Skip to content

Commit ed27954

Browse files
Fixed issues: #15, #29, #72, #86, #100, #114, #128, #142
- Now user will be able to give a quiz for this lab and can evaluate his/herself with actual numbers and percentage and can also check the solutions. - Issue description: Earlier when user tries to submit the answers, user was getting redirecting to the 404 not found page instead of result page.
1 parent bfdfa7c commit ed27954

24 files changed

+2598
-92
lines changed

src/lab/exp10/Quizzes.html

Lines changed: 176 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<title>Welcome to Virtual Labs - A MHRD Govt of india Initiative</title>
1212

1313
<link rel="shortcut icon" href="../images/favicon.ico">
14-
14+
<script type="text/javascript" src = 'quiz.js'></script>
1515

1616
<link href="../css/bootstrap.min.css" rel="stylesheet">
1717

@@ -25,6 +25,37 @@
2525
<link href="../css/style.css" rel="stylesheet">
2626
<script type="text/javascript" src = 'tabs.js'></script>
2727
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-67020197-1', 'auto');ga('send', 'pageview');</script>
28+
29+
30+
<style>
31+
.qheader{
32+
font:bold 14px Arial;
33+
}
34+
35+
.qselections{
36+
font:normal 13px Arial;
37+
}
38+
</style>
39+
40+
<script src="quizconfig.js">
41+
</script>
42+
43+
<script>
44+
45+
/***********************************************
46+
* JavaScriptKit.com Multiple Choice Quiz Script (http://www.javascriptkit.com)
47+
* Copyright 2003 JavaScript Kit- http://www.javascriptkit.com
48+
* This notice and footnote must stay intact for use
49+
* Visit JavaScript Kit (http://www.javascriptkit.com/) for full source code
50+
***********************************************/
51+
52+
var actualchoices=new Array()
53+
document.cookie="ready=yes"
54+
</script>
55+
56+
57+
58+
2859
</head>
2960
<body id="page-top" class="index">
3061
<div id="top">
@@ -93,14 +124,19 @@ <h2 class="text-h2-lightblue" style=" margin-bottom: 20px; margin-top: 10px; "><
93124
<div class="row">
94125
<div class="col-md-2 sidebar-col-2">
95126
<!--edit1-->
96-
<a href="Introduction.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Introduction</h3></a><a href="Theory.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Theory</h3></a><a href="Objective.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Objective</h3></a><a href="Experiment.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Experiment</h3></a><a href="Manual.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Manual</h3></a><a href="Quizzes.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Quizzes</h3></a><a href="http://feedback.vlabs.ac.in/" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;"></h3></a> </div>
127+
<a href="Introduction.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Introduction</h3></a><a href="Theory.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Theory</h3></a><a href="Objective.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Objective</h3></a><a href="Experiment.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Experiment</h3></a><a href="Manual.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Manual</h3></a><a href="Quizzes.html?domain=Computer Science&lab=Problem Solving Lab" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;">Quizzes</h3></a><a href="http://feedback.vlabs.ac.in/" class="sidebar-a" > <h3 class="text-h3-darkblue" style="margin-top: 2px;"></h3></a> </div>
97128

98-
<div class="col-md-10 lab-list-col-10">
129+
130+
131+
132+
133+
134+
<div class="col-md-10 lab-list-col-10">
99135

