Rerender Quiz form on Submit
This commit is contained in:
parent
29a5e2aa8c
commit
ee41e01519
|
@ -8,8 +8,6 @@ Tool for fs teams to train for registration qualification quizzes
|
||||||
- Global timer for quiz
|
- Global timer for quiz
|
||||||
- Penalties/Bonuses
|
- Penalties/Bonuses
|
||||||
- Show answers and correctness
|
- Show answers and correctness
|
||||||
- Clear answers after submission
|
|
||||||
- Random choice order after submission
|
|
||||||
|
|
||||||
## Long term plans
|
## Long term plans
|
||||||
|
|
||||||
|
|
22
src/main.js
22
src/main.js
|
@ -178,15 +178,12 @@ function parseSpreadsheet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function startQuiz() {
|
function renderQuiz() {
|
||||||
|
|
||||||
state.success = false
|
|
||||||
|
|
||||||
console.log('Starting/Resuming quiz. State:')
|
|
||||||
console.log(state)
|
|
||||||
|
|
||||||
var quizForm = document.querySelector('#quiz form')
|
var quizForm = document.querySelector('#quiz form')
|
||||||
|
|
||||||
|
quizForm.innerHTML = ''
|
||||||
|
|
||||||
for (const [i, q] of state.questions.entries()) {
|
for (const [i, q] of state.questions.entries()) {
|
||||||
|
|
||||||
var html = ''
|
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')
|
changeView('quiz')
|
||||||
|
|
||||||
if (state.timer > 0)
|
if (state.timer > 0)
|
||||||
|
@ -325,6 +334,7 @@ function submitQuiz() {
|
||||||
text += state.success ? 'Yay you did it!' : 'Try again!'
|
text += state.success ? 'Yay you did it!' : 'Try again!'
|
||||||
|
|
||||||
if (!state.success) {
|
if (!state.success) {
|
||||||
|
renderQuiz()
|
||||||
startTimer()
|
startTimer()
|
||||||
alert(text)
|
alert(text)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ a {
|
||||||
|
|
||||||
img {
|
img {
|
||||||
display: block;
|
display: block;
|
||||||
margin: auto;
|
margin: 16px auto;
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue