display questions

master
Bel LaPointe 2023-04-07 13:13:40 -06:00
parent fe6b87563f
commit 1816500617
2 changed files with 48 additions and 25 deletions

View File

@ -10,8 +10,8 @@
split(""). split("").
reverse(). reverse().
join("") join("")
).toString(36); ).toString(36)
console.log("session", session); console.log("session", session)
</script> </script>
</header> </header>
<body> <body>
@ -20,6 +20,7 @@
<input type="text" name="idq" readonly=true value="" style="display: none;"> <input type="text" name="idq" readonly=true value="" style="display: none;">
<div name="question"></div> <div name="question"></div>
<div name="clues"></div> <div name="clues"></div>
<div name="solution"></div>
<input type="button" value="clue"> <input type="button" value="clue">
<input type="text" name="answer"> <input type="text" name="answer">
<input type="submit" value="submit"> <input type="submit" value="submit">
@ -28,36 +29,45 @@
</body> </body>
<footer> <footer>
<script> <script>
let knowledgebase = {{ASSIGNMENTS_JSON}}; let knowledgebase = {{ASSIGNMENTS_JSON}}
knowledgebase = Object. knowledgebase = Object.
keys(knowledgebase). keys(knowledgebase).
map((key) => [ map((key) => [
[key, knowledgebase[key]] [key, knowledgebase[key]]
]); ])
function nextQuestion(form) { function nextQuestion(form) {
form.children.answer.value = ""; form.children.answer.value = ""
let todo = knowledgebase.pop(); let todo = knowledgebase.pop()
if (!todo) { if (!todo) {
todo = [0]; todo = [0]
} }
todo = todo[0]; todo = todo[0]
if (! todo) { if (! todo) {
todo = ["", {Q: "ALL DONE"}]; todo = ["", {Q: "ALL DONE"}]
} }
form.children.idq.value = todo[0]; form.children.idq.value = todo[0]
form.children.question.innerHTML = `<h3>${todo[1].Q}</h3>`
console.log(todo[1]);
form.children.question.innerHTML = `<h3>${todo[1].Q}</h3>`;
let clues = "" let clues = ""
for (var i of todo[1].Clues) { for (var i in todo[1].Clues) {
clues += `<br>${i}` clues += `<details><summary>clue #${i}</summary>${todo[1].Clues[i]}</details>`
} }
form.children.clues.innerHTML = clues; form.children.clues.innerHTML = clues
let solution = ""
for (var i in todo[1].Solution) {
solution += `<br>${todo[1].Solution[i]}`
}
if (solution) {
solution = `<details><summary>solution</summary>${solution}</details>`
}
form.children.solution.innerHTML = solution
} }
nextQuestion(document.getElementById("flash")); nextQuestion(document.getElementById("flash"))
</script> </script>
</footer> </footer>
</html> </html>

31
testdata/sample.yaml vendored
View File

@ -1,27 +1,40 @@
knowledge: knowledge:
questions: questions:
uuid1: uuid10:
q: whats a fieldset q: whats a fieldset
clues: clues:
- clue1 of 2 - clue1 of 2
- clue2 of 2 - clue2 of 2
solution:
- solution A
- solution B
tags:
- ops
- data-platform
uuid11:
q: whats a responseset
clues:
- clue1 of 2
- clue2 of 2
solution:
- solution A
- solution B
tags: tags:
- ops - ops
- data-platform - data-platform
answers: answers:
uuid2: uuid20:
q: uuid1 q: uuid10
a: a schema a: a schema
ts: 123 ts: 123
author: breel author: breel
uuid0: uuid21:
q: uuid1 q: uuid10
a: not a schema a: not a schema
ts: 122 ts: 122
author: breel author: breel
users: users:
breel: breel:
history: tags: {assignments: [ops]}
uuid1: cadence: 5s
- {a: uuid0, pass: true} resolution: 1
- {a: uuid2, pass: true}