100136
<!--edit -->
101-
<h1 class="text-h2-lightblue">Sequences</h1><div class="content" id="experiment-article-section-6-content">
137+
<h1 class="text-h2-lightblue">Numerical Representation</h1><div class="content" id="experiment-article-section-6-content">
102138
<p>
103-
<form action="quizresults.php" method="post" name="quiz" onsubmit='return window.confirm("You are submitting information to an external page. \nAre you sure?");' target="_blank">
139+
<!-- <form method="post" name="quiz" onsubmit='evaluate()' target="_blank">
104140
<ol>
105141
<li><b>1. The execution of a loop typically starts with: </b></li>
106142
<input name="Q1" type="radio" value="1">initialization statements<br>
@@ -129,27 +165,154 @@ <h1 class="text-h2-lightblue">Sequences</h1><div class="content" id="experiment-
129165
<input name="Q4" type="radio" value="4">None of the above<br>
130166
<br>
131167
<li><b>5. Which of the following is not an infinite loop. </b></li>
132-
<input name="Q5" type="radio" value="1"><code>int i = 1 ;
168+
<input name="Q5" type="radio" value="1"><code>int i = 1 ;
133169
while ( 1 )
134170
{
135171
i++ ;
136172
}</code><br>
137173
<input name="Q5" type="radio" value="2">
138-
<code>for( int i =1; i&lt; 10; i--)
139-
printf("Hello World");
174+
<code>for( int i =1; i &lt; 10 ; i--) printf("Hello World");
140175
</code><br>
141176
<input name="Q5" type="radio" value="3"><code>for(int i =1; i&lt;100; i++)
142177
printf("Hello World");
143178
</code><br>
144-
<input name="Q5" type="radio" value="4"><code>int i = 0;
179+
<input name="Q5" type="radio" value="4">
180+
<code>int i = 0;
145181
do{
146182
i--
147183
printf("%d ",i);
148184
}while(i&gt;0);
149-
</code><br>
185+
</code>
186+
</ol>
187+
<br>
150188
</br></input></br></input></br></input></br></input></br></br></input></br></input></br></input></br></input></br></br></input></br></input></br></input></br></input></br></br></input></br></input></br></input></br></input></br></br></input></br></input></br></input></br></input></ol>
151-
<p> <input target="_blank" type="submit" value="Submit answers for evaluation"/></p>
189+
<br>
190+
<p> <button type="submit" onclick="evaluate()">Submit answers for evaluation</button></p>
191+
</br></form> -->
192+
193+
194+
195+
<form method="POST" name="myquiz">
196+
197+
<!-- <font face="Arial"><big><big>General Knowledge Quiz</big></big></font></p> -->
198+
199+
<div class="qheader">
200+
1. The execution of a loop typically starts with: </div>
201+
<div class="qselections">
202+
<input type="radio" value="a" name="question1">a) initialization statements<br>
203+
<input type="radio" value="b" name="question1">b) Loop body<br>
204+
<input type="radio" value="c" name="question1">c) test condition<br>
205+
<input type="radio" value="d" name="question1">d) update statements<br>
206+
</div>
207+
208+
<br>
209+
210+
<div class="qheader">
211+
2) The break statement is used to exit from:</div>
212+
<div class="qselections">
213+
<input type="radio" value="a" name="question2">a) an if statement<br>
214+
<input type="radio" value="b" name="question2">b) a for loop<br>
215+
<input type="radio" value="c" name="question2">c) a program<br>
216+
<input type="radio" value="d" name="question2">d) the main( ) function<br>
217+
</div>
218+
219+
<br>
220+
221+
<div class="qheader">
222+
3) A do-while loop is useful when we want that the statements within the loop must be executed</div>
223+
<div class="qselections">
224+
<input type="radio" value="a" name="question3">a) only once<br>
225+
<input type="radio" value="b" name="question3">b) At Least Once<br>
226+
<input type="radio" value="c" name="question3">c) More than once<br>
227+
<input type="radio" value="d" name="question3">d) None of the above<br>
228+
</div>
229+
230+
<br>
231+
232+
<div class="qheader">
233+
4) In what sequence the initialization, testing and execution of body is done in a do-while loop </div>
234+
<div class="qselections">
235+
<input type="radio" value="a" name="question4">a) Initialization, execution of body, testing<br>
236+
<input type="radio" value="b" name="question4">b) Execution of body, initialization, testing<br>
237+
<input type="radio" value="c" name="question4">c) Initialization, testing, execution of body<br>
238+
<input type="radio" value="d" name="question4">d) None of the above<br>
239+
</div>
240+
241+
<br>
242+
243+
<div class="qheader">
244+
5) Which looping process checks the test condition at the end of the loop?</div>
245+
<div class="qselections">
246+
<input type="radio" value="a" name="question5">a) for<br>
247+
<input type="radio" value="b" name="question5">b) while<br>
248+
<input type="radio" value="c" name="question5">c) do-while<br>
249+
<input type="radio" value="d" name="question5">d) No looping peocess check condition at the end<br>
250+
</div>
251+
252+
<br>
253+
254+
<div class="qheader">
255+
6) A continue statement causes execution to skip to: </div>
256+
<div class="qselections">
257+
<input type="radio" value="a" name="question6">a) the end of the program<br>
258+
<input type="radio" value="b" name="question6">b) the first statement after the loop<br>
259+
<input type="radio" value="c" name="question6">c) the statement following the continue statement<br>
260+
<input type="radio" value="d" name="question6">d) the next iteration of the loop<br>
261+
</div>
262+
263+
<br>
264+
265+
<div class="qheader">
266+
7) The statement i++; is equivalent to: </div>
267+
<div class="qselections">
268+
<input type="radio" value="a" name="question7">a) <code>i = i + i;</code><br>
269+
<input type="radio" value="b" name="question7">b) <code>i = i + 1;</code><br>
270+
<input type="radio" value="c" name="question7">c) <code>i = i - 1;</code><br>
271+
<input type="radio" value="d" name="question7">d) <code> i - - ;</code><br>
272+
</div>
273+
274+
<br>
275+
276+
<div class="qheader">
277+
8) Another word for "looping" is: </div>
278+
<div class="qselections">
279+
<input type="radio" value="a" name="question8">a) recapitulation <br>
280+
<input type="radio" value="b" name="question8">b) tintinabulation <br>
281+
<input type="radio" value="c" name="question8">c) iteration<br>
282+
<input type="radio" value="d" name="question8">d) reiteration<br>
283+
</div>
284+
285+
<br>
286+
287+
<div class="qheader">
288+
9) Which looping process is best used when the number of iterations is known?</div>
289+
<div class="qselections">
290+
<input type="radio" value="a" name="question9">a) for<br>
291+
<input type="radio" value="b" name="question9">b) while<br>
292+
<input type="radio" value="c" name="question9">c) do-while<br>
293+
<input type="radio" value="d" name="question9">d) all of the above<br>
294+
</div>
295+
296+
<br>
297+
298+
<div class="qheader">
299+
10) Which of the following is not an infinite loop.</div>
300+
<div class="qselections">
301+
<input type="radio" value="a" name="question10">a) <code>int i = 1 ; while ( 1 ) { i++ ;
302+
} </code><br>
303+
<input type="radio" value="b" name="question10">b) <code>for( int i =1; i &lt; 10 ; i--) printf("Hello World");</code><br>
304+
<input type="radio" value="c" name="question10">c) <code>for(int i =1; i&lt;100; i++) printf("Hello World");</code><br>
305+
<input type="radio" value="d" name="question10">d) <code>int i = 0; do{ i-- printf("%d ",i); }while(i&gt;0);</code><br>
306+
307+
</div>
308+
309+
</form>
310+
311+
<form>
312+
<div align="center">
313+
<input type="button" value="Grade Me!" name="B1" onClick="gradeit()"> <input type="button" value="Reset" name="B2" onClick="document.myquiz.reset()"></div>
152314
</form>
315+
153316
</p>
154317
</div> </div>
155318
</div>
@@ -206,6 +369,8 @@ <h2 class="text-h2-lightblue-small" style="font-weight: bold;margin-top: 0px;">
206369

