X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fmonitor.js;h=5d5f237c44db3fd38218dc81f32f24281a87b9da;hb=f6648c37a3c13efbbc3b8c03c6ff725984c98843;hp=b58461be1de102cc280d14daede6a05805b65328;hpb=e99c53fb3be56eb4c685dd061eef0e5b5bf22b73;p=qomet.git diff --git a/public/javascripts/monitor.js b/public/javascripts/monitor.js index b58461b..5d5f237 100644 --- a/public/javascripts/monitor.js +++ b/public/javascripts/monitor.js @@ -1,5 +1,3 @@ -// UNIMPLEMENTED - // TODO: onglets pour chaque groupe + section déroulante questionnaire (chargé avec réponses) // NOM Prenom (par grp, puis alphabétique) // réponse : vert si OK (+ choix), rouge si faux, gris si texte (clic pour voir) @@ -8,4 +6,51 @@ // Affiché si (hash du) mdp du cours est correctement entré // Doit reprendre les données en base si refresh (sinon : sockets) -// Also buttons "start exam", "end exam" for logged in teacher +let socket = null; //monitor answers in real time + +new Vue({ + el: "#monitor", + data: { + password: "", //from password field + assessment: null, //obtained after authentication + // Stage 0: unauthenticated (password), + // 1: authenticated (password hash validated), start monitoring + stage: 0, + answers: { + displayAll: true, + showSolution: true, //TODO: allow to hide, to let teachers search too + inputs: [ ], + index : -1, + }, + }, + methods: { + // stage 0 --> 1 + startMonitoring: function() { + $.ajax("/start/monitoring", { + method: "GET", + data: { + password: this.password, + aname: examName, + cname: courseName, + initials: initials, + }, + dataType: "json", + success: s => { + if (!!s.errmsg) + return this.warning(s.errmsg); + this.assessment = JSON.parse(s.assessment); + this.stage = 1; + socket = io.connect("/", { + query: "aid=" + this.assessment._id + "&secret=" + s.secret + }); + socket.on(message.newAnswer, m => { + let paperIdx = this.assessment.papers.findIndex( item => { + return item.number == m.number; + }); + this.assessment.papers[paperIdx].inputs.push(m.input); //answer+index + }); + }, + }); + }, + }, +});