From f74aba0e9cdcc5436db0d178fefa0e0285497595 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 29 Jun 2026 12:37:20 +0100 Subject: [PATCH] feat: implement finish dialog with unanswered question detection and submit functionality --- css/main.css | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 25 +++++++++++++------- js/main.js | 46 ++++++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 9 deletions(-) diff --git a/css/main.css b/css/main.css index fa2d372..e3b5edf 100644 --- a/css/main.css +++ b/css/main.css @@ -563,6 +563,71 @@ img { text-align: center; } +/* Finish dialog styling */ +.finish-header { + display: flex; + justify-content: center; + padding-top: 6vh; + pointer-events: none; +} +.login-risr-box { + display: inline-block; +} +.login-risr-logo { + height: 64px; + width: auto; + user-drag: none; +} +.finish-dialog { + display: inline-block; + background-color: #1b1b1b; + color: #fff; + margin: 3vh auto; + padding: 1.6rem; + border-radius: 8px; + max-width: 520px; + box-shadow: 0 8px 24px rgba(0,0,0,0.6); + text-align: left; +} +.logout-title { + font-size: 1.4rem; + font-weight: 700; + margin-bottom: 0.8rem; +} +.logout-error.info { + background-color: #e3f2fd; + color: #0d47a1; + border: 1px solid rgba(13,71,161,0.15); + padding: 0.8rem; + border-radius: 4px; + margin-bottom: 0.8rem; +} +.logout-text { + margin-bottom: 0.8rem; + color: #ddd; +} +.logout-buttons { + display: flex; + gap: 0.6rem; + justify-content: flex-end; +} +.logout-button { + padding: 0.6rem 1rem; + border-radius: 4px; + border: none; + cursor: pointer; + font-weight: 600; +} +.logout-button.danger { + background: #b71c1c; + color: white; +} +.logout-button.primary { + background: #1976d2; + color: white; +} + + .dialog { /*display: inline-block;*/ display: none; diff --git a/index.html b/index.html index 6a43c25..36d429c 100644 --- a/index.html +++ b/index.html @@ -31,7 +31,7 @@ id="btn-submit-nav" class="submit-button navigation nav-right" > - SUBMIT + FINISH @@ -108,12 +108,21 @@ -
-
-
Ready to logout?
-
- - +
diff --git a/js/main.js b/js/main.js index def024e..0b69039 100644 --- a/js/main.js +++ b/js/main.js @@ -2031,7 +2031,51 @@ $("#btn-local-file-load").click(function(evt) { }); $(".submit-button").click(function(evt) { - interact.submitAnswers(exam_details, db, URLS); + // Show a finish dialog similar to the app style + // Compute unanswered count from the answers DB and show the dialog + interact + .getJsonAnswers(exam_details, db) + .then((answers) => { + // Count unique question ids answered + const qids = new Set(); + answers.forEach((a) => { + if (a && a.qid) qids.add(a.qid.toString()); + }); + + const totalQuestions = + exam_details.number_of_questions || (exam_details.question_order && exam_details.question_order.length) || 0; + const answeredCount = qids.size; + const unanswered = Math.max(0, totalQuestions - answeredCount); + + $("#unanswered-count").text(unanswered); + + // Update messaging for clarity + if (unanswered === 0) { + $(".logout-error.info p.unanswered-line").text("All questions have answers."); + } else if (totalQuestions === 0) { + $(".logout-error.info p.unanswered-line").text(`You have ${unanswered} unanswered question(s)`); + } else { + $(".logout-error.info p.unanswered-line").text(`You have ${unanswered} unanswered question(s)`); + } + + // Show dialog overlay + $(".logout-background").fadeIn(150); + + // Wire dialog buttons + $("#button-logout").off("click").on("click", function() { + interact.submitAnswers(exam_details, db, URLS); + $(".logout-background").fadeOut(150); + }); + + $("#button-continue").off("click").on("click", function() { + $(".logout-background").fadeOut(150); + }); + }) + .catch((e) => { + console.debug("Error computing unanswered count", e); + $("#unanswered-count").text("?"); + $(".logout-background").fadeIn(150); + }); }); $("#btn-review").click(function(evt) {