-
Notifications
You must be signed in to change notification settings - Fork 1
/
js_lec_7.js
198 lines (159 loc) · 4.51 KB
/
js_lec_7.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// cloneNode
// appendChild
// createTextNode
// removeChild
// replaceChild
var quiz1 = {
question: "What is the square root of 100?",
answers: [
{answer: "1", url:""},
{answer: "12", url:""},
{answer: "10", url:""},
{answer: "7", url:"IMAGE_URL"}
],
correctAnswer: 2,
help: ["YOUTUBE_URL", "TITLE"]
};
var quiz2 = {
question: "What is the sum of 1 and 5?",
answers: [
{answer: "2", url:""},
{answer: "800", url:""},
{answer: "199", url:""},
{answer: "600", url:"IMAGE_URL"}
],
correctAnswer: 0,
help: ["YOUTUBE_URL", "TITLE"]
};
var quiz3 = {
question: "What is the sum of 8 and 5?",
answers: [
{answer: "3", url:""},
{answer: "900", url:""},
{answer: "299", url:""},
{answer: "500", url:"IMAGE_URL"}
],
correctAnswer: 0,
help: ["YOUTUBE_URL", "TITLE"]
};
var quiz4 = {
question: "What is the result of 8 * 5",
answers: [
{answer: "40", url:""},
{answer: "50", url:""},
{answer: "60", url:""},
{answer: "70", url:"IMAGE_URL"}
],
correctAnswer: 0,
help: ["YOUTUBE_URL", "TITLE"]
};
var quiz5 = {
question: "The multiplicative inverse of 4 is",
answers: [
{answer: "-4", url:""},
{answer: "-1/4", url:""},
{answer: "1/4", url:""},
{answer: "1", url:"IMAGE_URL"}
],
correctAnswer: 0,
help: ["YOUTUBE_URL", "TITLE"]
};
var quiz6 = {
question: "{ 1, 2, 3, 4, 5, 6 ...................} is called as the set of .....",
answers: [
{answer: "Prime numbers", url:""},
{answer: "Whole numbers", url:""},
{answer: "Naturat numbers", url:""},
{answer: "Irrational numbers", url:"IMAGE_URL"}
],
correctAnswer: 0,
help: ["YOUTUBE_URL", "TITLE"]
};
var quiz7 = {
question: "A ............... is system of non-empty set on which a binary operation defined.",
answers: [
{answer: "Groupiod", url:""},
{answer: "Group", url:""},
{answer: "Semi-group", url:""},
{answer: "N.O.T", url:"IMAGE_URL"}
],
correctAnswer: 0,
help: ["YOUTUBE_URL", "TITLE"]
};
// Set first question data
document.getElementById("question").innerHTML = quiz1.question;
document.getElementById("a1").innerHTML = quiz1.answers[0].answer;
document.getElementById("a2").innerHTML = quiz1.answers[1].answer;
document.getElementById("a3").innerHTML = quiz1.answers[2].answer;
document.getElementById("a4").innerHTML = quiz1.answers[3].answer;
var question_container = document.getElementById("quetsion_container");
var body = document.getElementById("body");
var questions = new Array(quiz1, quiz2, quiz3, quiz4, quiz5, quiz6, quiz7);
for(var j=1; j<questions.length; j++){
// clone the node
var duplicateQuestion = question_container.cloneNode(true);
for(var k=0; k<duplicateQuestion.childNodes.length; k++){
if (duplicateQuestion.childNodes[k].id != 'undefined' &&
duplicateQuestion.childNodes[k].id == "question") {
duplicateQuestion.childNodes[k].innerHTML = questions[j].question;
}
else if(duplicateQuestion.childNodes[k].id != 'undefined' &&
duplicateQuestion.childNodes[k].id == "a1"){
duplicateQuestion.childNodes[k].innerHTML = questions[j].answers[0].answer;
} else if(duplicateQuestion.childNodes[k].id != 'undefined' &&
duplicateQuestion.childNodes[k].id == "a2"){
duplicateQuestion.childNodes[k].innerHTML = questions[j].answers[1].answer;
} else if(duplicateQuestion.childNodes[k].id != 'undefined' &&
duplicateQuestion.childNodes[k].id == "a3"){
duplicateQuestion.childNodes[k].innerHTML = questions[j].answers[2].answer;
} else if(duplicateQuestion.childNodes[k].id != 'undefined' &&
duplicateQuestion.childNodes[k].id == "a4"){
duplicateQuestion.childNodes[k].innerHTML = questions[j].answers[3].answer;
}
}
// add child nodes
body.appendChild(duplicateQuestion);
}
// // var answer1 = document.getElementById("answer1");
// var body = document.getElementById("body");
// body.appendChild(duplicateQuestion);
// document.write(quiz.question);
// if (quiz.answers[3].url == "") {
// // hide the image tag
// } else {
// // show the image tag
// };
// if (quiz.answers[0].url == "") {
// // hide the image tag
// } else {
// // show the image tag
// };
// if (quiz.answers[1].url == "") {
// // hide the image tag
// } else {
// // show the image tag
// };
// if (quiz.answers[2].url == "") {
// // hide the image tag
// } else {
// // show the image tag
// };
/*
objectName.methodName();
document.write();
*/
// method: function(){
// code
// }
// var car = {
// buildDate: 2015,
// color: "blue",
// model: 2017,
// engine: "1300cc",
// abc: ["item1", "item2"],
// owner: {
// name: "Jhon",
// age: 26,
// education: "Masters"
// }
// };