This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
forked from phoenix-jss/Physics-quiz
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathindex.js
78 lines (64 loc) · 2.1 KB
/
index.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
var quiz = {
questions : ["Are u fucked up in life?","No. of days in a week?","No of mounths in a year?","Captian of indian cricket team?","Who played guddu in Mirzapur?"],
opt1 : ["Yes","2","8","MS Dhoni"],
opt2 : ["No","7","10","V Kholi"],
opt3 : ["Not Sure","5","12","Rohit Sharma"],
opt4 : ["Hapily fucked up","6","11","S Raina"],
answer : ["Hapily fucked up","7","12","V Kholi","Ali faizal"]
};
var i = 0;
var score = 0;
var ans;
var options = document.forms[0];
document.getElementById("score").innerHTML = 0;
document.getElementById("question").innerHTML = quiz.questions[i];
document.getElementById("op1").innerHTML = quiz.opt1[i];
document.getElementById("op2").innerHTML = quiz.opt2[i];
document.getElementById("op3").innerHTML = quiz.opt3[i];
document.getElementById("op4").innerHTML = quiz.opt4[i];
function changeContent(){
document.getElementById("score").innerHTML = score;
document.getElementById("question").innerHTML = quiz.questions[i];
document.getElementById("op1").innerHTML = quiz.opt1[i];
document.getElementById("op2").innerHTML = quiz.opt2[i];
document.getElementById("op3").innerHTML = quiz.opt3[i];
document.getElementById("op4").innerHTML = quiz.opt4[i];
}
function next(){
i++;
jQuery("input:radio").attr('disabled',false);
jQuery('input:radio').prop('checked', false);
changeContent();
}
function checkAnswer(event){
if(quiz.opt1[i]==quiz.answer[i]){
ans = 1;
}
else if(quiz.opt2[i]==quiz.answer[i]){
ans = 2;
}
else if(quiz.opt3[i]==quiz.answer[i]){
ans = 3;
}
else if(quiz.opt4[i]==quiz.answer[i]){
ans = 4;
}
var whichinput = document.getElementsByName("option");
var len = whichinput.length;
var checkedinputno;
var checkedinput;
for(var b=0; b<len ; b++){
if(whichinput[b].checked){
checkedinputno = b;
checkedinput = whichinput[b];
}
}
if((checkedinputno+1) == ans){
scoreUpdate();
}
jQuery("input:radio").attr('disabled',true);
}
function scoreUpdate(){
score++;
document.getElementById("score").innerHTML = score;
}