-
Notifications
You must be signed in to change notification settings - Fork 13
/
RC.html
304 lines (279 loc) · 9.11 KB
/
RC.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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link REL="SHORTCUT ICON" HREF="favicon.ico">
<title>RC Practice Utility</title>
<script src="data.js" type="text/javascript" charset="utf-8"></script>
<script language="javascript">
var totalq=0;
var curq=0;
var curans=0;
var pid=0;
var rs=0; //0 means random, 1 means next and 2 means prev
var count_sec=0;
var count_min=0;
var timer;
function randomIntFromInterval(min,max) {
return Math.floor(Math.random()*(max-min+1)+min);
}
function startCount()
{
document.getElementById('rid').innerHTML="Time elapsed = "+count_min+" mins , "+count_sec+" Secs";
count_sec=count_sec+1;
if(count_sec>=60)
{
count_sec=0;
count_min=count_min+1;
}
timer=window.setTimeout("startCount()",1000);
}
function stopCount()
{
count_sec=0;
count_min=0;
clearTimeout(timer);
}
function nextq()
{
if(curq<data[pid][1].length-1)
{
curq=curq+1;
show_question();
}
else
{
show_psg(rs);
}
}
function show_psg(rs) //0 means random, 1 means next and 2 means prev
{
if(rs==0)
pid=randomIntFromInterval(0,data.length-1);
else if(rs==1)
{
if(pid==data.length-1)
pid=0;
else
pid=pid+1;
}
else if(rs==2)
{
if(pid==0)
pid=data.length-1;
else
pid=pid-1;
}
document.getElementById("pid_val").value=(pid+1);
document.getElementById("passage").innerHTML=data[pid][0];
totalq=data[pid][1].length;
curq=0;
stopCount();
startCount();
reset_img();
show_question();
}
function show_question() //curq already set
{
var question_string=data[pid][1][curq][0]+"<br><br>";
curans=randomIntFromInterval(1,(data[pid][1][curq].length-1));
var onum=1;
for(var i=1;i<data[pid][1][curq].length;i++)
{
if(i!=curans)
{
onum++;
question_string=question_string+"<input id='option"+i+"' type='radio' name='useranswer' value='"+i+"'><label for='option"+i+"'>"+data[pid][1][curq][onum]+"</label><br>";
}
else
question_string=question_string+"<input id='option"+i+"' type='radio' name='useranswer' value='"+i+"'><label for='option"+i+"'>"+data[pid][1][curq][1]+"</label><br>";
}
document.getElementById("questions").innerHTML=question_string;
document.getElementById("infoid").innerHTML="";
disable_nxt();
}
function hilight(right,wrong)
{
var arrayOflabel = document.getElementsByTagName("label");
var o=0
for (var j=0;j<arrayOflabel.length;j++)
{
if(arrayOflabel[j].htmlFor!="")
{
var opnum=parseInt(arrayOflabel[j].htmlFor.substring(6));
if(opnum==right)
arrayOflabel[j].style.background='#66ff66';
else
arrayOflabel[j].style.background='#FFFFFF';
if(wrong!=-1)
{
if(opnum==wrong)
if(o==0)
{
arrayOflabel[j].style.background='#ff6666';
o=1;
}
}
}
}
}
function handleEnter(inField, e) {
var charCode;
if(e && e.which){
charCode = e.which;
}else if(window.event){
e = window.event;
charCode = e.keyCode;
}
if(charCode == 13)
{
document.getElementById('infoid').innerHTML="";
pid=parseInt(document.getElementById('pid_val').value) -1;
document.getElementById("passage").innerHTML=data[pid][0];
totalq=data[pid][1].length;
rs=1;
curq=0;
stopCount();
startCount();
reset_img();
show_question();
}
}
function disable_options()
{
document.getElementById('option1').disabled=true;
document.getElementById('option2').disabled=true;
document.getElementById('option3').disabled=true;
document.getElementById('option4').disabled=true;
document.getElementById('option5').disabled=true;
}
function reset_img()
{
var i=0;
for (i=1;i<=12;i++)
document.getElementById('i'+i).innerHTML="";
for (i=1;i<=totalq;i++)
document.getElementById('i'+i).innerHTML="<img src='./img/na.png'>";
}
function set_right()
{
document.getElementById('i'+(curq+1)).innerHTML="<img src='./img/right.png'>";
}
function set_wrong()
{
document.getElementById('i'+(curq+1)).innerHTML="<img src='./img/wrong.png'>";
}
function valbutton()
{
var user_ans;
var msg="Incorrect. A";
try
{
user_ans=document.querySelector('input[name="useranswer"]:checked').value;
}
catch(err)
{
//console.log(err.message);
msg="Correct a";
}
disable_options();
if(curans==user_ans)
{
set_right();
hilight(curans,-1);
document.getElementById("infoid").innerHTML="<img src='./img/tick.gif'> <font color='#009900'>Correct</font>";
}
else
{
set_wrong();
hilight(curans,user_ans);
var map=["A","B","C","D","E"];
document.getElementById("infoid").innerHTML="<img src='./img/cross.gif'> <font color='#cc3300'>"+msg+"nswer is ("+map[curans-1]+")</font>";
}
enable_nxt();
}
function enable_nxt()
{
document.getElementById('nxt').disabled=false;
document.getElementById('nxt').style.color="#1f1f65";
}
function disable_nxt()
{
document.getElementById('nxt').disabled=true;
document.getElementById('nxt').style.color="#656567";
}
</script>
<style type="text/css" media="screen">
input.btn, select.btn {
background-color:#5f5e5c;
background-image:url(./img/btn.gif);
border-color:#666666 #000000 #000000 #000000;
border-style:solid;
border-width:1px;
color:#1f1f65;
font-family:'trebuchet ms',helvetica,sans-serif;
font-size:90%;
font-weight:bold;
padding-left:5px;
padding-right:5px;
}
input.btn:hover, select.btn:hover {
background-color:#5f5e5c;
background-image:url(./img/btn_hover.gif);
border-color:#666666 #000000 #000000 #000000;
border-style:solid;
border-width:1px;
color:#1f1f65;
font-family:'trebuchet ms',helvetica,sans-serif;
font-size:90%;
font-weight:bold;
padding-left:5px;
padding-right:5px;
}
</style>
</head>
<body onload="show_psg(0)">
<center><h3><b>A <a href="https://github.com/lagnajeet/RC_Practice_Desktop_App">standalone desktop version</a> is available for the same purpose.</b> Please consider using that as I will be focusing more of my efforts on it in future.</h3></center>
<table cellpadding="0" cellspacing="0" border="1" width="800px" height="500px" align="center" style="margin-top:30px">
<tr><td colspan=2 width="50%" height="100%" style='padding-top:3px;padding-right:2px;padding-left:2px;'>
<span style="float:left;" id="pno">
<input class="btn" type="button" onclick="javascript:show_psg(2)" style="width:100px;height:22px" value="Previous">
<font size="4px;" face="Courier New" color="#000000">Passage</font>
<input id="pid_val" type="text" onkeypress="handleEnter(this, event)" style="width:35px;height:19px" value="">
<input class="btn" type="button" onclick="javascript:show_psg(1)" style="width:100px;height:22px" value="Next">
</span>
<span style="font-family: 'Courier New', Courier, monospace;float:right;font-weight: bold;" id='rid'></span>
</td></tr>
<tr><td rowspan=3 width="50%" height="100%"><div style='height:500px;overflow:auto'><div id="passage" style="overflow:visible;color:black;font-family:'Courier New', Courier, monospace;font-size:18px;background-image:url('./img/lines.gif');background-repeat:no-repeat;padding-left:35px;padding-right:5px;text-align:justify;"></div></div>
</td></tr>
<tr><td width="50%" height='475px'>
<form id='qform'>
<div name='form1' id="questions" style="height:475px;overflow:auto;color:black;font-family:'Courier New', Courier, monospace;font-size:18px;padding-left: 5px;padding-right: 5px;text-align: justify;"></div>
</form>
</td></tr>
<tr><td width="50%" height='30px' id="infoid" style="border:0px;text-align:center;font-family:'Courier New', Courier, monospace;font-size:18px;" align='center'></td></tr>
<tr>
<td align="left" style='border-left:1px solid;border-right:0px;padding-left:2px;padding-top:1px;' valign="middle">
<span id='i1'></span>
<span id='i2'></span>
<span id='i3'></span>
<span id='i4'></span>
<span id='i5'></span>
<span id='i6'></span>
<span id='i7'></span>
<span id='i8'></span>
<span id='i9'></span>
<span id='i10'></span>
<span id='i11'></span>
<span id='i12'></span>
</td>
<td id="buttonid" align="right" style='border-left:0px;padding-top:1px;padding-right:2px;'>
<input class="btn" type="button" onclick="show_psg(0);" style="width:100px;height:22px" value="Skip">
<input class="btn" type="button" onclick="valbutton();" style="width:100px;height:22px" value="Submit">
<input id="nxt" class="btn" type="button" onclick="nextq();" style="width: 100px; height: 22px; color: #656567;" value="Next" disabled="disabled">
</td></tr>
</table>
<br>
<center><b>The line numbers in the questions may not refer correctly to the right line in the passage.</b><br><br><font color="#B40404"><i>The code is released under </font><a href="gpl-3.0-standalone.html" style="color:#840404">GNU public license</a><font color="#B40404">.<br>The developer claims no rights to the data which in this case are the reading comprehensions.<br>The data format used for this program is described in </font><a href="documentation.html" style="color:#840404">here</a><font color="#B40404">.</i></font></center><br><div width="75%" style="color:black;font-family:Tahoma;font-size:10px;text-align:center;" align="center">You can reach me at <a href="mailto:lagnajeet@gmail.com" style="color:black;font-family:Tahoma;font-size:10px;color:#0582ff;text-decoration:none;">lagnajeet@gmail.com</a>.</div>
</body>
</html>