serious problem..in online examination ..plz solve that as soon as possible

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2007
Posts: 1
Reputation: cmg1986 is an unknown quantity at this point 
Solved Threads: 0
cmg1986 cmg1986 is offline Offline
Newbie Poster

serious problem..in online examination ..plz solve that as soon as possible

 
0
  #1
Jul 31st, 2007
Hello...
I have a quiz application based on PHP.
I use paging, which is showing only one question per page.
I want to set a time limitation on the application.
The problem is that when i do refresh the page then javascript countdown timer start from starting.
What i want to do is i want the time limitation only loaded once at the beginning. though we move to the prev or next page, the time will keep on counting without being started again.
Can you help me with this?
Many thanks for the helps....PLZZZZZZZZZZZZZZz send me changes in code so that i can deposit my project upto 3rd aug 07.
MY CODE IS::
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['counter']))
  4. {
  5. $_SESSION['counter']+=1;
  6. }
  7. else
  8. {
  9. $flag=1;
  10. $_SESSION['counter']=-1;
  11. }
  12.  
  13. ?>
  14. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  15. <html xmlns="http://www.w3.org/1999/xhtml">
  16. <head>
  17. <script language="JavaScript" type="text/javascript">
  18. var hr = 00; //<%=request.getAttribute("HR") %>
  19. var sec = 00; // set the seconds
  20. var min =01; // set the minutes
  21.  
  22.  
  23. function countDown() {
  24. sec--;
  25.  
  26. if (sec == -01)
  27. {
  28. sec = 59;
  29. min = min - 1;
  30. }
  31. else { min = min; }
  32.  
  33. if (sec<=9)
  34. { sec = "0" + sec;
  35. }
  36.  
  37. if(min==-01)
  38. {
  39. min=59;
  40. hr= hr-1;
  41. }
  42.  
  43. time = (hr<=9 ? "0" + hr : hr)+" : " + (min<=9 ? "0" + min : min)+ " : " + sec ;
  44. if (document.getElementById) { document.getElementById('theTime').innerHTML = time; }
  45. //document.ans_form.timeLeft.value = time;
  46.  
  47. /*if (document.getElementById)
  48. {
  49. theTime.innerHTML = time;
  50. }*/
  51.  
  52. SD=window.setTimeout("countDown();", 1000);
  53.  
  54. // To check time is over or not
  55. if (hr=='00' && min == '00' && sec == '00')
  56. { sec = "00"; window.clearTimeout(SD);
  57. alert("stop");
  58. }
  59. }
  60. window.onload = countDown;
  61.  
  62. </script>
  63.  
  64.  
  65.  
  66. <script language="javascript">
  67. //var targetURL="usermain.php"
  68. function doRedirect(targetURL)
  69. {
  70. window.location.replace(targetURL);
  71. }
  72. </script>
  73. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  74. <title>Untitled Document</title>
  75. <style type="text/css">
  76. <!--
  77. .style9 {
  78. font-size: 24px;
  79. font-weight: bold;
  80. }
  81. .style10 {
  82. font-size: 36px;
  83. font-weight: bold;
  84. }
  85. .style11 {color: #000066}
  86. -->
  87. </style>
  88. <script language="javascript">
  89. function check()
  90. {
  91. var checked=false;
  92. for(counter = 0; counter < 4; counter++)
  93. {
  94. if(document.ans_form.option[counter].checked)
  95. {
  96. checked=true;
  97. }
  98. }
  99. if(checked == false)
  100. {
  101. alert("Please select an option ");
  102. }
  103. else document.ans_form.submit();
  104. }
  105.  
  106. function check1()
  107. {
  108. document.ans_form.submit();
  109. }
  110.  
  111. </script>
  112. </head>
  113.  
  114. <body>
  115. <table width="100%">
  116. <tr><td width="100%" align="center"><span id="theTime" class="timeClass"></span></td></tr>
  117. </table>
  118. <?php
  119. echo sec;
  120. if (!isset($_SESSION['userid']))
  121. {
  122. ?>
  123. <script language="javascript">
  124. doRedirect("main.php");
  125. </script>
  126. <?php
  127. }
  128. ?>
  129. <?php
  130.  
  131. $conn=mysql_connect("localhost","root","");
  132. mysql_select_db('onlineexam', $conn);
  133. //Write the code for random number generation
  134. // begin the session
  135. //..............................................>>>
  136.  
  137. //.........................................>
  138. for($j=0; $j<11; $j++)
  139. {
  140. $x[$j] = $j+1;
  141.  
  142. //for ( $i = 1; $i < 51; $i++ )
  143. // print "<tr><td>" . $x[$i] . " ";
  144. // $y=$x[$i];
  145. }shuffle($x);
  146.  
  147. for($j=0; $j<=3; $j++)
  148. {
  149. $y[$j] = $j+1;
  150.  
  151. //for ( $i = 1; $i < 51; $i++ )
  152. // print "<tr><td>" . $x[$i] . " ";
  153. // $y=$x[$i];
  154. }shuffle($y);
  155. for($j=0;$j<5;$j++)
  156. {
  157. $z[$j]=$x[$j];
  158. }
  159.  
  160. if(!isset($_SESSION['k']))
  161. {
  162. $_SESSION['k']=$z;
  163. }
  164. $_SESSION['p']=$y;
  165. // loop through the session array with foreach
  166. $user_id=$_SESSION['userid'];
  167. $query="select count(*) from user_exam where userid='$user_id'";
  168. $result=mysql_query($query) or die(mysql_error());
  169. $row=mysql_fetch_row($result);
  170. if($row[0] == 0)
  171. {
  172. foreach($_SESSION['k'] as $key=>$value)
  173. {
  174. // and print out the values
  175. echo $value.' <br />';
  176. $query="insert into user_exam(userid, attemptno, status) values('$user_id','$value', 'not')";
  177. $result=mysql_query($query) or die(mysql_error());
  178. }
  179. }
  180. $query3="select * from user_exam where userid='$user_id' and status='not'";
  181. $result3=mysql_query($query3);
  182. $row3=mysql_fetch_row($result3);
  183. echo $row3[0];
  184. if($row3 == null)
  185. {
  186. ?>
  187. <script language="javascript">
  188. doRedirect("paprfinis.php");
  189. </script>
  190. <?php
  191. }
  192.  
  193. // Fetch the questions from database
  194. // $user_id=$_SESSION['userid'];
  195. //echo $user_id;
  196. // write code to count number of attempted questions in the database by a particular user
  197. //............
  198.  
  199.  
  200. $counter=$_SESSION['counter'];
  201. if($counter == 4) $_SESSION['counter']=-1;
  202. echo "counter:".$counter;
  203.  
  204. //$que_no=$_SESSION['k'][$counter];
  205. //$temp_array=$_SESSION['k'];
  206. //$que_no=$value;
  207. echo "queno:".$que_no;
  208.  
  209. // echo $que_no;
  210.  
  211. //echo $_SESSION['que_no'];
  212.  
  213.  
  214.  
  215. echo $user_id;
  216. $query="select * from user_exam where userid='$user_id'";
  217. $result=mysql_query($query) or die(mysql_error());
  218. mysql_data_seek($result, $counter);
  219. $row=mysql_fetch_row($result);
  220. if(strcasecmp($row[2], 'not') == 0)
  221. {
  222. echo "question :".$row[1];
  223. $result1 = mysql_query("SELECT quesdesc, opt1, opt2, opt3, opt4 FROM question_master where queno=$row[1]");
  224. $row1=mysql_fetch_row($result1);
  225. $_SESSION['que_no']=$row[1];
  226. echo "session question:".$_SESSION['que_no'];
  227. }
  228.  
  229.  
  230.  
  231. else
  232. {
  233. ?>
  234. <script language="javascript">
  235. doRedirect("tstqus.php");
  236. </script>
  237. <?php
  238. }
  239.  
  240.  
  241. /*while($row=mysql_fetch_row($result))
  242.   {
  243.   if($que_no == $row[0])
  244.   {
  245. $flag=1;
  246.   }
  247.   }
  248. if($flag != 1)
  249.  { */
  250.  
  251.  
  252.  
  253. // echo $row[0].$row[1].$row[2].$row[3].$row[4];
  254. //$result1 = mysql_query("SELECT opt1,opt2,opt3,opt4 FROM question_master where queno=");
  255. //$row1=mysql_fetch_row($result1);
  256. //echo $row1[0].$row1[1];*/
  257. ?>
  258.  
  259. <table width="916" border="0" cellpadding="0" cellspacing="0">
  260. <!--DWLayoutTable-->
  261. <tr>
  262. <td width="229" rowspan="2" valign="top"><img src="images/CSC.jpg" width="202" height="66" alt="jj" /></td>
  263. <td width="49" height="48">&nbsp;</td>
  264. <td width="63">&nbsp;</td>
  265. <td colspan="3" valign="top"><div align="center"><u><span class="style10">ONLINE EXAMINATION </span></u><span class="style10"></span></div></td>
  266. <td width="123"></td>
  267. <td width="23"></td>
  268. </tr>
  269. <tr>
  270. <td height="18"></td>
  271. <td></td>
  272. <td width="146"></td>
  273. <td width="156"></td>
  274. <td width="127"></td>
  275. <td></td>
  276. <td></td>
  277. </tr>
  278. <tr>
  279. <td height="14"></td>
  280. <td></td>
  281. <td></td>
  282. <td></td>
  283. <td></td>
  284. <td></td>
  285. <td></td>
  286. <td></td>
  287. </tr>
  288. <tr>
  289. <td height="27"></td>
  290. <td></td>
  291. <td></td>
  292. <td></td>
  293. <td valign="top"><span class="style9"><u><span class="style11">TEST PAPER</span>:</u></span></td>
  294. <td>&nbsp;</td>
  295. <td></td>
  296. <td></td>
  297. </tr>
  298.  
  299. <tr>
  300. <td height="17"></td>
  301. <td></td>
  302. <td></td>
  303. <td></td>
  304. <td></td>
  305. <td></td>
  306. <td></td>
  307. <td></td>
  308. </tr>
  309. <tr>
  310. <td height="15"></td>
  311. <td></td>
  312. <td colspan="5" rowspan="9" valign="top">
  313. <form name="ans_form" action="submitqus.php" method="post">
  314.  
  315. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  316. <!--DWLayoutTable-->
  317. <tr>
  318. <td width="32" height="9"></td>
  319. <td width="17"></td>
  320. <td width="24"></td>
  321. <td width="20"></td>
  322. <td width="100"></td>
  323. <td width="51"></td>
  324. <td width="94"></td>
  325. <td width="16"></td>
  326. <td width="45"></td>
  327. <td width="205"></td>
  328. <td width="11"></td>
  329. </tr>
  330. <tr>
  331. <td colspan="2" rowspan="2" valign="top"><span class="style9">Qus:</span></td>
  332. <td height="6"></td>
  333. <td></td>
  334. <td></td>
  335. <td></td>
  336. <td></td>
  337. <td></td>
  338. <td></td>
  339. <td></td>
  340. <td></td>
  341. </tr>
  342. <tr>
  343. <td colspan="8" rowspan="2" valign="top">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo "<font face=arial size=3>". $row1[0]; ?><p>&nbsp;</p></td>
  344. <td height="20"></td>
  345. </tr>
  346. <tr>
  347. <td height="68">&nbsp;</td>
  348. <td>&nbsp;</td>
  349. <td></td>
  350. </tr>
  351.  
  352.  
  353.  
  354.  
  355. <tr>
  356. <td height="20">&nbsp;</td>
  357. <td>&nbsp;</td>
  358. <td>&nbsp;</td>
  359. <td>&nbsp;</td>
  360. <td>&nbsp;</td>
  361. <td>&nbsp;</td>
  362. <td>&nbsp;</td>
  363. <td>&nbsp;</td>
  364. <td>&nbsp;</td>
  365. <td>&nbsp;</td>
  366. <td>&nbsp;</td>
  367. </tr>
  368.  
  369. <tr>
  370. <td height="20"></td>
  371. <td colspan="2" valign="top"><label>
  372. <input type="radio" name="option" id="radio" value="<?php echo $row1[$y[1]]; ?>" />
  373. </label></td>
  374. <td colspan="5" rowspan="2" valign="top"><?php echo "<font face=verdana size=3>".$row1[$y[1]]; ?>&nbsp;</td>
  375. <td>&nbsp;</td>
  376. <td>&nbsp;</td>
  377. <td>&nbsp;</td>
  378. </tr>
  379. <tr>
  380. <td height="12"></td>
  381. <td></td>
  382. <td></td>
  383. <td></td>
  384. <td></td>
  385. <td></td>
  386. </tr>
  387. <tr>
  388. <td height="16"></td>
  389. <td></td>
  390. <td></td>
  391. <td></td>
  392. <td></td>
  393. <td></td>
  394. <td></td>
  395. <td></td>
  396. <td></td>
  397. <td></td>
  398. <td></td>
  399. </tr>
  400. <tr>
  401. <td height="20"></td>
  402. <td colspan="2" valign="top">
  403. <label>
  404. <input type="radio" name="option" id="radio2" value="<?php echo $row1[$y[2]]; ?>" />
  405. </label> </td>
  406. <td colspan="5" rowspan="2" valign="top"><?php echo "<font face=verdana size=3>".$row1[$y[2]]; ?>&nbsp;</td>
  407. <td></td>
  408. <td></td>
  409. <td></td>
  410. </tr>
  411. <tr>
  412. <td height="12"></td>
  413. <td></td>
  414. <td></td>
  415. <td></td>
  416. <td></td>
  417. <td></td>
  418. </tr>
  419. <tr>
  420. <td height="19"></td>
  421. <td>&nbsp;</td>
  422. <td></td>
  423. <td>&nbsp;</td>
  424. <td>&nbsp;</td>
  425. <td>&nbsp;</td>
  426. <td>&nbsp;</td>
  427. <td>&nbsp;</td>
  428. <td></td>
  429. <td></td>
  430. <td></td>
  431. </tr>
  432. <tr>
  433. <td height="20"></td>
  434. <td colspan="2" valign="top">
  435. <label>
  436. <input type="radio" name="option" id="radio3" value="<?php echo $row1[$y[3]]; ?>" />
  437. </label> </td>
  438. <td colspan="5" rowspan="2" valign="top"><?php echo "<font face=verdana size=3>".$row1[$y[3]]; ?>&nbsp;</td>
  439. <td></td>
  440. <td></td>
  441. <td></td>
  442. </tr>
  443. <tr>
  444. <td height="12"></td>
  445. <td></td>
  446. <td></td>
  447. <td></td>
  448. <td></td>
  449. <td></td>
  450. </tr>
  451. <tr>
  452. <td height="15"></td>
  453. <td></td>
  454. <td></td>
  455. <td></td>
  456. <td></td>
  457. <td></td>
  458. <td></td>
  459. <td></td>
  460. <td></td>
  461. <td></td>
  462. <td></td>
  463. </tr>
  464. <tr>
  465. <td height="20"></td>
  466. <td colspan="2" valign="top">
  467. <label>
  468. <input type="radio" name="option" id="radio4" value="<?php echo $row1[$y[0]]; ?>" />
  469. </label> </td>
  470. <td colspan="5" rowspan="2" valign="top"><?php echo "<font face=verdana size=3>".$row1[$y[0]]; ?>&nbsp;</td>
  471. <td></td>
  472. <td></td>
  473. <td></td>
  474. </tr>
  475. <tr>
  476. <td height="12"></td>
  477. <td></td>
  478. <td></td>
  479. <td></td>
  480. <td></td>
  481. <td></td>
  482. </tr>
  483. <tr>
  484. <td height="13"></td>
  485. <td></td>
  486. <td></td>
  487. <td></td>
  488. <td></td>
  489. <td></td>
  490. <td></td>
  491. <td></td>
  492. <td></td>
  493. <td></td>
  494. <td></td>
  495. </tr>
  496. <tr>
  497. <td height="19"></td>
  498.  
  499. <td colspan="3" rowspan="2" valign="top"><a href="tstqus.php"><input name="BACK" type="submit" class="style11" value="BACK" /></a></td>
  500. <td></td>
  501. <td valign="top"><input name="SUBMIT1" type="button" value="SUBMIT" class="style11" onclick="check();"/></td>
  502. <td>&nbsp;</td>
  503.  
  504.  
  505. </td>
  506. <td><input type="button" value="NEXT" name="NEXT" class="style11" onclick="check1();" /></a></td>
  507. <tr>
  508.  
  509. </tr>
  510. <td></td>
  511. </tr>
  512. <tr>
  513. <td height="14"></td>
  514. <td></td>
  515. <td></td>
  516. <td></td>
  517. <td></td>
  518. <td></td>
  519. <td></td>
  520. <td></td>
  521. </tr>
  522. </table>
  523. </form></td>
  524. <td><!--DWLayoutEmptyCell-->&nbsp;</td>
  525. </tr>
  526.  
  527. <tr>
  528. <td height="37" valign="top"><a href="Org.php"><img src="Images/Orga.jpg" alt="bvnbvn" width="177" height="31" hspace="7" vspace="2" border="1" /></a></td>
  529. <td></td>
  530. <td>&nbsp;</td>
  531. </tr>
  532. <tr>
  533. <td height="15"></td>
  534. <td></td>
  535. <td></td>
  536. </tr>
  537.  
  538. <tr>
  539. <td height="37" valign="top"><a href="Onlinetest.php"><img src="Images/onlinetest.jpg" alt="mm" width="177" height="31" hspace="7" vspace="2" border="1" /></a></td>
  540. <td></td>
  541. <td>&nbsp;</td>
  542. </tr>
  543. <tr>
  544. <td height="19">&nbsp;</td>
  545. <td></td>
  546. <td>&nbsp;</td>
  547. </tr>
  548.  
  549. <tr>
  550. <td height="37" valign="top"><a href="review.php"><img src="Images/Logout.jpg" alt="bnb" width="177" height="31" hspace="7" vspace="2" border="1" /></a></td>
  551. <td></td>
  552. <td>&nbsp;</td>
  553. </tr>
  554. <tr>
  555. <td height="15"></td>
  556. <td></td>
  557. <td></td>
  558. </tr>
  559.  
  560. <tr>
  561. <td height="37" valign="top"><a href="main.php"><img src="Images/Home.jpg" alt="bnbv" width="177" height="31" hspace="7" vspace="2" border="1" /></a></td>
  562. <td></td>
  563. <td>&nbsp;</td>
  564. </tr>
  565. <tr>
  566. <td height="140">&nbsp;</td>
  567. <td></td>
  568. <td>&nbsp;</td>
  569. </tr>
  570. <tr><td height="37" valign="top"><a href="paprfinis.php"><img src="Images/endtst.jpg" alt="bvnbvn" width="90" height="21" hspace="7" vspace="2" border="1" /></a></td></tr>
  571. <tr>
  572. <td height="83">&nbsp;</td>
  573. <td></td>
  574. <td></td>
  575. <td>&nbsp;</td>
  576. <td>&nbsp;</td>
  577. <td>&nbsp;</td>
  578. <td>&nbsp;</td>
  579. <td>&nbsp;</td>
  580. </tr>
  581.  
  582.  
  583. <tr>
  584. <td height="66" valign="top"><img src="Images/CSC.jpg" alt="df" width="202" height="66" /></td>
  585. <td></td>
  586. <td></td>
  587. <td></td>
  588. <td></td>
  589. <td></td>
  590. <td>&nbsp;</td>
  591. <td>&nbsp;</td>
  592. </tr>
  593. <tr>
  594. <td height="3"></td>
  595. <td></td>
  596. <td></td>
  597. <td></td>
  598. <td></td>
  599. <td></td>
  600. <td></td>
  601. <td></td>
  602. </tr>
  603. </table>
  604.  
  605. </body>
  606. </html>
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: serious problem..in online examination ..plz solve that as soon as possible

 
0
  #2
Aug 1st, 2007
I don't think you can do that, unless you can store the elapsed time in a cookie.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,210
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: serious problem..in online examination ..plz solve that as soon as possible

 
0
  #3
Aug 1st, 2007
For security reasons, you should not have control over the user's refresh, forward, and back buttons.

I just realized the utter impossibility of doing this and making it fair.

You do not have control over the following:
- The browser the student has.
- The Internet Service Provider the student subscribes to.
- Whether the ISP burdens users with popups in exchange for free or low-cost service.
- Security settings.
- Firewalls.
- Traffic loading on the ISP.

So I can see some problems:

- The page stops loading in the middle, but the timer starts.

- The page loads, but JavaScript is turned off.

- The page loads except for the script.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC