Merge forename + name into [identifying] 'name' (more general)
[qomet.git] / public / javascripts / monitor.js
index 6c08d7a..8963731 100644 (file)
@@ -29,12 +29,7 @@ new Vue({
                        return this.students
                                .filter( s => { return group==0 || s.group == group; })
                                .map( s => { return Object.assign({}, s); }) //not altering initial array
-                               .sort( (a,b) => {
-                                       let res = a.name.localeCompare(b.name);
-                                       if (res == 0)
-                                               res += a.forename.localeCompare(b.forename);
-                                       return res;
-                               });
+                               .sort( (a,b) => { return a.name.localeCompare(b.name); });
                },
                groupList: function() {
                        let maxGrp = 1;
@@ -81,7 +76,11 @@ new Vue({
                                        if (!!s.errmsg)
                                                return alert(s.errmsg);
                                        this.assessment = s.assessment;
-                                       this.answers.inputs = s.assessment.questions.map( q => { return q.answer; });
+                                       this.answers.inputs = s.assessment.questions.map( q => {
+                                               let input = _(q.options.length).times( _.constant(false) );
+                                               q.answer.forEach( idx => { input[idx] = true; });
+                                               return input;
+                                       });
                                        this.students = s.students;
                                        this.stage = 1;
                                        socket = io.connect("/", {
@@ -101,7 +100,7 @@ new Vue({
                                                        });
                                                }
                                                // TODO: notations not coherent (input / answer... when, which ?)
-                                               this.assessment.papers[paperIdx].inputs.push(m.answer); //input+index
+                                               this.assessment.papers[paperIdx].inputs.push(JSON.parse(m.answer)); //input+index
                                        });
                                },
                        });
@@ -110,7 +109,7 @@ new Vue({
                        // In the end, send answers to students
                        socket.emit(
                                message.allAnswers,
-                               { answers: this.assessment.questions.map( q => { return q.answer; }) }
+                               { answers: JSON.stringify(this.assessment.questions.map( q => { return q.answer; })) }
                        );
                },
        },