Add configurable values to rule system
This commit is contained in:
parent
71095cd5b8
commit
9e63f6986c
|
@ -33,7 +33,7 @@
|
||||||
Title:<br>
|
Title:<br>
|
||||||
<input type="text" id="titleField" required>
|
<input type="text" id="titleField" required>
|
||||||
Style:<br>
|
Style:<br>
|
||||||
<select type="select" id="styleField" required>
|
<select type="select" id="styleField" onchange="updateDynamicRuleFields()" required>
|
||||||
<option value="FSG" >FSG </option>
|
<option value="FSG" >FSG </option>
|
||||||
<option value="FSA" >FSA </option>
|
<option value="FSA" >FSA </option>
|
||||||
<option value="FSN" >FSN </option>
|
<option value="FSN" >FSN </option>
|
||||||
|
@ -42,6 +42,28 @@
|
||||||
<option value="FSSpain" >FSSpain </option>
|
<option value="FSSpain" >FSSpain </option>
|
||||||
<option value="FSSwitzerland">FSSwitzerland </option>
|
<option value="FSSwitzerland">FSSwitzerland </option>
|
||||||
</select>
|
</select>
|
||||||
|
<div id="extraFields"></div>
|
||||||
|
<script>
|
||||||
|
var drf_sf = document.getElementById('styleField')
|
||||||
|
var drf_ef = document.getElementById('extraFields')
|
||||||
|
function updateDynamicRuleFields() {
|
||||||
|
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>'
|
||||||
|
break
|
||||||
|
case 'FSCzech':
|
||||||
|
drf_ef.innerHTML = 'Seconds Timeout after handin:<br><input type="number" id="sTOutField" value="30" 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>'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
drf_ef.innerHTML = ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateDynamicRuleFields()
|
||||||
|
</script>
|
||||||
Paste your questions from a spreadsheet here:<br>
|
Paste your questions from a spreadsheet here:<br>
|
||||||
<textarea rows="16" id="questions" required></textarea>
|
<textarea rows="16" id="questions" required></textarea>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -134,7 +134,7 @@ function reStartQuiz() {
|
||||||
|
|
||||||
state.totalTimer = 0
|
state.totalTimer = 0
|
||||||
state.submitTimer = 0
|
state.submitTimer = 0
|
||||||
state.success = 0
|
state.success = false
|
||||||
|
|
||||||
startQuiz()
|
startQuiz()
|
||||||
|
|
||||||
|
@ -153,6 +153,9 @@ function createQuiz(e) {
|
||||||
state.title = document.getElementById('titleField').value
|
state.title = document.getElementById('titleField').value
|
||||||
state.style = document.getElementById('styleField').value
|
state.style = document.getElementById('styleField').value
|
||||||
|
|
||||||
|
// After state.style is set
|
||||||
|
applyRuleSettingsFromForm()
|
||||||
|
|
||||||
if (parseSpreadsheet().success == false) {
|
if (parseSpreadsheet().success == false) {
|
||||||
alert('Quiz creation failed.')
|
alert('Quiz creation failed.')
|
||||||
return
|
return
|
||||||
|
@ -164,7 +167,8 @@ function createQuiz(e) {
|
||||||
|
|
||||||
changeView('prescreen')
|
changeView('prescreen')
|
||||||
|
|
||||||
console.log('Quiz created')
|
console.log('Quiz created:')
|
||||||
|
console.log(state)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ input[type="button"]:disabled, input[type="submit"]:disabled {
|
||||||
background: #888 !important;
|
background: #888 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea, input[type="text"], select {
|
input[type="text"], input[type="number"], textarea, select {
|
||||||
background: #ddd;
|
background: #ddd;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
padding: .5em;
|
padding: .5em;
|
||||||
|
|
23
web/util.js
23
web/util.js
|
@ -3,7 +3,9 @@ const defaultState = {
|
||||||
id: null,
|
id: null,
|
||||||
title: null,
|
title: null,
|
||||||
questions: [],
|
questions: [],
|
||||||
success: 0,
|
success: false,
|
||||||
|
submitTries: 1,
|
||||||
|
submits: 0,
|
||||||
submitTime: null,
|
submitTime: null,
|
||||||
submitTimer: 0,
|
submitTimer: 0,
|
||||||
submitInterval: null,
|
submitInterval: null,
|
||||||
|
@ -32,7 +34,7 @@ function updateTitles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const rules = {
|
var rules = {
|
||||||
__default__: {
|
__default__: {
|
||||||
sequential: false,
|
sequential: false,
|
||||||
submitTries: 1,
|
submitTries: 1,
|
||||||
|
@ -66,6 +68,23 @@ function getRule(name) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function applyRuleSettingsFromForm() {
|
||||||
|
|
||||||
|
switch (state.style) {
|
||||||
|
case 'FSG':
|
||||||
|
case 'FSA':
|
||||||
|
state.questionTime = parseInt(document.getElementById('qTimeField').value)
|
||||||
|
break
|
||||||
|
case 'FSCzech':
|
||||||
|
state.submitTime = parseInt(document.getElementById('sTOutField').value)
|
||||||
|
break
|
||||||
|
case 'FSSpain':
|
||||||
|
state.submitTries = parseInt(document.getElementById('sTriesField').value)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function changeView(view) {
|
function changeView(view) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue