X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fassessment.js;h=ec56309e7aaf8aeb40283ee7418785ecfdeb5a10;hb=43828378be054cf3604b753e8d9ab24af911188f;hp=ad309d7cf12d98e1656d55868b788c5d1db29d6f;hpb=29c8b391bcdf6ffca53545178e2ad194287a1bdc;p=qomet.git diff --git a/public/javascripts/assessment.js b/public/javascripts/assessment.js index ad309d7..ec56309 100644 --- a/public/javascripts/assessment.js +++ b/public/javascripts/assessment.js @@ -12,7 +12,7 @@ function checkWindowSize() return window.innerWidth >= screen.width-3 && window.innerHeight >= screen.height-3; }; -let V = new Vue({ +new Vue({ el: "#assessment", data: { assessment: assessment, @@ -39,25 +39,53 @@ let V = new Vue({ }, mounted: function() { $(".modal").modal(); - if (assessment.mode != "secure") - return; - window.addEventListener("keydown", e => { - // Ignore F12 (avoid accidental window resize due to devtools) - // NOTE: in Chromium at least, fullscreen mode exit with F11 cannot be prevented. - // Workaround: disable key at higher level. Possible xbindkey config: - // "false" - // m:0x10 + c:95 - // Mod2 + F11 - if (e.keyCode == 123) - e.preventDefault(); - }, false); + if (assessment.mode != "open") + { + window.addEventListener("keydown", e => { + // Ignore F12 (avoid accidental window resize due to devtools) + // NOTE: in Chromium at least, fullscreen mode exit with F11 cannot be prevented. + // Workaround: disable key at higher level. Possible xbindkey config: + // "false" + // m:0x10 + c:95 + // Mod2 + F11 + if (e.keyCode == 123) + e.preventDefault(); + }, false); + } window.addEventListener("blur", () => { - this.trySendCurrentAnswer(); - document.location.href= "/noblur"; + if (!socket) + return; + if (assessment.mode == "secure") + { + this.trySendCurrentAnswer(); + document.location.href= "/noblur"; + } + else if (assessment.mode == "exam") + socket.emit(message.studentBlur, {number:this.student.number}); }, false); + if (assessment.mode == "exam") + { + window.addEventListener("focus", () => { + if (!socket) + return; + socket.emit(message.studentFocus, {number:this.student.number}); + }, false); + } window.addEventListener("resize", e => { - this.trySendCurrentAnswer(); - document.location.href= "/fullscreen"; + if (!socket) + return; + if (assessment.mode == "secure") + { + this.trySendCurrentAnswer(); + document.location.href= "/fullscreen"; + } + else if (assessment.mode == "exam") + { + if (checkWindowSize()) + socket.emit(message.studentFullscreen, {number:this.student.number}); + else + socket.emit(message.studentResize, {number:this.student.number}); + } }, false); }, methods: { @@ -105,6 +133,9 @@ let V = new Vue({ $("#leftButton, #rightButton").hide(); if (assessment.time > 0) { + +// TODO: distinguish total exam time AND question time + const deltaTime = !!paper ? Date.now() - paper.startTime : 0; this.remainingTime = assessment.time * 60 - Math.round(deltaTime / 1000); this.runTimer(); @@ -246,7 +277,6 @@ let V = new Vue({ success: ret => { if (!!ret.errmsg) return this.showWarning(ret.errmsg); - assessment.conclusion = ret.conclusion; this.stage = 3; delete this.student["password"]; //unable to send new answers now },