-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinfoo.js
217 lines (167 loc) · 4.66 KB
/
tinfoo.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// FOR TIMER
var min = 9;
var sec = 60;
const appendm = document.getElementById("min");
const appends = document.getElementById("sec")
const i = setInterval(timer, 1000);
function timer() {
sec--;
if (sec <= 9) {
appends.innerHTML = "0" + sec;
}
if (sec > 9) {
appends.innerHTML = sec;
}
if (sec < 0) {
7
min--;
appendm.innerHTML = min;
sec = 60;
appends.innerHTML = sec;
}
if (min <= 9) {
appendm.innerHTML = "0" + min;
}
if ((min == 00) && (sec == 00)) {
clearInterval(i);
console.log("chl gya")
}
}
// FOR END BUTTON
const eb = document.getElementById("eb")
eb.addEventListener("click", (e) => {
if (confirm("Do you really want to exit this test ")) {
window.location.href = "hiremeeclone.html";
}
else {
e.preventDefault()
}
})
// FOR QUESTIONS COUNT
// FOR QUIZ
const quizdata = [
{
question: "Q1. Which one of the following river flows between Vindhyan and Satpura ranges?",
a: "Narmada",
b: "Mahanadi",
c: "Son",
d: " Netravati",
correct: "a",
},
{
question: "Q2. The Central Rice Research Station is situated in?",
a: "Chennai",
b: "Cuttack",
c: "Bangalore",
d: "Quilon",
correct: "b",
},
{
question: "Q3. Patanjali is well known for the compilation of -",
a: "Yoga Sutra",
b: "Panchatantra",
c: "Brahma Sutra",
d: "Ayurveda",
correct: "a",
},
{
question: "Q4. The country that has the highest in Barley Production?",
a: "China",
b: "India",
c: "Russia",
d: "France",
correct: "c",
},
{
question: "Q5. Tsunamis are not caused by",
a: "Hurricanes",
b: "Earthquakes",
c: "Undersea landslides",
d: "Volcanic eruptions",
correct: "a",
}
];
const qstnd = document.getElementById("qstn")
const ak = document.getElementById("ak")
const bk = document.getElementById("bk")
const ck = document.getElementById("ck")
const dk = document.getElementById("dk")
const n = document.getElementById("n")
const p = document.getElementById("p")
const subm = document.getElementById("sub")
const ansel = document.querySelectorAll(".ans")
let cq = 0;
const qwc = document.getElementById("qc")
var qcnt = 0;
loadquiz();
function loadquiz() {
deselectans();
var currentqstn = quizdata[cq];
qstnd.innerText = currentqstn.question;
ak.innerText = currentqstn.a;
bk.innerText = currentqstn.b;
ck.innerText = currentqstn.c;
dk.innerText = currentqstn.d;
}
function deselectans() {
ansel.forEach((ansele) => {
ansele.checked = false;
})
};
const queco = document.getElementById("quc");
function nextq() {
const answ = getselected();
if (answ) {
cq++;
console.log("ek age")
}
else if(quizdata.clicked!=true) {
cq++;
}
if (cq < quizdata.length) {
loadquiz();
queco.innerHTML = cq + 1;
}
}
function prevq(e) {
const answ = getselected();
if (answ) {
cq--;
console.log("ek peeche")
}
// else {
// cq--;
// console.log("single click pe ppeeche aunga")
// }
else if(quizdata.clicked!=true) {
cq--;
}
if (cq < quizdata.length) {
console.log(cq)
loadquiz();
queco.innerHTML = cq + 1;
}
if(quizdata==0){
e.preventDefault()
}
}
function getselected() {
let ans = undefined;
ansel.forEach((ansele) => {
if (ansele.checked) {
console.log("ans is checjeds")
ans = ansele.id;
}
})
return ans;
}
// #submit button
const subb = document.getElementById("sub");
subb.addEventListener("click", (e) => {
if (confirm("Do you really want to submit and EXIT this test")) {
window.location.href = "thankyou.html";
}
else {
e.preventDefault();
}
});