-
Notifications
You must be signed in to change notification settings - Fork 0
/
results_view.js
144 lines (121 loc) · 6.65 KB
/
results_view.js
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
window.onload = function () {
document.getElementById("oneForward").textContent = 1;
document.getElementById("twoForward").textContent = 2;
document.getElementById("threeForward").textContent = 3;
document.getElementById("currentQuestion").textContent = "1: " + questions[0];
document.getElementById("answerA").textContent = answers[0][0];
document.getElementById("answerB").textContent = answers[0][1];
document.getElementById("answerC").textContent = answers[0][2];
document.getElementById("answerD").textContent = answers[0][3];
document.getElementById("oneBack").style.visibility = 'hidden';
document.getElementById("twoBack").style.visibility = 'hidden';
document.getElementById("threeBack").style.visibility = 'hidden';
document.getElementById("oneBack").style.visibility = 'hidden';
document.getElementById("twoBack").style.visibility = 'hidden';
document.getElementById("threeBack").style.visibility = 'hidden';
}
var answers = [["1", "2", "3", "4"], ["2", "3", "4", "5"], ["3", "4", "5", "9"], ["4", "8", "6", "7"], ["5", "10", "11", "520"], ["1", "2", "3", "4"], ["1", "2", "3", "4"], ["1", "2", "3", "4"], ["1", "2", "3", "4"], ["1", "2", "3", "4"], ["1", "2", "3", "4"], ["1", "2", "3", "4"]];
var questions = ["wut is 1 + 1?????!!!! ", "What is 2 + 2?", "what is 3 + 3?", "what is 4 + 4?", "what is 5 + 5?", "what is 6 + 6?", "what is 1 + 1? ", "What is 2 + 2?", "what is 3 + 3?", "what is 4 + 4?", "what is 5 + 5?", "what is 6 + 6?"];
var currentQuestionIndex = 0;
function previousQuestion(){
var currentQuestion = document.getElementById("currentQuestion");
if (currentQuestionIndex > 0) {
currentQuestionIndex = currentQuestionIndex - 1;
currentQuestion.innerHTML ="Question " + (currentQuestionIndex+1);
document.getElementById("answerA").textContent = answers[currentQuestionIndex][0];
document.getElementById("answerB").textContent = answers[currentQuestionIndex][1];
document.getElementById("answerC").textContent = answers[currentQuestionIndex][2];
document.getElementById("answerD").textContent = answers[currentQuestionIndex][3];
}
}
function nextQuestion(buttonOffset, direction) {
var currentQuestion = document.getElementById("currentQuestion");
//update question buttons
console.log(buttonOffset);
if (direction) {
//clearInterval(timeInterval)
currentQuestionIndex = currentQuestionIndex + buttonOffset;
currentQuestion.innerHTML = currentQuestionIndex + 1 + ": " + questions[currentQuestionIndex + 1];
if (currentQuestionIndex + 1 - 3 > 0) {
document.getElementById("threeBack").style.color = "black";
document.getElementById("threeBack").textContent = currentQuestionIndex + 1 - 3;
document.getElementById("threeBack").style.visibility = 'visible';
}
else {
document.getElementById("threeBack").style.visibility = 'hidden';
}
if (currentQuestionIndex + 1 - 2 > 0) {
document.getElementById("twoBack").style.color = "black";
document.getElementById("twoBack").textContent = currentQuestionIndex + 1 - 2;
document.getElementById("twoBack").style.visibility = 'visible';
}
else {
document.getElementById("twoBack").style.visibility = 'hidden';
}
if (currentQuestionIndex + 1 - 1 > 0) {
document.getElementById("oneBack").style.color = "black";
document.getElementById("oneBack").textContent = currentQuestionIndex + 1 - 1;
document.getElementById("oneBack").style.visibility = 'visible';
}
else {
document.getElementById("oneBack").style.visibility = 'hidden';
}
document.getElementById("oneForward").textContent = currentQuestionIndex + 2;
document.getElementById("twoForward").textContent = currentQuestionIndex + 3;
document.getElementById("threeForward").textContent = currentQuestionIndex + 4;
}
else {
//clearInterval(timeInterval)
currentQuestionIndex = currentQuestionIndex + buttonOffset;
currentQuestion.innerHTML = currentQuestionIndex + 1 + questions[currentQuestionIndex + 1];
if(currentQuestionIndex - 2 > 0)
{
document.getElementById("threeBack").textContent = currentQuestionIndex - 2;
document.getElementById("threeBack").hidden = false;
document.getElementById("threeBack").style.visibility = 'visible';
}
else
{
document.getElementById("threeBack").style.visibility = 'hidden';
}
if(currentQuestionIndex - 1 > 0)
{
document.getElementById("twoBack").textContent = currentQuestionIndex - 1;
document.getElementById("twoBack").style.color = "black";
document.getElementById("twoBack").style.visibility = 'visible';
}
else
{
document.getElementById("twoBack").style.visibility = 'hidden';
}
if(currentQuestionIndex > 0)
{
document.getElementById("oneBack").textContent = currentQuestionIndex;
document.getElementById("oneBack").style.visibility = 'visible';
document.getElementById("oneBack").style.color = "black";
}
else
{
document.getElementById("oneBack").style.visibility = 'hidden';
}
document.getElementById("oneForward").textContent = currentQuestionIndex + 2;
document.getElementById("twoForward").textContent = currentQuestionIndex + 3;
document.getElementById("threeForward").textContent = currentQuestionIndex + 4;
}
//update ansers for current question:
document.getElementById("answerA").textContent = answers[currentQuestionIndex][0];
document.getElementById("answerB").textContent = answers[currentQuestionIndex][1];
document.getElementById("answerC").textContent = answers[currentQuestionIndex][2];
document.getElementById("answerD").textContent = answers[currentQuestionIndex][3];
document.getElementById("currentQuestionArea").textContent = questions[currentQuestionIndex];
//put a green box around the answer the user selected
// document.getElementById("ansA").style.outline = "";
// document.getElementById("ansB").style.outline = "";
// document.getElementById("ansC").style.outline = "";
// document.getElementById("ansD").style.outline = "";
// if (usersSelectedAnswers[currentQuestionIndex]) {
// var id = "ans" + usersSelectedAnswers[currentQuestionIndex];
// document.getElementById(id).style.outline = "2px solid green";
// }
//startTimer(time_length)
}