Fix total time counting for timed questions and lots of cleanup

This commit is contained in:
Oskar Winkels 2021-01-23 19:47:19 +01:00
parent 6cdf7dbb4d
commit 314c9e8c67
2 changed files with 25 additions and 18 deletions

View File

@ -2,7 +2,7 @@ ChooseAny Which Materials can be used to fabricate the brake pedal? "Steel
Aluminium
Titanum
All the above" "1
2" 3
2" 0.3
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

1 ChooseAny Which Materials can be used to fabricate the brake pedal? Steel Aluminium Titanum All the above 1 2 3 0.3
2 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 This gearbox is from the 2017 Bugatti Chiron FSCzech https://i.ibb.co/56LM89v/chiron-transmission.jpg 5 5
3 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 18.2 17.1 https://i.ibb.co/1r3yqY7/2b.png https://i.ibb.co/tYTdw86/2a.png 7 7
4
5
6
7
8

View File

@ -16,7 +16,7 @@ function updateFSATeamCountTroll() {
var time = state.questions[state.currentQuestion].time || state.submitTime
var timeratio = 1 - (state.submitTimer / time)
var slowAnswerChance = Math.random()*2*Math.pow(timeratio, 2)
var quickAnswerChance = (Math.random()+Math.sqrt(69/time))/3
var quickAnswerChance = (Math.random()+Math.sqrt(69/time))/4
var chance = Math.round(slowAnswerChance + quickAnswerChance)
var magnitude = Math.round((Math.random()/2+timeratio)*6)
var nt = chance * magnitude
@ -31,9 +31,10 @@ function updateTotalTimer() {
var timerEls = document.querySelectorAll('.totaltimer')
for (timerEl of timerEls)
timerEl.innerHTML = formatTime(state.totalTimer);
timerEl.innerHTML = 'Total time: ' + formatTime(state.totalTimer);
state.totalTimer++
if (!state.waitNextQuestion)
state.totalTimer++
localStorage.setItem('state', JSON.stringify(state))
@ -123,7 +124,7 @@ function startSubmitTimer(time) {
}
function showSequentialQuestion(n) {
function updateSequentialQuestion() {
var questions = document.querySelectorAll('.question')
for (q of questions)
@ -131,8 +132,8 @@ function showSequentialQuestion(n) {
updateSubmitInfo()
if (n !== null) {
var q = document.querySelector('#quiz form #question' + n)
if (state.currentQuestion !== null && !state.waitNextQuestion) {
var q = document.querySelector('#quiz form #question' + state.currentQuestion)
q.style.display = 'block'
}
@ -143,10 +144,17 @@ function nextQuestion() {
// Save time taken
state.questions[state.currentQuestion].timeTaken = state.totalTimer - state.questionStartTotalTimer
if (getRule('questionTimeout') && (state.submitTimer > 0)
&& (state.currentQuestion != (state.questions.length-1))) {
// Last question
if (state.currentQuestion == (state.questions.length - 1)) {
state.currentQuestion = null
updateSequentialQuestion()
return
}
// Waiting for next question
if (getRule('questionTimeout') && (state.submitTimer > 0)) {
state.waitNextQuestion = true;
showSequentialQuestion(null) // hide question
updateSequentialQuestion() // hide question
return
}
@ -162,12 +170,9 @@ function nextQuestion() {
state.currentQuestion++
if (state.currentQuestion == state.questions.length)
state.currentQuestion = null
updateSequentialQuestion()
showSequentialQuestion(state.currentQuestion)
if (state.currentQuestion !== null && getRule('questionTimeout'))
if (getRule('questionTimeout'))
startSubmitTimer()
}
@ -232,7 +237,7 @@ function startQuiz() {
changeView('quiz')
if (getRule('sequential'))
showSequentialQuestion(state.currentQuestion)
updateSequentialQuestion()
if (state.submitTimer > 0)
startSubmitTimer(state.submitTimer)
@ -373,13 +378,15 @@ function showQuizResults() {
qinfo += ('. Time taken: ' + formatTime(q.timeTaken))
if (value.correct && getRule('allowQOvertime'))
qinfo += (', Bonus points ' + ((q.timeTaken <= q.time) ? 'received' : 'lost'))
else if (q.timeTaken == q.time)
else if (q.timeTaken >= (q.time - 1) && !getRule('allowQOvertime'))
qinfo += ', Time ran out'
}
el.querySelector('h3').innerHTML += ` &nbsp; <span class="meta">${qinfo}</span>`
}
document.querySelector('#fsateamcounttroll').innerHTML = ''
document.querySelector('#submitinfo').innerHTML = ''
document.querySelector('#quizSubmitButton').value = 'Back'
}
@ -468,7 +475,7 @@ function submitQuiz() {
renderQuiz()
if (getRule('sequential')) {
state.currentQuestion = 0
showSequentialQuestion(state.currentQuestion)
updateSequentialQuestion()
}
if (getRule('submitTimeout'))