207370
</div> <!-- top div -->
208371

372+
373+
209374
</body>
210375

211376

src/lab/exp10/quizconfig.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/***********************************************
2+
* JavaScriptKit.com Multiple Choice Quiz Script (http://www.javascriptkit.com)
3+
* Copyright 2003 JavaScript Kit- http://www.javascriptkit.com
4+
* This notice and footnote must stay intact for use
5+
* Visit JavaScript Kit (http://www.javascriptkit.com/) for full source code
6+
***********************************************/
7+
8+
//Enter total number of questions:
9+
var totalquestions=10
10+
11+
//Enter the solutions corresponding to each question:
12+
var correctchoices=new Array()
13+
correctchoices[1]='a' //question 1 solution
14+
correctchoices[2]='b' //question 2 solution, and so on.
15+
correctchoices[3]='b'
16+
correctchoices[4]='a'
17+
correctchoices[5]='c'
18+
correctchoices[6]='d'
19+
correctchoices[7]='b'
20+
correctchoices[8]='c'
21+
correctchoices[9]='a'
22+
correctchoices[10]='c'
23+
24+
/////Don't edit beyond here//////////////////////////
25+
26+
function gradeit(){
27+
var incorrect=null
28+
for (q=1;q<=totalquestions;q++){
29+
var thequestion=eval("document.myquiz.question"+q)
30+
for (c=0;c<thequestion.length;c++){
31+
if (thequestion[c].checked==true)
32+
actualchoices[q]=thequestion[c].value
33+
}
34+
35+
if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice
36+
if (incorrect==null)
37+
incorrect=q
38+
else
39+
incorrect+="/"+q
40+
}
41+
}
42+
43+
if (incorrect==null)
44+
incorrect="a/b"
45+
document.cookie='q='+incorrect
46+
if (document.cookie=='')
47+
alert("Your browser does not accept cookies. Please adjust your browser settings.")
48+
else
49+
window.location="results.htm"
50+
}
51+
52+
53+
function showsolution(){
54+
var win2=window.open("","win2","width=200,height=350, scrollbars")
55+
win2.focus()
56+
win2.document.open()
57+
win2.document.write('<title>Solution</title>')
58+
win2.document.write('<body bgcolor="#FFFFFF">')
59+
win2.document.write('<center><h3>Solution to Quiz</h3></center>')
60+
win2.document.write('<center><font face="Arial">')
61+
for (i=1;i<=totalquestions;i++){
62+
for (temp=0;temp<incorrect.length;temp++){
63+
if (i==incorrect[temp])
64+
wrong=1
65+
}
66+
if (wrong==1){
67+
win2.document.write("Question "+i+"="+correctchoices[i].fontcolor("red")+"<br>")
68+
wrong=0
69+
}
70+
else
71+
win2.document.write("Question "+i+"="+correctchoices[i]+"<br>")
72+
}
73+
win2.document.write('</center></font>')
74+
win2.document.write("<h5>Note: The solutions in red are the ones to the questions you had incorrectly answered.</h5>")
75+
win2.document.close()
76+
}

