Rerender Quiz form on Submit
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								src/main.js
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								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)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -31,7 +31,7 @@ a {
 | 
			
		||||
 | 
			
		||||
img {
 | 
			
		||||
	display: block;
 | 
			
		||||
	margin: auto;
 | 
			
		||||
	margin: 16px auto;
 | 
			
		||||
	max-width: 90%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user