From ee41e015194104360ed198f5b6406506e194cbd8 Mon Sep 17 00:00:00 2001 From: Oskar Date: Wed, 15 Jan 2020 15:26:20 +0100 Subject: [PATCH] Rerender Quiz form on Submit --- README.md | 2 -- src/main.js | 22 ++++++++++++++++------ src/style.css | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 95a3d79..68eee4c 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ Tool for fs teams to train for registration qualification quizzes - Global timer for quiz - Penalties/Bonuses - Show answers and correctness -- Clear answers after submission -- Random choice order after submission ## Long term plans diff --git a/src/main.js b/src/main.js index 897d566..c97e9d8 100644 --- a/src/main.js +++ b/src/main.js @@ -178,15 +178,12 @@ function parseSpreadsheet() { } -function startQuiz() { - - state.success = false - - console.log('Starting/Resuming quiz. State:') - console.log(state) +function renderQuiz() { var quizForm = document.querySelector('#quiz form') + quizForm.innerHTML = '' + for (const [i, q] of state.questions.entries()) { var html = '' @@ -219,6 +216,18 @@ function startQuiz() { } +} + + +function startQuiz() { + + state.success = false + + console.log('Starting/Resuming quiz. State:') + console.log(state) + + renderQuiz() + changeView('quiz') if (state.timer > 0) @@ -325,6 +334,7 @@ function submitQuiz() { text += state.success ? 'Yay you did it!' : 'Try again!' if (!state.success) { + renderQuiz() startTimer() alert(text) } diff --git a/src/style.css b/src/style.css index 0a35529..2cc41ac 100644 --- a/src/style.css +++ b/src/style.css @@ -31,7 +31,7 @@ a { img { display: block; - margin: auto; + margin: 16px auto; max-width: 90%; }