-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata_display_end.html
More file actions
165 lines (134 loc) · 5.97 KB
/
data_display_end.html
File metadata and controls
165 lines (134 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html>
<script src="javascript/jquery-3.1.1.min.js"></script>
<script src="/assets/javascripts/jatos.js"></script>
<script src="lib/papaparse.min.js"></script>
<script src="lib/d3.min.js"></script>
<script src="filesaver/FileSaver.js"></script>
<link href="static/css/forms.css" rel="stylesheet" type="text/css" media="all">
<link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
</body>
<div class=FormBox>
<div id="message_div"></div>
<div id="data_div">
<h3> Résultats</h3>
</div>
<br>
<button id="db" type="button" class="btn">Télécharger</button>
<button id="download_button_full" type="button" class="btn">Télécharger résultats détaillés</button>
</div>
<script>
function median(values){
values.sort(function(a,b){
return a-b;
});
if(values.length ===0) return 0
var half = Math.floor(values.length / 2);
if (values.length % 2)
return values[half];
else
return (values[half - 1] + values[half]) / 2.0;
}
function displayCSV(data){
var parsedCSV = d3.csvParseRows(data);
var container = d3.select("#data_div")
.append("table")
.selectAll("tr")
.data(parsedCSV).enter()
.append("tr")
.selectAll("td")
.data(function(d) { return d; }).enter()
.append("td")
.text(function(d) { return d; });
}
jatos.onLoad(function () {
var lang = "default";
if (jatos.studySessionData.language){
lang = jatos.studySessionData.language;
}
mode = jatos.studySessionData.task_type;
results = jatos.studySessionData.results;
formatted_data = {
"fields" : ["Partie", "Numero de tache", "Temps (ms)", "# Erreurs", "# Ecoutes"],
"data" :[]
}
formatted_time_data = {
"fields" : ["Partie", "Meilleur temps (ms)", "Pire temps (ms)", "Temps moyen (ms)", "Temps mediane(ms)", "# Erreurs", "# Ecoutes"],
"data" :[]
}
all_phase_names = {
"COLOR":{
1:"Partie 1a - Recherche de sons ",
2:"Partie 1b - Recherche de sons (rapidement)",
3:"Partie 2a - Association entre son et couleur",
4:"Partie 2a - Association entre son et couleur (rapidement)",
5:"Partie 3 - Recherche de sons à l'aide de la couleur",
},
"TEXTURE":{
1:"Partie 1a - Recherche de sons ",
2:"Partie 1b - Recherche de sons (rapidement)",
3:"Partie 2a - Association entre sons et textures",
4:"Partie 2a - Association entre sons et textures (rapidement)",
5:"Partie 3 - Recherche de sons à l'aide de la texture",
},
"SHAPE":{
1:"Partie 1a - Recherche de sons ",
2:"Partie 1b - Recherche de sons (rapidement)",
3:"Partie 2a - Association entre sons et formes",
4:"Partie 2a - Association entre sons et formes (rapidement)",
5:"Partie 3 - Recherche de sons à l'aide de la forme",
}
}
console.log(mode);
phase_names=all_phase_names[mode];
//Get data skipping training session
for( let phase_index = 1;phase_index<Object.keys(results).length;phase_index++){
phase_data = results[phase_index];
var times = []
var errors = 0;
var listens = 0;
for(let task_index =0 ;task_index<Object.keys(phase_data).length;task_index++){
task_data = phase_data[task_index];
formatted_data["data"].push( [phase_names[phase_index], task_index, task_data["time"], task_data["misclicks"], task_data["listens"]]);
times.push(task_data["time"]);
errors += task_data["misclicks"];
listens += task_data["listens"];
}
bestTime = Math.min(...times);
worstTime = Math.max(...times);
averageTime = times.reduce((a,b) => a + b, 0)/times.length;
medTime = median(times)
formatted_time_data["data"].push([phase_names[phase_index], bestTime, worstTime, averageTime, medTime, errors,listens])
}
console.log(formatted_data);
data_csv = Papa.unparse(formatted_data);
time_csv = Papa.unparse(formatted_time_data);
displayCSV(time_csv);
data_csv_blob = new Blob([data_csv], { type: "text/csv;charset=utf-8" });
time_csv_blob = new Blob([time_csv], { type: "text/csv;charset=utf-8" });
$.ajax({
url:"static/html/task_descriptions.html",
type:'GET',
success: function(data) {
let message = $('<div>').append(data).find('#end_message_students').find(`#${lang}`)
$('#message_div').html( message );
document.body.innerHTML = document.body.innerHTML.replace(/ID_STRING/g, jatos.studySessionData["uuid"]);
$("#db").click(function(){
// debugger;
saveAs(time_csv_blob, "donnees_etude.csv");
// l = createDownloadableCsvFile("donnees_etude.csv", time_csv)
console.log("Download")
});
$("#download_button_full").click(function(){
console.log("Download 2")
saveAs(data_csv_blob, "donnees_etude_completes.csv");
});
}
});
});
</script>
</body>