src/lab/exp10/results.htm

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<html>
2+
3+
<head>
4+
<title>Instant Quiz Results</title>
5+
</head>
6+
7+
<body bgcolor="#FFFFFF">
8+
9+
<p align="center"><strong><font face="Arial">
10+
11+
<script src="quizconfig.js">
12+
</script>
13+
14+
<big>Instant Quiz Results</big></font></strong></p>
15+
<div align="center"><center>
16+
17+
<table border="0" cellspacing="0" cellpadding="0">
18+
<tr>
19+
<td width="100%"><form method="POST" name="result"><table border="0" width="100%" cellpadding="0" height="116">
20+
<tr>
21+
<td height="25" bgcolor="#D3FFA8"><strong><font face="Arial">No. of questions you got right:</font></strong></td>
22+
<td height="25"><p><input type="text" name="p" size="24"></td>
23+
</tr>
24+
<tr>
25+
<td height="17" bgcolor="#D3FFA8"><strong><font face="Arial">The questions you got wrong:</font></strong></td>
26+
<td height="17"><p><textarea name="T2" rows="3" cols="24" wrap="virtual"></textarea></td>
27+
</tr>
28+
<tr>
29+
<td height="25" bgcolor="#D3FFA8"><strong><font face="Arial">Grade in percentage:</font></strong></td>
30+
<td height="25"><input type="text" name="q" size="8"></td>
31+
</tr>
32+
</table>
33+
</form>
34+
</td>
35+
</tr>
36+
</table>
37+
</center></div>
38+
39+
<form method="POST"><div
40+
align="center"><center><p>
41+
42+
<script>
43+
var wrong=0
44+
for (e=0;e<=2;e++)
45+
document.result[e].value=""
46+
47+
var results=document.cookie.split(";")
48+
for (n=0;n<=results.length-1;n++){
49+
if (results[n].charAt(1)=='q')
50+
parse=n
51+
52+
}
53+
54+
var incorrect=results[parse].split("=")
55+
incorrect=incorrect[1].split("/")
56+
if (incorrect[incorrect.length-1]=='b')
57+
incorrect=""
58+
document.result[0].value=totalquestions-incorrect.length+" out of "+totalquestions
59+
document.result[2].value=(totalquestions-incorrect.length)/totalquestions*100+"%"
60+
for (temp=0;temp<incorrect.length;temp++)
61+
document.result[1].value+=incorrect[temp]+", "
62+
63+
64+
</script>
65+
66+
<input type="button" value="Take the quiz again" name="B1"
67+
onClick="history.go(-1)"> <input type="button" value="View solution" name="B2"
68+
onClick="showsolution()"></p>
69+
</center></div>
70+
</form>
71+
72+
</body>
73+
</html>

0 commit comments

Comments
 (0)