Commit 1fe5f66c authored by pet's avatar pet

Csv funcionando

parent 7162aca4
......@@ -205,11 +205,7 @@ function downloadCsv(){
var csvContent = "data:text/csv;charset=utf-8,";
for(var i in dataSet){
csvContent += dataSet[i].nome+" - "+dataSet[i].grupo+","
}
csvContent+="\n";
if(dataSet.length < 1){
alert("Não há nenhum teste registrado!");
return;
......@@ -218,23 +214,23 @@ function downloadCsv(){
ordemFiltrada = filtraOrdemBateria(dataSet[0].ordemBateria);
function scpAspas(t){
return "'"+t+"'";
return "\""+t+"\"";
}
var tabela = [];
tabela.push([]);
tabela[0][0] = "''";
tabela[0][0] = "\"\"";
var congruenteIndex = [];
var incongruenteIndex = [];
for(i in ordemFiltrada){
if(ordemFiltrada[i] == "C"){
congruenteIndex.push(i);
congruenteIndex.push(parseInt(i));
//tabela[0].push(","+scapeAspasSimples(ordemFiltrada[i]));
}
if(ordemFiltrada[i] == "I"){
incongruenteIndex.push(i);
incongruenteIndex.push(parseInt(i));
}
}
......@@ -244,24 +240,24 @@ function downloadCsv(){
for(var i = 0; i < numCongruentes; i++){
tabela[0].push(",'C "+(i+1)+"'");
tabela[0].push(",\"C "+(i+1)+"\"");
}
tabela[0].push(",'Média C','Dev Pad C', 'Erro C', 'Acertos C'");
tabela[0].push(",\"Média C\",\"Dev Pad C\", \"Erro C\", \"Acertos C\"");
for(var i = 0; i < numCongruentes; i++){
tabela[0].push(",'C "+(i+1)+"'");
tabela[0].push(",\"C M"+(i+1)+"\"");
}
tabela[0].push(",'Média C M','Dev Pad C M', 'Erro C M', 'Acertos C M'");
tabela[0].push(",\"Média C M \",\"Dev Pad C M\", \"Erro C M\", \"Acertos C M\"");
for(var i = 0; i < numIncongruentes; i++){
tabela[0].push(",'I "+(i+1)+"'");
tabela[0].push(",\"I "+(i+1)+"\"");
}
tabela[0].push(",'Média I','Dev Pad I', 'Erro I', 'Acertos I'");
tabela[0].push(",\"Média I\",\"Dev Pad I\", \"Erro I\", \"Acertos I\"");
for(var i = 0; i < numIncongruentes; i++){
tabela[0].push(",'I "+(i+1)+"'");
tabela[0].push(",\"I M"+(i+1)+"\"");
}
tabela[0].push(",'Média I M','Dev Pad I M', 'Erro I M', 'Acertos I M'");
tabela[0].push(",\"Média I M \",\"Dev Pad I M\", \"Erro I M\", \"Acertos I M\"");
var dicionario = {}
......@@ -280,70 +276,127 @@ function downloadCsv(){
var soma = 0;
for(var i in teste){
if(teste[i].acertou){
soma+=teste[i].tempo;
soma+=parseFloat(teste[i].tempo);
acertos++;
}
//console.log(teste[i]);
}
var media = 0;
if(acertos > 0){
media = (soma/acertos);
}
return {media: media, acertos: acertos};
}
for(p in dicionario){
var line = [];
var line = [p];
var pessoa = dicionario[p];
var acertosTotais = 0;
for(b in pessoa){
var bateria = pessoa[b];
if(bateria.grupo == 1){
for(var j in congruenteIndex){
media = mediaTeste(bateria.stringResposta[j]);
var index = congruenteIndex[j];
media = mediaTeste(bateria.stringResposta[index]);
acertosTotais+=media.acertos;
line.push(","+scpAspas(media.media))
}
}
}
line.push(",\"\""); //media
line.push(",\"\""); //desvio padrao
line.push(",\"\""); //erro
line.push(","+scpAspas(acertosTotais));
tabela.push(line);
}
console.log(tabela);
console.log(dicionario);
return;
//~ for(var i = 0; i < ordemFiltrada.length+ordemFiltrada.length; i++){
//~ for(var j in dataSet[0].stringResposta[0]){
//~ lines.push("");
//~ }
//~ }
//~ for(var i in dataSet){
//~ for(var j in dataSet[i].stringResposta){
//~ j = parseInt(j);
//~
//~ if(ordemFiltrada[j]=="C"){
//~ lineIndex = parseInt(j*dataSet[i].stringResposta[j].length)+j;
//~ lines[lineIndex]+="Congruente,";
//~ }
//~ if(ordemFiltrada[j]=="I"){
//~ lineIndex = parseInt(j*dataSet[i].stringResposta[j].length)+j;
//~ lines[lineIndex]+="Incongruente,";
//~ }
//~ for(var k in dataSet[i].stringResposta[j]){
//~ lineIndex = parseInt(j*dataSet[i].stringResposta[j].length) + parseInt(k);
//~ lineIndex=parseInt(lineIndex)+1+parseInt(j);
//~ if(dataSet[i].stringResposta[j][k].acertou)
//~ lines[lineIndex]+="Acerto - ";
//~ else
//~ lines[lineIndex]+="Erro - ";
//~ lines[lineIndex] +=(dataSet[i].stringResposta[j][k].tempo+",");
//~ }
//~
//~ }
//~ }
csvContent += lines.join("\n");
var i = 1;
for(p in dicionario){
var pessoa = dicionario[p];
var acertosTotais = 0;
for(b in pessoa){
var bateria = pessoa[b];
if(bateria.grupo == 2){
for(var j in congruenteIndex){
var index = congruenteIndex[j];
media = mediaTeste(bateria.stringResposta[index]);
acertosTotais+=media.acertos;
tabela[i].push(","+scpAspas(media.media))
}
}
}
tabela[i].push(",\"\""); //media
tabela[i].push(",\"\""); //desvio padrao
tabela[i].push(",\"\""); //erro
tabela[i].push(","+scpAspas(acertosTotais));
i++;
}
var i = 1;
for(p in dicionario){
var pessoa = dicionario[p];
var acertosTotais = 0;
for(b in pessoa){
var bateria = pessoa[b];
if(bateria.grupo == 1){
for(var j in incongruenteIndex){
var index = incongruenteIndex[j];
media = mediaTeste(bateria.stringResposta[index]);
acertosTotais+=media.acertos;
tabela[i].push(","+scpAspas(media.media));
}
}
}
tabela[i].push(",\"\""); //media
tabela[i].push(",\"\""); //desvio padrao
tabela[i].push(",\"\""); //erro
tabela[i].push(","+scpAspas(acertosTotais));
i++;
}
var i = 1;
for(p in dicionario){
var pessoa = dicionario[p];
var acertosTotais = 0;
for(b in pessoa){
var bateria = pessoa[b];
if(bateria.grupo == 2){
for(var j in incongruenteIndex){
var index = incongruenteIndex[j];
media = mediaTeste(bateria.stringResposta[index]);
acertosTotais+=media.acertos;
tabela[i].push(","+scpAspas(media.media))
}
}
}
tabela[i].push(",\"\""); //media
tabela[i].push(",\"\""); //desvio padrao
tabela[i].push(",\"\""); //erro
tabela[i].push(","+scpAspas(acertosTotais));
i++;
}
for(var l in tabela){
csvContent+= tabela[l].join("")+"\n";
}
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment