Commit 3ea299a3 authored by bhm15's avatar bhm15

Salvando e dando load dos dados em arquivos

parent abcaed8d
function save_data(){
if(dataSet == null){
alert("NOP");
return;
}
var tempos = []
for (var teste in dataSet){
tempos.push(buscaTempoResposta(dataSet[teste].stringResposta[0]));
}
var data = tempos;
var csvContent = "data:text/csv;charset=utf-8,";
csvContent += JSON.stringify(dataSet);
var encodedUri = encodeURI(csvContent);
//window.open(encodedUri,"ahsuhas");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", "my_data.stroop");
document.body.appendChild(link); // Required for FF
link.click(); // This will download the data file named "my_data.csv".
}
function load_data(inputFiles){
f = inputFiles[0];
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
var data = e.target.result;
dataSet = JSON.parse(data);
salvaTestes();
location.reload();
}
})(f);
reader.readAsBinaryString(f);
}
......@@ -53,8 +53,10 @@
</div>
<div class="corpo">
<input id='hidden_1' type='hidden' name='acao' value=''>
<button type="submit" class="pure-button pure-button-primary" class='botao_submit' value='enviado' onClick="downloadCsv();">Baixar os resultados</button>
<button type="submit" class="pure-button pure-button-primary" class='botao_submit' value='enviado' onClick="buscaTestes()">Examinar o gráfico</button>
<button class="pure-button pure-button-primary" class='botao_submit' value='enviado' onClick="downloadCsv();">Baixar os resultados</button>
<button class="pure-button pure-button-primary" class='botao_submit' value='enviado' onClick="buscaTestes()">Examinar o gráfico</button>
<button class="pure-button pure-button-primary" onClick="save_data();">Salvar dados</button>
<input type="file" id="input_load_data" onchange="load_data(this.files)">
<br>
<br>
<a class="pure-button pure-button-primary" href="index.html">Fazer teste</a>
......@@ -90,4 +92,5 @@
</body>
<script src="js/professor.js"></script>
<script src="js/save_data.js"></script>
</html>
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