-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion.html
More file actions
100 lines (89 loc) · 2.96 KB
/
question.html
File metadata and controls
100 lines (89 loc) · 2.96 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Fragen</title>
<link rel="stylesheet" href="question.css"/>
</head>
<body>
<div class="switchContainer">1 / 15</div>
<div class="question-container">
<div id="question"></div>
<div id="answers">
<div>
<img class="answer-image" />
<img class="answer-image" />
</div>
<div>
<img class="answer-image" />
<img class="answer-image" />
</div>
</div>
</div>
<div class="button-container">
<button class="switch" onclick="next()">weiter</button>
</div>
<div id="popup">
<p>Bist du dir ganz sicher, dass das die richtige Antwort ist?</p>
<button onclick="confirmAnswer(true)">Ja</button>
<button onclick="confirmAnswer(false)">Nein</button>
</div>
<script>
var answerImageElements = document.getElementsByClassName("answer-image");
var nextButton = document.querySelector("div.button-container button");
nextButton.disabled = true;
const correctAnswerNumber = 2;
//question and answers
var questionText = "Wie viele Treppen gibt es in Hogwarts?";
var answerImages = [
"images/t_142.png",
"images/t_165.png",
"images/t_277.png",
"images/t_587.png"
];
function displayBorders() {
for (var i = 0; i < answerImageElements.length; i++) {
answerImageElements[i].style.padding = "2px";
answerImageElements[i].disabled = true;
answerImageElements[i].onclick = () => {
};
if (i === correctAnswerNumber) {
answerImageElements[i].style.border = "3px solid #10da10"
} else {
answerImageElements[i].style.border = "3px solid #d33e3e"
}
}
nextButton.disabled = false;
}
function next() {
document.location.href = "question2.html";
}
//question text
var questionElement = document.getElementById("question");
questionElement.innerText = questionText;
//answer images
for (var i = 0; i < answerImageElements.length; i++) {
answerImageElements[i].src = answerImages[i];
answerImageElements[i].style.padding = "5px";
answerImageElements[i].style.border = "none"
answerImageElements[i].onclick = () => {
showConfirmationPopup();
};
answerImageElements[i].disabled = false;
}
// show confirmation popup
function showConfirmationPopup() {
var popupElement = document.getElementById("popup");
popupElement.style.display = "block";
}
// confirm answer
function confirmAnswer(shouldProceed) {
var popupElement = document.getElementById("popup");
popupElement.style.display = "none";
if (shouldProceed) {
displayBorders();
}
}
</script>
</body>
</html>