From 6b2aa17cafee2d33f8c2311f30d35833ff0c71c8 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic <philip.kaludercic@fau.de> Date: Sun, 21 Jan 2024 13:00:54 +0000 Subject: [PATCH] Generate permalink contents --- quiz.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/quiz.js b/quiz.js index 534092b..f36fdc9 100644 --- a/quiz.js +++ b/quiz.js @@ -7,7 +7,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/. */ "use strict"; -const version = "$Id: quiz.js,v 1.21 2024/01/21 11:04:51 oj14ozun Exp oj14ozun $"; +const version = "$Id: quiz.js,v 1.22 2024/01/21 12:38:48 oj14ozun Exp oj14ozun $"; const js_version = document.getElementById("js-version"); js_version.innerText = version; @@ -25,6 +25,7 @@ const stats = document.getElementById("stats"); const report = document.getElementById("report"); const correct = document.getElementById("correct"); const wrong = document.getElementById("wrong"); +const perma = document.getElementById("perma"); const class_list = document.documentElement.classList; @@ -80,6 +81,15 @@ function remember(q, ok) { } function pick() { + const qid = new URLSearchParams(window.location.search).get("show"); + if (qid) { + const q = questions.find(q => q.id == qid); + if (q) { + return q; + } + console.error("Invalid ID: " + qid); + } + let choice = questions[0]; let worst = evaluate(choice); @@ -176,6 +186,9 @@ function next() { let title = `Problem mit der Frage: "${text.innerText}" (${q.source})`; let desc = "(Ersetze diesen Text mit einer Beschreibung des Problems)" report.href = `${gitlab_base}/issues/new?issue[title]=${encodeURIComponent(title)}&issue[description]=${encodeURIComponent(desc)}`; + + // update permalink + perma.href = `?show=${encodeURIComponent(q.id)}`; } function submit() { -- GitLab