PageRenderTime 61ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/take_up.php

https://bitbucket.org/sadhana_rani_sankar/aces
PHP | 285 lines | 236 code | 39 blank | 10 comment | 30 complexity | 5d69a94ce3882553079855e1b80d2195 MD5 | raw file
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', '1');
  4. require_once ('Auth_stu.php');
  5. session_start();
  6. $auth = new Auth_stu();
  7. if (!isset($_SESSION['user_id']))
  8. {
  9. //Not logged in, send to login page.
  10. header( 'Location: login.php' );
  11. }
  12. else
  13. {
  14. //Check we have the right user
  15. $logged_in = $auth->checkSession();
  16. if(empty($logged_in)){
  17. //Bad session, ask to login
  18. $auth->logout();
  19. header( 'Location: login.php' );
  20. }
  21. else
  22. {
  23. //User is logged in, show the page
  24. ?>
  25. <!DOCTYPE html>
  26. <html>
  27. <head>
  28. <title>ACES : HOME</title>
  29. <!-- Include the bootstrap stylesheets -->
  30. <link rel="stylesheet" href="bootstrapnew.css"/>
  31. </head>
  32. <body>
  33. <!-- Navbar
  34. ================================================== -->
  35. <div class="navbar navbar-fixed-top">
  36. <div class="navbar-inner">
  37. <div class="container">
  38. <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
  39. <span class="icon-bar"></span>
  40. <span class="icon-bar"></span>
  41. <span class="icon-bar"></span>
  42. </a>
  43. <a class="brand" href="http://www.amrita.edu/">AMRITA</a>
  44. <div class="nav-collapse" id="main-menu">
  45. </li>
  46. </ul>
  47. </li>
  48. </ul>
  49. <ul class="nav pull-right" id="main-menu-right">
  50. <li><a rel="tooltip" href="#"><?php echo date("d.m.Y") ;?> <i class="icon-share-alt"></i></a></li>
  51. <li><a rel="tooltip" href="#">Welcome <?php echo ''. $_SESSION['name'] ;?> <i class="icon-share-alt"></i></a></li>
  52. <li><a rel="tooltip" href="/logout_stu.php">Logout <i class="icon-share-alt"></i></a></li>
  53. </ul>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="container">
  59. <div class="container">
  60. <p> </p>
  61. <h1 style="font-size:46px" align="center" >&nbsp;</h1>
  62. <h1 style="font-size:46px" align="center" >&nbsp;</h1>
  63. <h1 style="font-size:46px" align="center" >ACES</h1>
  64. <h4 align="center"> Automated Code Evaluation System</h4>
  65. <p></p>
  66. <h6 align="left">AMRITA SCHOOL OF ENGINEERING</h6>
  67. <h6 align="left" >COIMBATORE <small></h6>
  68. <!-- Forms
  69. ================================================== -->
  70. <section id="forms">
  71. <div class="page-header">
  72. <h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tests Available</h1>
  73. </div>
  74. <div class="row">
  75. <div class="span10 offset1">
  76. <form class="form-horizontal well" action="mcq_score.php" method="post" enctype="multipart/form-data">
  77. <fieldset>
  78. <?php
  79. if(isset($_POST['submit']))
  80. { if(!isset($_POST['sel'])) {echo 'You need to select a test.'; exit;}
  81. $selected=$_POST['sel'];
  82. $array=array();
  83. $auth->connect();
  84. $query=mysql_query("SELECT start_date,start_time,duration FROM test WHERE test_id='$selected'"); // make changes
  85. if(!$query) {echo 'error'; exit; }
  86. while($row=mysql_fetch_array($query))
  87. {
  88. $date=$row['start_date'];
  89. $time=$row['start_time'];
  90. $duration=$row['duration'];
  91. }
  92. //echo $duration."<br/>";
  93. $str=$date.' '.$time.'+'.$duration;
  94. if (($timestamp = strtotime($str)) == false) {
  95. echo "The string ($str) is bogus";
  96. } else {
  97. $t=date('m/d/Y h:i:s A', $timestamp);
  98. }
  99. $begin=strtotime($str."-".$duration);
  100. $beg=date('m/d/Y h:i:s A', $begin);
  101. //echo 'Test_start :'.$beg; ?>
  102. <?php
  103. $details=array();
  104. array_push($details,$selected);
  105. $r=mysql_query("SELECT * FROM test WHERE test_id='$selected'");
  106. if(!$r) { echo 'error'; exit;}
  107. // echo 'TEST DETAILS:'; ?> <?php
  108. while($row=mysql_fetch_array($r))
  109. {
  110. $title=$row['title'];
  111. //echo 'Title: '.$row['title'];
  112. $duration=$row['duration'];
  113. // echo 'Duration :'.$row['duration'] ;
  114. $start=$row['start_date'];
  115. // echo 'Start Date :'.$row['start_date'];
  116. }
  117. ?>
  118. <br/>
  119. <legend> <?php echo $title?> </legend>
  120. <label>Start Time &nbsp;:<?php echo $time;?></label>
  121. <label>Duration &nbsp;:<?php echo $duration;?></label>
  122. <script type="text/javascript" language="JavaScript">
  123. TargetDate= <?= json_encode($t) ?>;
  124. StartDate=<?= json_encode($beg) ?>;
  125. CountActive = true;
  126. CountStepper = -1;
  127. LeadingZero = true;
  128. DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
  129. FinishMessage = "It is finally here!";
  130. function calcage(secs, num1, num2) {
  131. s = ((Math.floor(secs/num1))%num2).toString();
  132. if (LeadingZero && s.length < 2)
  133. s = "0" + s;
  134. return "<b>" + s + "</b>";
  135. }
  136. function CountBack(secs) {
  137. if (secs < 0) {
  138. document.getElementById("cntdwn").innerHTML = FinishMessage;
  139. return;
  140. }
  141. DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
  142. DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
  143. DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
  144. DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));
  145. document.getElementById("cntdwn").innerHTML = DisplayStr;
  146. if (CountActive)
  147. setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
  148. }
  149. function putspan(backcolor, forecolor) {
  150. document.write("<span id='cntdwn' align='right' style='background-color:" + backcolor +
  151. "; color:" + forecolor + "'></span>");
  152. }
  153. if (typeof(BackColor)=="undefined")
  154. BackColor = "#f5f5f5";
  155. if (typeof(ForeColor)=="undefined")
  156. ForeColor= "black";
  157. if (typeof(TargetDate)=="undefined")
  158. TargetDate = "12/31/2020 5:00 AM";
  159. if (typeof(DisplayFormat)=="undefined")
  160. DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
  161. if (typeof(CountActive)=="undefined")
  162. CountActive = true;
  163. if (typeof(FinishMessage)=="undefined")
  164. FinishMessage = "";
  165. if (typeof(CountStepper)!="number")
  166. CountStepper = -1;
  167. if (typeof(LeadingZero)=="undefined")
  168. LeadingZero = true;
  169. CountStepper = Math.ceil(CountStepper);
  170. if (CountStepper == 0)
  171. CountActive = false;
  172. var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
  173. putspan(BackColor, ForeColor);
  174. var dthen = new Date(TargetDate);
  175. var dnow = new Date(StartDate);
  176. if(CountStepper>0)
  177. ddiff = new Date(dnow-dthen);
  178. else
  179. ddiff = new Date(dthen-dnow);
  180. gsecs = Math.floor(ddiff.valueOf()/1000);
  181. CountBack(gsecs);
  182. </script>
  183. <br/>
  184. <br/>
  185. <p>
  186. <?php
  187. $r=mysql_query("SELECT ques_id FROM test_feed WHERE test_id='$selected'");
  188. if(!$r) { echo 'error'; exit;}
  189. while($row=mysql_fetch_array($r))
  190. {
  191. array_push($array,$row['ques_id']);
  192. array_push($details,$row['ques_id']);
  193. }
  194. $num=count($array);
  195. $count1=1;
  196. for($i=0;$i<$num;$i++)
  197. { $j=$i+1;
  198. $r=mysql_query("SELECT * FROM ques_pool WHERE ques_id='$array[$i]'");
  199. if(!$r) {echo 'error' ; exit; }
  200. while($row=mysql_fetch_array($r))
  201. {
  202. ?>
  203. <br/>
  204. <label> Question <?php echo $j ?></label><div control="label"> <label align='right'> Marks <?php echo $row['max_marks'] ?> Neg Marks <?php echo $row['neg_marks'] ?></label></div> <label> <?php echo $row['ques'] ?> </label><br/>
  205. <?php
  206. $r1=mysql_query("SELECT * FROM option_feed WHERE ques_id='$row[ques_id]'");
  207. if(!$r1) {echo 'error' ; exit; }
  208. while($row1=mysql_fetch_array($r1))
  209. {
  210. ?>
  211. <input type="radio" name="<?php echo $count1 ?>" value="<?php echo $row1['option_no']?>"/> <?php echo $row1['option1']?>
  212. <br />
  213. <?php
  214. }
  215. ?>
  216. </p>
  217. <?php
  218. $count1++;
  219. }
  220. }
  221. }
  222. $_SESSION['det']=implode(',',$details);
  223. ?>
  224. <div class="form-actions">
  225. <input type="submit" class="btn btn-primary" name="submit" value="Submit for evaluation"/>
  226. </div>
  227. </fieldset>
  228. </form>
  229. </div>
  230. </div>
  231. </section>
  232. <!-- Footer
  233. ================================================== -->
  234. <hr>
  235. <footer id="footer">
  236. <p class="pull-right"><a href="#">Back to top</a></p>
  237. <div class="links"></div>
  238. Made by <a href="http://www.amrita.edu">Amrita</a>. Contact him <a href="mailto:amrita.edu">hello@admin_asec</a>.<br/>
  239. Based on <a target="_blank" href="http://twitter.github.com/bootstrap/">Bootstrap</a>. Icons from <a target="_blank" href="http://glyphicons.com/">Glyphicons</a>. Web fonts from <a target="_blank" href="http://www.google.com/webfonts">Google</a>.</p>
  240. </footer>
  241. </body>
  242. </html>
  243. <?php
  244. }
  245. }
  246. ?>