Created
November 16, 2023 01:34
-
-
Save AntiKippi/01e9396bf8287dc5d957b76f6f0f8cf6 to your computer and use it in GitHub Desktop.
TU Wien DWI WS2023 Extract Miniquiz Answers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
for (let content in H5PIntegration.contents) { | |
let jc = JSON.parse(H5PIntegration.contents[content]["jsonContent"]); | |
for (let chapter of jc["chapters"]) { | |
let output = chapter["metadata"]["title"] + "\n"; | |
for (let question of chapter["params"]["content"][0]["content"]["params"]["questions"]) { | |
output += "Question: " + question["params"]["question"]; | |
output += "Answer(s): \n"; | |
if (question["params"]["answers"]) { | |
for (let answer of question["params"]["answers"]) { | |
if (answer["correct"]) { | |
output += answer["text"] + "\n"; | |
} | |
} | |
} | |
else if (question["params"]["correct"]) { | |
output += question["params"]["correct"] + "\n"; | |
} | |
else { | |
console.warn("Could not extract answer") | |
} | |
output += "\n"; | |
} | |
console.log(output); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment