-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion.js
110 lines (104 loc) · 3.29 KB
/
question.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
function changeQuestion(val){
if(val.className == "question-button unatempted"){
val.classList.remove("unatempted");
val.classList.add("skipped");
}
val.classList.add("current-question");
var q = document.getElementById("q"+val.id);
var p = document.getElementById("detector");
var x = document.getElementById(p.innerHTML.substring(1));
x.classList.remove("current-question");
var o = document.getElementById(p.innerHTML);
o.style.transform = "scale(0, 1)";
o.style.display = "none";
q.style.display = "block";
q.style.transform = "scale(1, 1)";
p.innerHTML = q.id;
}
function markat(val){
var b = document.getElementById(val);
b.classList.remove("skipped");
b.classList.add("atempted");
}
function getPrev(){
var span = document.getElementById("detector");
var oldId = span.innerHTML;
if(oldId != "q1"){
var prevNumber = String(parseInt(oldId.substring(1))-1);
var newId = "q"+ prevNumber;
var newEle = document.getElementById(newId);
var oldEle = document.getElementById(oldId);
var newBtn = document.getElementById(prevNumber);
if(newBtn.className == "question-button unatempted"){
newBtn.classList.remove("unatempted");
newBtn.classList.add("skipped");
}
newBtn.classList.add("current-question");
var oldBtn = document.getElementById(oldId.substring(1));
oldBtn.classList.remove("current-question");
oldEle.style.transform = "scale(0, 1)";
oldEle.style.display = "none";
newEle.style.display = "block";
newEle.style.transform = "scale(1, 1)";
span.innerHTML = newEle.id;
}
}
function getNext(n){
var span = document.getElementById("detector");
var oldId = span.innerHTML;
if(oldId != "q"+n){
var prevNumber = String(parseInt(oldId.substring(1))+1);
var newId = "q"+ prevNumber;
var newEle = document.getElementById(newId);
var oldEle = document.getElementById(oldId);
var newBtn = document.getElementById(prevNumber);
if(newBtn.className == "question-button unatempted"){
newBtn.classList.remove("unatempted");
newBtn.classList.add("skipped");
}
newBtn.classList.add("current-question");
var oldBtn = document.getElementById(oldId.substring(1));
oldBtn.classList.remove("current-question");
oldEle.style.transform = "scale(0, 1)";
oldEle.style.display = "none";
newEle.style.display = "block";
newEle.style.transform = "scale(1, 1)";
span.innerHTML = newEle.id;
}
}
function timer(start_time){
var current_time = parseInt(new Date().getTime()/1000);
var remaining_time = 600 - (current_time - start_time);
var sec = remaining_time % 60;
var min = parseInt(remaining_time / 60);
var block = document.getElementById("timer");
var btn = document.getElementById("done");
var check = setInterval(function(){
block.innerHTML = "Time Remaining: " + String(min) + " : "+ String(sec);
sec--;
if(min <= -1){
alert("time up");
btn.click();
}
if(sec < 0){
min--;
sec = 59;
if(min == 0)
block.style.color = "red";
}
}, 1000);
}
function getContent(){
var mod = document.getElementById("conf-modal-body");
var ques = document.getElementById("ques-ans");
mod.innerHTML = ques.innerHTML;
var r = document.getElementsByName("radio1");
for(var i = 0; i < r.length; i++){
if(r[i].checked)
alert(r[i].value);
}
}
function conf(){
var r = confirm("you must have to submit fist");
if(r) document.getElementById("done").click();
}