-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetAnswers.js
More file actions
36 lines (30 loc) · 1.09 KB
/
getAnswers.js
File metadata and controls
36 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let json = H5PIntegration.contents;
let interactions = JSON.parse(json[Object.keys(json)[0]].jsonContent).interactiveVideo.assets.interactions;
let html = "";
html += `<h1>Answers</h1>`
for (let i = 0; i < interactions.length; i++) {
interaction = interactions[i]
q_type=interaction.libraryTitle
params=interaction.action.params
html += `<h2>Question ${i + 1}</h2>`
if (q_type=="Single Choice Set") {
answer=params.choices[0].answers[0]
html += `<p>${answer}</p>`
console.log(answer)
} else if (q_type=="Multiple Choice") {
answers = params.answers
for (let i = 0; i < answers.length; i++) {
answer = answers[i]
if (answer.correct==true)
html += `<p>${answer.text}</p>`
console.log(answer.text)
}
} else if (q_type=="True/False Question") {
console.log(params.correct)
html += `<p>${params.correct}</p>`
} else
console.log("wait")
console.log("\n")
}
const win = window.open('', 'answers', 'width=400, height=600');
win.document.write(html);