diff --git a/web/src/eval.js b/web/src/eval.js
index ed057cc..926fdbd 100644
--- a/web/src/eval.js
+++ b/web/src/eval.js
@@ -209,19 +209,23 @@ export function evalQuestion(question) {
let text = choices[Math.floor(Math.random() * choices.length)];
question.feedbackPopupDiv.innerHTML = text;
question.feedbackPopupDiv.style.color =
- question.state === QuestionState.passed ? "green" : "maroon";
- question.feedbackPopupDiv.style.display = "block";
+ question.state === QuestionState.passed ? "var(--green)" : "var(--red)";
+ question.feedbackPopupDiv.style.display = "flex";
setTimeout(() => {
question.feedbackPopupDiv.style.display = "none";
- }, 500);
+ }, 1000);
// change the question button
+ question.editingEnabled = true;
if (question.state === QuestionState.passed) {
- if (question.src.instances.length > 0) {
+ question.editingEnabled = false;
+ if (question.src.instances.length > 1) {
// if the student passed and there are other question instances,
// provide the ability to repeat the question
question.checkAndRepeatBtn.innerHTML = iconRepeat;
- } else question.checkAndRepeatBtn.style.display = "none";
- } else {
+ } else {
+ question.checkAndRepeatBtn.style.visibility = "hidden";
+ }
+ } else if (question.checkAndRepeatBtn != null) {
// in case of non-passing, the check button must be provided (kept)
question.checkAndRepeatBtn.innerHTML = iconCheck;
}
diff --git a/web/src/icons.js b/web/src/icons.js
index c6d9e0f..a1c1cb9 100644
--- a/web/src/icons.js
+++ b/web/src/icons.js
@@ -27,7 +27,7 @@ export const iconCircleChecked =
// icon at the bottom of a question to check the question
export const iconCheck =
- '';
+ '';
// icon at the bottom of a question to repeat the question
-export const iconRepeat = ``;
+export const iconRepeat = ``;
diff --git a/web/src/index.js b/web/src/index.js
index 493f900..17b8c7b 100644
--- a/web/src/index.js
+++ b/web/src/index.js
@@ -5,8 +5,17 @@
******************************************************************************/
import { genDiv } from "./dom.js";
-import { courseInfo1, courseInfo2, courseInfo3 } from "./lang.js";
-import { Question } from "./question.js";
+import { evalQuestion } from "./eval.js";
+import {
+ courseInfo1,
+ courseInfo2,
+ courseInfo3,
+ dataPolicy,
+ evalNowText,
+ pointsText,
+ timerInfoText,
+} from "./lang.js";
+import { Question, QuestionState } from "./question.js";
/**
* This file is the entry point of the quiz website and populates the DOM.
@@ -17,42 +26,169 @@ import { Question } from "./question.js";
* @param {boolean} debug -- true for enabling extensive debugging features
*/
export function init(quizSrc, debug) {
- // default to English, if the provided language abbreviation is unknown
- if (["en", "de", "es", "it", "fr"].includes(quizSrc.lang) == false)
- quizSrc.lang = "en";
- // if debugging is enabled, show a DEBUG info at the start of the page
- if (debug) document.getElementById("debug").style.display = "block";
- // show the quiz' meta data
- document.getElementById("date").innerHTML = quizSrc.date;
- document.getElementById("title").innerHTML = quizSrc.title;
- document.getElementById("author").innerHTML = quizSrc.author;
- document.getElementById("courseInfo1").innerHTML = courseInfo1[quizSrc.lang];
- let reload =
- '' +
- courseInfo3[quizSrc.lang] +
- "";
- document.getElementById("courseInfo2").innerHTML = courseInfo2[
- quizSrc.lang
- ].replace("*", reload);
-
- // generate questions
- /** @type {Question[]} */
- let questions = [];
- /** @type {HTMLElement} */
- let questionsDiv = document.getElementById("questions");
- let idx = 1; // question index 1, 2, ...
- for (let questionSrc of quizSrc.questions) {
- questionSrc.title = "" + idx + ". " + questionSrc.title;
- let div = genDiv();
- questionsDiv.appendChild(div);
- let question = new Question(div, questionSrc, quizSrc.lang, debug);
- question.showSolution = debug;
- questions.push(question);
- question.populateDom();
- if (debug && questionSrc.error.length == 0) {
- // if the debug version is active, evaluate the question immediately
- if (question.hasCheckButton) question.checkAndRepeatBtn.click();
+ new Quiz(quizSrc, debug);
+}
+
+/**
+ * Question management.
+ */
+export class Quiz {
+ /**
+ *
+ * @param {Object.