logo

Crowdly

Browser

Додати до Chrome

(function () { if (window.__cbGuard) return; window.__cbGuard = true; /...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

(function () {

if (window.__cbGuard) return;

window.__cbGuard = true;

// only the attempt page. the review and summary pages also render question

// text, and running there would show the red screen again and try to finish

// an attempt that is already finished

if (!/\/attempt\.php$/.test(location.pathname)) return;

/* ---------- tuning ---------- */

var STRIKES_TO_END = 2;

var END_COUNTDOWN_S = 8; // the red screen stays this long before the attempt is submitted

var HIDDEN_GRACE_MS = 800; // tab switched, app switched, window minimised

var BLUR_GRACE_MS = 1500; // focus lost but page still visible. switching apps on a desktop does this

var SELECT_GRACE_MS = 2500; // a native dropdown was open. browsing its options steals focus too

// everything is keyed to this attempt, so a new attempt in the same tab

// starts clean and the state of an old one cannot leak into it

var ATTEMPT = (/[?&]attempt=(\d+)/.exec(location.search) || [])[1] || "none";

var K_STRIKES = "cbguard_" + ATTEMPT + "_strikes", K_ENDED = "cbguard_" + ATTEMPT + "_ended",

K_WARN = "cbguard_" + ATTEMPT + "_warn", K_CONSENT = "cbguard_" + ATTEMPT + "_consent";

var NAVY = "#06205E", AMBER = "#B57B0D", RED = "#A32B22";

var FONT = "'Segoe UI',Calibri,Arial,sans-serif";

/* ---------- storage that survives page changes inside the attempt ---------- */

function get(k) { try { return sessionStorage.getItem(k); } catch (e) { return window["__cb_" + k] || null; } }

function set(k, v) { try { sessionStorage.setItem(k, v); } catch (e) {} window["__cb_" + k] = v; }

function strikes() { return parseInt(get(K_STRIKES) || "0", 10) || 0; }

/* ---------- banner ---------- */

var bar = document.createElement("div");

bar.id = "cb-guard-bar";

bar.setAttribute("style", "position:fixed;top:0;left:0;right:0;z-index:2147482000;background:" + NAVY +

";color:#fff;font:600 14px/1.4 " + FONT + ";padding:9px 16px;text-align:center;letter-spacing:.4px;" +

"box-shadow:0 2px 8px rgba(0,0,0,.25);user-select:none;-webkit-user-select:none");

bar.textContent = "CLOSED BOOK EXAM · Leaving this window skips the question. Leaving it twice ends the exam.";

document.body.appendChild(bar);

document.body.style.paddingTop = (bar.offsetHeight + 4) + "px";

/* ---------- full screen notices ---------- */

function overlay(colour, title, lines, buttonText, needTick, onOk) {

var old = document.getElementById("cb-guard-overlay"); if (old) old.parentNode.removeChild(old);

var o = document.createElement("div"); o.id = "cb-guard-overlay";

o.setAttribute("style", "position:fixed;inset:0;z-index:2147483000;background:rgba(6,32,94,.92);display:flex;" +

"align-items:center;justify-content:center;padding:24px;font-family:" + FONT + ";user-select:none;-webkit-user-select:none");

var box = document.createElement("div");

box.setAttribute("style", "background:#fff;max-width:640px;width:100%;border-top:8px solid " + colour + ";padding:28px 30px;box-shadow:0 20px 60px rgba(0,0,0,.4)");

var h = document.createElement("div");

h.setAttribute("style", "font:700 24px/1.2 Cambria,Georgia,serif;color:" + colour + ";margin:0 0 14px");

h.textContent = title; box.appendChild(h);

lines.forEach(function (t) {

var p = document.createElement("p"); p.setAttribute("style", "font:15px/1.55 " + FONT + ";color:#1D2B4A;margin:0 0 10px"); p.textContent = t; box.appendChild(p);

});

var btn = null;

if (buttonText) {

var tick = null;

if (needTick) {

var lab = document.createElement("label");

lab.setAttribute("style", "display:flex;gap:10px;align-items:flex-start;font:600 15px/1.45 " + FONT + ";color:" + NAVY + ";margin:18px 0 14px;cursor:pointer");

tick = document.createElement("input"); tick.type = "checkbox"; tick.id = "cb-guard-tick"; tick.setAttribute("style", "width:18px;height:18px;margin-top:3px;flex:none");

var span = document.createElement("span"); span.textContent = needTick; lab.appendChild(tick); lab.appendChild(span); box.appendChild(lab);

}

btn = document.createElement("button"); btn.id = "cb-guard-ok";

btn.setAttribute("style", "background:" + colour + ";color:#fff;border:0;font:600 16px " + FONT + ";padding:13px 24px;cursor:pointer;margin-top:6px;opacity:" + (needTick ? ".4" : "1"));

btn.textContent = buttonText; btn.disabled = !!needTick;

if (tick) tick.addEventListener("change", function () { btn.disabled = !tick.checked; btn.style.opacity = tick.checked ? "1" : ".4"; });

btn.addEventListener("click", function () { if (btn.disabled) return; o.parentNode.removeChild(o); if (onOk) onOk(); });

box.appendChild(btn);

}

o.appendChild(box); document.body.appendChild(o);

return o;

}

/* ---------- ended. the red screen, and it stays ended ---------- */

function showEnded(seconds) {

bar.textContent = "This exam has been ended."; bar.style.background = RED;

var o = overlay(RED, "Your exam has been ended",

["The exam window was left a second time. Your attempt is being submitted with the answers you had given up to that point.",

"This page can no longer be used. Going back, reloading or reopening it will not restore the attempt.",

"If you believe this happened by mistake, speak to the invigilator now, without leaving the room."],

null);

if (seconds) {

var cd = document.createElement("p"); cd.id = "cb-guard-countdown";

cd.setAttribute("style", "font:600 15px " + FONT + ";color:" + RED + ";margin:14px 0 0");

var box = o.firstChild; box.appendChild(cd);

var left = seconds;

cd.textContent = "Submitting in " + left + " seconds.";

var iv = setInterval(function () { left--; if (left <= 0) { clearInterval(iv); cd.textContent = "Submitting now."; return; }

cd.textContent = "Submitting in " + left + " seconds."; }, 1000);

}

var form = document.getElementById("responseform");

if (form) Array.prototype.forEach.call(form.querySelectorAll("input, select, textarea, button"), function (el) { el.disabled = true; });

}

/* ---------- finishing the attempt in one step ---------- */

function q(sel) { try { return document.querySelector(sel); } catch (e) { return null; } }

function finishAttempt() {

var m = /[?&]attempt=(\d+)/.exec(location.search);

var cm = /[?&]cmid=(\d+)/.exec(location.search);

var sk = (window.M && M.cfg && M.cfg.sesskey) || (q("input[name=sesskey]") || {}).value;

if (m && sk) {

var f = document.createElement("form"); f.method = "POST"; f.id = "cb-guard-finish";

f.action = location.pathname.replace(/[^\/]*$/, "processattempt.php");

var fields = { attempt: m[1], finishattempt: "1", timeup: "0", sesskey: sk, slots: "" };

if (cm) fields.cmid = cm[1];

Object.keys(fields).forEach(function (k) {

var i = document.createElement("input"); i.type = "hidden"; i.name = k; i.value = fields[k]; f.appendChild(i);

});

document.body.appendChild(f); f.submit(); return true;

}

var fin = q("a.endtestlink") || q("input[value*='Finish attempt']");

if (fin) fin.click();

var tries = 0, iv = setInterval(function () {

var b = q("#mod_quiz-submit-all-btn") || Array.prototype.slice.call(document.querySelectorAll("button, input[type=submit]"))

.filter(function (el) { return /submit all and finish/i.test(el.textContent || el.value || ""); })[0];

if (b) b.click();

var c = Array.prototype.slice.call(document.querySelectorAll(".modal button, [data-action='save'], button.btn-primary"))

.filter(function (el) { return /submit all and finish|yes|confirm/i.test(el.textContent || el.value || ""); })[0];

if (c) c.click();

if (++tries > 25) clearInterval(iv);

}, 400);

return false;

}

function endExam() {

set(K_ENDED, "1");

showEnded(END_COUNTDOWN_S);

setTimeout(finishAttempt, END_COUNTDOWN_S * 1000);

}

/* ---------- skipping the current question ---------- */

function clearAnswers() {

var form = document.getElementById("responseform"); if (!form) return;

Array.prototype.forEach.call(form.querySelectorAll("input[type=radio], input[type=checkbox]"), function (el) { el.checked = false; });

Array.prototype.forEach.call(form.querySelectorAll("select"), function (el) { el.selectedIndex = 0; });

Array.prototype.forEach.call(form.querySelectorAll("input[type=text], input[type=number], textarea"), function (el) { el.value = ""; });

}

function goNext() {

var n = q("#mod_quiz-next-nav") || q("input[name='next']") || q("input.mod_quiz-next-nav");

if (n) { n.click(); return; }

var fin = q("a.endtestlink"); if (fin) fin.click();

}

function warnBanner() {

bar.textContent = "You left the window once. Leave again and your exam ends automatically."; bar.style.background = AMBER;

}

function showWarning(thenNext) {

overlay(AMBER, "You left the exam window",

["The question you were on has been skipped. Its answers were cleared and it cannot be reopened.",

"This is your only warning. If you leave this window again, for any reason, your exam ends automatically and is submitted exactly as it stands at that moment.",

"Close every other application now. Turn off notifications. Stay on this page until you have finished."],

"I understand. Continue the exam",

"I acknowledge that leaving this window again ends my exam automatically.",

function () { set(K_WARN, "0"); if (thenNext) goNext(); });

}

function skipQuestion() {

set(K_WARN, "1");

warnBanner();

clearAnswers();

showWarning(true);

}

function strike() {

if (get(K_ENDED) === "1") return;

var n = strikes() + 1; set(K_STRIKES, String(n));

if (n >= STRIKES_TO_END) endExam(); else skipQuestion();

}

/* ---------- detecting that the window was really left ---------- */

var awaySince = null, awayKind = null;

function dropdownHasFocus() {

var a = document.activeElement;

return !!(a && a.tagName === "SELECT");

}

function onHidden() { if (awaySince === null) { awaySince = Date.now(); awayKind = "hidden"; } }

function onBlur() {

if (document.hidden) return;

if (awaySince === null) { awaySince = Date.now(); awayKind = dropdownHasFocus() ? "select" : "blur"; }

}

function onBack() {

if (awaySince === null) return;

var away = Date.now() - awaySince, kind = awayKind; awaySince = null; awayKind = null;

var limit = kind === "hidden" ? HIDDEN_GRACE_MS : kind === "select" ? SELECT_GRACE_MS : BLUR_GRACE_MS;

if (away >= limit) strike();

}

document.addEventListener("visibilitychange", function () { document.hidden ? onHidden() : onBack(); });

window.addEventListener("blur", onBlur);

window.addEventListener("focus", onBack);

/* ---------- copy, paste, selection, right click ---------- */

var block = function (e) { e.preventDefault(); e.stopPropagation(); return false; };

function isAnswerBox(t) { return t && (t.tagName === "TEXTAREA" || (t.tagName === "INPUT" && /text|number/.test(t.type))); }

["copy", "cut", "paste", "contextmenu", "dragstart", "drop"].forEach(function (ev) {

document.addEventListener(ev, function (e) { if (ev === "paste" || ev === "drop" || !isAnswerBox(e.target)) return block(e); }, true);

});

document.addEventListener("selectstart", function (e) { if (!isAnswerBox(e.target)) return block(e); }, true);

document.addEventListener("keydown", function (e) {

var k = (e.key || "").toLowerCase();

if ((e.ctrlKey || e.metaKey) && ["c", "x", "v", "p", "s", "u", "a"].indexOf(k) !== -1) return block(e);

if (k === "f12" || k === "printscreen") return block(e);

if ((e.ctrlKey || e.metaKey) && e.shiftKey && ["i", "j", "c"].indexOf(k) !== -1) return block(e);

}, true);

var style = document.createElement("style");

style.textContent = ".que .qtext, .que .answer, .que .formulation { -webkit-user-select:none; user-select:none; }" +

".que textarea, .que input[type=text] { -webkit-user-select:text; user-select:text; }";

document.head.appendChild(style);

/* ---------- what to show when a page opens ---------- */

function onPageOpen() {

if (get(K_ENDED) === "1") { showEnded(2); setTimeout(finishAttempt, 2000); return; }

if (strikes() >= 1) warnBanner();

// the warning was shown on the page where it happened. if it was never

// acknowledged, because the page moved on or was reloaded, show it here

if (get(K_WARN) === "1") { showWarning(false); return; }

if (get(K_CONSENT) !== "1") {

overlay(NAVY, "Before you start",

["This is a closed book examination taken alone. By continuing you confirm the following.",

"You will not use any AI assistant, chatbot or language model, on this device or any other, during the exam.",

"You will not use social media, messaging, email or any other communication tool during the exam.",

"You have closed every other application and turned off notifications, and you have no software running that can read this page or interact with it.",

"You will not leave this window. Leaving it once skips the current question. Leaving it twice ends the exam and submits it as it stands.",

"You understand that a breach of these conditions is treated as academic fraud under the school's regulations."],

"I agree, start the exam",

"I confirm all of the above and I take the exam under these conditions.",

function () { set(K_CONSENT, "1"); });

}

}

onPageOpen();

window.addEventListener("pageshow", function (e) { if (e.persisted) onPageOpen(); });

})();

Which of these scan notes is a valid signal?

100%
0%
0%
0%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на elearning.mbs-education.com?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome