From 94f7e8cacc9980acd90a0d05f7a7c6f05f046876 Mon Sep 17 00:00:00 2001 From: Roman Vlasenko Date: Wed, 30 Nov 2022 18:46:56 +0300 Subject: [PATCH 1/2] Redirect messages from the exam page to the proctoring worker --- src/data/messages/handlers.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data/messages/handlers.js b/src/data/messages/handlers.js index 21f4969d..0e5c6aa4 100644 --- a/src/data/messages/handlers.js +++ b/src/data/messages/handlers.js @@ -1,5 +1,12 @@ import actionToMessageTypesMap from './constants'; +function makeRedirectHandler(worker) { + return function handler(e) { + const { data, origin } = e + worker.postMessage({ data, origin }) + } +} + function createWorker(url) { const blob = new Blob([`importScripts('${url}');`], { type: 'application/javascript' }); const blobUrl = window.URL.createObjectURL(blob); @@ -18,11 +25,14 @@ function workerTimeoutPromise(timeoutMilliseconds) { export function workerPromiseForEventNames(eventNames, workerUrl) { return (timeout, attemptExternalId) => { const proctoringBackendWorker = createWorker(workerUrl); + const redirectHandler = makeRedirectHandler(proctoringBackendWorker) + window.addEventListener('message', redirectHandler) return new Promise((resolve, reject) => { const responseHandler = (e) => { if (e.data.type === eventNames.successEventName) { proctoringBackendWorker.removeEventListener('message', responseHandler); proctoringBackendWorker.terminate(); + window.removeEventListener('message', redirectHandler) resolve(); } else { reject(e.data.error); From 348351d79fb2279703d6a6570da6783cf821debb Mon Sep 17 00:00:00 2001 From: Roman Vlasenko Date: Fri, 30 Jun 2023 17:37:50 +0500 Subject: [PATCH 2/2] Do not try to verify proctoring application on the course page --- src/core/OuterExamTimer.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/OuterExamTimer.jsx b/src/core/OuterExamTimer.jsx index 28188f42..7d0fd679 100644 --- a/src/core/OuterExamTimer.jsx +++ b/src/core/OuterExamTimer.jsx @@ -34,7 +34,7 @@ const ExamTimer = ({ courseId }) => { submitExam={submitExam} expireExamAttempt={expireExam} pollExamAttempt={pollAttempt} - pingAttempt={pingAttempt} + pingAttempt={() => {}} /> )} {apiErrorMsg && }