X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fmonitor.js;h=9f43ce0a403540cca2299953c8db73c6290c9ea5;hb=435371c7ba4b60790953115b9ebed68a047bb0a3;hp=b58461be1de102cc280d14daede6a05805b65328;hpb=e99c53fb3be56eb4c685dd061eef0e5b5bf22b73;p=qomet.git diff --git a/public/javascripts/monitor.js b/public/javascripts/monitor.js index b58461b..9f43ce0 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) @@ -9,3 +7,74 @@ // 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, + }, + methods: { + // stage 0 --> 1 + startMonitoring: function() { + $.ajax("/start/monitoring", { + method: "GET", + data: { + password: this., + aname: examName, + cname: courseName, + }, + dataType: "json", + success: s => { + if (!!s.errmsg) + return this.warning(s.errmsg); + this.stage = 1; + }, + }); + }, + // TODO: 2-level sockets, for prof and monitors + socket = io.connect("/" + assessment.name, { + query: "number=" + this.student.number + "&password=" + this.password + }); + socket.on(message.allAnswers, this.setAnswers); + initializeStage2(s.questions, s.paper); + }, + }); + }, + // stage 2 --> 3 (or 4) + // from a message by statements component, or time over + // TODO: also function startAssessment (for main teacher only) + endAssessment: function() { + // Set endTime, destroy password + $("#leftButton, #rightButton").show(); + if (assessment.mode == "open") + { + this.stage = 4; + return; + } + $.ajax("/end/assessment", { + method: "GET", + data: { + aid: assessment._id, + number: this.student.number, + password: this.student.password, + }, + dataType: "json", + success: ret => { + if (!!ret.errmsg) + return this.warning(ret.errmsg); + assessment.conclusion = ret.conclusion; + this.stage = 3; + delete this.student["password"]; //unable to send new answers now + socket.disconnect(); + socket = null; + }, + }); + }, + }, +});