Implement most new Quiz modes (see #3) except proper overtime for FSA.
Probably quite buggy
This commit is contained in:
parent
57a52478cc
commit
57846a83c9
|
@ -3,9 +3,9 @@ Aluminium
|
|||
Titanum
|
||||
All the above" "1
|
||||
2"
|
||||
ChooseOne What is depicted on the picture "7 speed double cluth transmission for AWD
|
||||
8 speed double cluth transmission for AWD
|
||||
7 speed double cluth transmission for 2WD
|
||||
ChooseOne What is depicted on the picture "7 speed double clutch transmission for AWD
|
||||
8 speed double clutch transmission for AWD
|
||||
7 speed double clutch transmission for 2WD
|
||||
Automatic transmission with torque conventer" 1 FSCzech https://i.ibb.co/56LM89v/chiron-transmission.jpg
|
||||
Text Calculate the (1) torsional- and (2) bending-nominal stress at the critical cross section for the load case shown below. Answer in N / mm² and round to one decimal place. Given: P = 12kW; n = 980 1/min; F = 500 N; xkrit = 110 mm; 0 ≤ x0 ≤ 120mm "torsional-nominal stress
|
||||
bending-nominal stress" "17.1
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 6.
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
<title>FS Quiz tool</title>
|
||||
|
||||
<script src="util.js"></script>
|
||||
<script src="ssparser.js"></script>
|
||||
<script src="share.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -50,13 +54,13 @@
|
|||
switch (drf_sf.value) {
|
||||
case 'FSG':
|
||||
case 'FSA':
|
||||
drf_ef.innerHTML = 'Minutes per question:<br><input type="number" id="qTimeField" value="5" min="1" max="30" required>'
|
||||
drf_ef.innerHTML = 'Minutes per question:<br><input type="number" id="qTimeField" value="'+(rules[drf_sf.value].questionTimeout)+'" min="1" max="30" required>'
|
||||
break
|
||||
case 'FSCzech':
|
||||
drf_ef.innerHTML = 'Seconds Timeout after handin:<br><input type="number" id="sTOutField" value="30" min="1" max="300" required>'
|
||||
drf_ef.innerHTML = 'Seconds Timeout after handin:<br><input type="number" id="sTOutField" value="'+(rules['FSCzech'].submitTimeout)+'" min="1" max="300" required>'
|
||||
break
|
||||
case 'FSSpain':
|
||||
drf_ef.innerHTML = 'Number of handin tries:<br><input type="number" id="sTriesField" value="3" min="1" max="10" required>'
|
||||
drf_ef.innerHTML = 'Number of handin tries:<br><input type="number" id="sTriesField" value="'+(rules['FSSpain'].submitTries)+'" min="1" max="10" required>'
|
||||
break
|
||||
default:
|
||||
drf_ef.innerHTML = ''
|
||||
|
@ -87,7 +91,7 @@
|
|||
</div>
|
||||
<form>
|
||||
</form>
|
||||
<input type="button" value="Submit" onclick="submitQuiz()" style="background: #008029" id="quizSubmitButton" disabled>
|
||||
<input type="button" value="Submit" onclick="submitQuiz()" style="background: #008029" id="quizSubmitButton">
|
||||
<input type="button" value="Abort" onclick="abortQuiz()">
|
||||
</div>
|
||||
|
||||
|
@ -107,9 +111,6 @@
|
|||
· <span id="meme"></span>
|
||||
</footer>
|
||||
|
||||
<script src="util.js"></script>
|
||||
<script src="ssparser.js"></script>
|
||||
<script src="share.js"></script>
|
||||
<script src="quiz.js"></script>
|
||||
|
||||
</body>
|
||||
|
|
72
web/quiz.js
72
web/quiz.js
|
@ -33,7 +33,14 @@ function updateSubmitButton() {
|
|||
|
||||
var lastQuestion = (state.currentQuestion == (state.questions.length - 1))
|
||||
|
||||
button.value = lastQuestion ? 'Submit Answers' : 'Next Question'
|
||||
button.value = lastQuestion || !getRule('sequential') ? 'Submit Answers' : 'Next Question'
|
||||
|
||||
}
|
||||
|
||||
function resetSubmitButton() {
|
||||
|
||||
updateSubmitButton()
|
||||
document.getElementById('quizSubmitButton').disabled = false
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,16 +50,22 @@ function updateSubmitTimer() {
|
|||
|
||||
if (state.submitTimer > 0) {
|
||||
|
||||
button.value = 'Wait ' + state.submitTimer + 's'
|
||||
timetext = state.submitTimer > 60 ?
|
||||
Math.floor(state.submitTimer/60)+':'+(('0' + (state.submitTimer%60)).slice(-2)) :
|
||||
state.submitTimer + 's'
|
||||
|
||||
button.value = 'Wait ' + timetext
|
||||
button.disabled = true
|
||||
state.submitTimer -= 1
|
||||
|
||||
} else {
|
||||
|
||||
updateSubmitButton()
|
||||
button.disabled = false
|
||||
resetSubmitButton()
|
||||
clearInterval(state.submitInterval)
|
||||
|
||||
if (getRule('sequential') && !getRule('allowQOvertime'))
|
||||
submitQuiz()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -97,6 +110,9 @@ function nextQuestion() {
|
|||
|
||||
showSequentialQuestion()
|
||||
|
||||
if (state.currentQuestion !== null && getRule('questionTimeout'))
|
||||
startSubmitTimer()
|
||||
|
||||
return state.currentQuestion
|
||||
|
||||
}
|
||||
|
@ -165,10 +181,13 @@ function startQuiz() {
|
|||
|
||||
if (state.submitTimer > 0)
|
||||
startSubmitTimer(state.submitTimer)
|
||||
else if (getRule('questionTimeout'))
|
||||
startSubmitTimer()
|
||||
else
|
||||
updateSubmitTimer()
|
||||
resetSubmitButton()
|
||||
|
||||
startTotalTimer()
|
||||
state.running = true
|
||||
|
||||
console.log('Quiz started/resumed')
|
||||
|
||||
|
@ -178,12 +197,15 @@ function reStartQuiz() {
|
|||
|
||||
console.log('Restarting quiz');
|
||||
|
||||
state.currentQuestion = 0
|
||||
state.totalTimer = 0
|
||||
state.submitTimer = 0
|
||||
state.success = false
|
||||
state.currentQuestion = defaultState.currentQuestion
|
||||
state.success = defaultState.success
|
||||
state.submitTry = defaultState.submitTry
|
||||
state.submitTimer = defaultState.submitTimer
|
||||
state.submitInterval = defaultState.submitInterval
|
||||
state.totalTimer = defaultState.totalTimer
|
||||
state.totalInterval = defaultState.totalInterval
|
||||
|
||||
startQuiz()
|
||||
changeView('prescreen')
|
||||
|
||||
}
|
||||
|
||||
|
@ -226,6 +248,8 @@ function endQuiz() {
|
|||
|
||||
console.log('Ending quiz')
|
||||
|
||||
state.running = false
|
||||
|
||||
localStorage.removeItem('state')
|
||||
|
||||
document.querySelector('#quiz form').innerHTML = ''
|
||||
|
@ -299,20 +323,31 @@ function submitQuiz() {
|
|||
|
||||
}
|
||||
|
||||
var text = '' + correct + '/' + state.questions.length + ' questions answered correctly.\n'
|
||||
var text = '' + correct + '/' + state.questions.length + ' questions answered correctly.'
|
||||
|
||||
state.success = (correct == state.questions.length)
|
||||
|
||||
text += state.success ? 'Yay you did it!' : 'Try again!'
|
||||
|
||||
if (!state.success) {
|
||||
state.submitTry++
|
||||
|
||||
if (getRule('submitTries') && state.submitTry < state.submitTries) {
|
||||
alert(text + `\nThis was try ${state.submitTry}/${state.submitTries}\nClick OK to Try Again`)
|
||||
renderQuiz()
|
||||
if (getRule('sequential')) {
|
||||
state.currentQuestion = 0
|
||||
showSequentialQuestion(state.currentQuestion)
|
||||
}
|
||||
|
||||
if (getRule('submitTimeout'))
|
||||
startSubmitTimer()
|
||||
alert(text)
|
||||
} else {
|
||||
document.querySelector('#postscreen h1').innerHTML = (text + '<br>Maybe next time :)')
|
||||
endQuiz()
|
||||
}
|
||||
}
|
||||
|
||||
if (state.success) {
|
||||
document.querySelector('#postscreen h1').innerHTML = `Yay, we're done!<br>Everything is correct :)`
|
||||
document.querySelector('#postscreen h1').innerHTML = (text + '<br>Yay you did it!')
|
||||
endQuiz()
|
||||
}
|
||||
|
||||
|
@ -339,8 +374,6 @@ function abortQuiz() {
|
|||
|
||||
window.onload = async function() {
|
||||
|
||||
console.log('onload')
|
||||
|
||||
var browserWarning = document.getElementById('browserwarning')
|
||||
|
||||
// If arrow functions are supported, it's modern enough :P
|
||||
|
@ -349,7 +382,7 @@ window.onload = async function() {
|
|||
var stateString = localStorage.getItem('state')
|
||||
|
||||
var urlId = idFromUrl()
|
||||
console.log('URL ID:' + urlId)
|
||||
console.log('URL ID:', urlId)
|
||||
|
||||
if (stateString) {
|
||||
|
||||
|
@ -378,7 +411,10 @@ window.onload = async function() {
|
|||
document.getElementById('meme').innerHTML = meme
|
||||
|
||||
if (stateString && !useUrl)
|
||||
if (state.running)
|
||||
startQuiz()
|
||||
else
|
||||
changeView('prescreen')
|
||||
|
||||
if (!stateString && !useUrl)
|
||||
changeView('spreadsheet')
|
||||
|
|
21
web/util.js
21
web/util.js
|
@ -2,19 +2,17 @@ const defaultState = {
|
|||
style: 'FSCzech', // enum of { FSG, FSA, FSN, FSEast, FSCzech, FSSpain, FSSwitzerland }
|
||||
id: null,
|
||||
title: null,
|
||||
running: false,
|
||||
questions: [],
|
||||
currentQuestion: 0,
|
||||
success: false,
|
||||
submitTry: 0,
|
||||
submitTries: 1,
|
||||
submits: 0,
|
||||
submitTime: null,
|
||||
submitTimer: 0,
|
||||
submitInterval: null,
|
||||
totalTimer: 0,
|
||||
totalInterval: null,
|
||||
questionTime: null,
|
||||
questionTimer: 0,
|
||||
questionInterval: null,
|
||||
}
|
||||
|
||||
var state
|
||||
|
@ -38,13 +36,13 @@ function updateTitles() {
|
|||
var rules = {
|
||||
__default__: {
|
||||
sequential: false,
|
||||
submitTries: 1, // NYI
|
||||
submitTimeout: null, // NYI
|
||||
timedQs: false, // NYI
|
||||
allowQOvertime: false // NYI
|
||||
questionTimeout: null,
|
||||
allowQOvertime: false, // Not implemented correctly
|
||||
submitTries: 1,
|
||||
submitTimeout: null
|
||||
},
|
||||
'FSG' : { sequential: true, timedQs: true },
|
||||
'FSA' : { sequential: true, timedQs: true, allowQOvertime: true },
|
||||
'FSG' : { sequential: true, questionTimeout: 5 },
|
||||
'FSA' : { sequential: true, questionTimeout: 5, allowQOvertime: true },
|
||||
'FSN' : { sequential: true },
|
||||
'FSEast' : { sequential: false },
|
||||
'FSCzech' : { sequential: false, submitTries: Infinity, submitTimeout: 30 },
|
||||
|
@ -74,10 +72,11 @@ function applyRuleSettingsFromForm() {
|
|||
switch (state.style) {
|
||||
case 'FSG':
|
||||
case 'FSA':
|
||||
state.questionTime = parseInt(document.getElementById('qTimeField').value)
|
||||
state.submitTime = 60 * parseInt(document.getElementById('qTimeField').value)
|
||||
break
|
||||
case 'FSCzech':
|
||||
state.submitTime = parseInt(document.getElementById('sTOutField').value)
|
||||
state.submitTries = rules[state.style].submitTries
|
||||
break
|
||||
case 'FSSpain':
|
||||
state.submitTries = parseInt(document.getElementById('sTriesField').value)
|
||||
|
|
Loading…
Reference in New Issue