-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
183 lines (175 loc) · 3.8 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>THE QUIZ</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body onload="setTimeout(showResults,5*60000)">
<div id="quiz"></div>
<button id="submit">Get Results</button>
<div id="results"></div>
<script type="text/javascript">
var numCorrect = 0;
var output = [];
var answers;
var wans=[];
var yans=[];
var qno=[];
var quizContainer = document.getElementById('quiz');
var resultsContainer = document.getElementById('results');
var submitButton = document.getElementById('submit');
var questions = [
{
question: "Which of the following are features of TCP Socket Stream?",
answers: {
a: 'connection-oriented',
b: 'simplex',
c: 'uni-directional'
},
correctAnswer: 'a'
},
{
question: "Can we make use of multi-casting in socket programming?",
answers: {
a: 'yes',
b: 'maybe',
c: 'no'
},
correctAnswer: 'a'
},
{
question: "Which of the following are features of UDP Datagram?",
answers: {
a: 'low latency rate',
b: 'sequential Ordering',
c: 'allow Send only'
},
correctAnswer: 'a'
},
{
question: "Can socket stream send data without a connection?",
answers: {
a: 'no',
b: 'yes',
c: 'maybe'
},
correctAnswer: 'a'
},
{
question: "Which of the following are blocking event calls?",
answers: {
a: 'reject',
b: 'disconnect',
c: 'connect'
},
correctAnswer: 'c'
},
{
question: "Can we skip socket binding?",
answers: {
a: 'no',
b: 'yes',
c: 'maybe'
},
correctAnswer: 'b'
},
{
question: "Which of the following are types of participant?",
answers: {
a: 'Passive',
b: 'Open',
c: 'Inactive'
},
correctAnswer: 'a'
},
{
question: "Which of the following are type of valid environments for socket programming?",
answers: {
a: 'virtual',
b: 'proxy',
c: 'iterative'
},
correctAnswer: 'c'
},
{
question: "Is socket programming a point to point connection?",
answers: {
a: 'yes',
b: 'not',
c: 'maybe'
},
correctAnswer: 'a'
},
{
question: "Can we disable TCP Nagle’s Algorithm?",
answers: {
a: 'maybe',
b: 'yes',
c: 'no'
},
correctAnswer: 'b'
}
];
function showQuestions(){
for(var i=0; i<questions.length; i++){
answers = [];
for(letter in questions[i].answers){
answers.push(
'<label>'
+ '<input type="radio" name="question'+i+'" value="'+letter+'">'
+ letter + ': '
+ questions[i].answers[letter]
+ '</label>'
);
}
output.push(
'<div class="question">' + questions[i].question + '</div>'
+ '<div class="answers">' + answers.join('') + '</div>'
);
}
quizContainer.innerHTML = output.join('');
}
function showResults(){
var answerContainers = quizContainer.querySelectorAll('.answers');
var userAnswer = '';
for(var i=0; i<questions.length; i++){
userAnswer = (answerContainers[i].querySelector('input[name=question'+i+']:checked')||{}).value;
if(userAnswer===questions[i].correctAnswer){
numCorrect++;
answerContainers[i].style.color = 'lightgreen';
}
else{
answerContainers[i].style.color = 'red';
qno.push(i+1);
wans.push(questions[i].correctAnswer);
yans.push(userAnswer);
}
}
setTimeout(myResult,10000);
function myResult(){
alert("your result is :"+numCorrect);
quizContainer.innerHTML="";
resultsContainer.innerHTML="";
submitButton.innerHTML="";
if(wans.length ==0)
{
document.write("congrats !!!!!!!!!!!!!!!!!!!!!!! ALL CORRECT");
}
else
{
document.write("Your Wrong answer are "+wans.length+"<br>");
for(var i=0;i<wans.length;i++)
{
document.write("_______________QUESTION NUMBER_______________"+qno[i]+"<br>");
document.write("your answer is "+(yans[i])+" "+"correct answer is "+wans[i]+"<br>");
}
}
}
}
showQuestions();
submitButton.onclick = function(){
showResults();
}
</script>
</body>
</html>