PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/final.php

https://gitlab.com/javednayeem/grecenter
PHP | 220 lines | 190 code | 18 blank | 12 comment | 58 complexity | 8355506010e1b63d737f50eebb66b9b4 MD5 | raw file
  1. <?php
  2. require_once("includes/function.php");
  3. require_once("includes/db_con.php");
  4. require_once("includes/heder.php");
  5. $test = $_SESSION['test'];
  6. //echo "test variable : " . $test ;
  7. $sec=1;
  8. //INSERT INTO `student_results` (`student_id`, `student_name`, `test_no`, `results_1`, `results_2`, `results_3`, `results_4`, `results_analytical`,)
  9. //VALUES ('3', 'student@student.com', '1', '12', '23', '56', '67', '43')
  10. ?>
  11. <div class="container">
  12. <div class="container">
  13. <div class="col-md-12-result">
  14. <a class="btn btn-lg btn-success" href="gre.php" title="Back to GRE Test">Back to GRE Test</a>
  15. <h4> Your Total Score is: <?php echo $_SESSION['result_one']+$_SESSION['result_three']+$_SESSION['result_tow']+$_SESSION['result_four']+260; ?> </h4>
  16. <h4> Your Verbal Score is: <?php echo $_SESSION['result_one']+$_SESSION['result_three']+130; ?></h4>
  17. <h4> Your Quantitative Score is: <?php echo $_SESSION['result_tow']+$_SESSION['result_four']+130; ?></h4>
  18. <?php
  19. $student_id = $_SESSION["admin_id"];
  20. $student_name = $_SESSION["username"];
  21. $test_no = $_SESSION['test'];
  22. $results_1 = $_SESSION['result_one'];
  23. $results_2 = $_SESSION['result_tow'];
  24. $results_3 = $_SESSION['result_three'];
  25. $results_4 = $_SESSION['result_four'];
  26. $results_analytical = "12";
  27. $query = "INSERT INTO `student_results` ";
  28. $query .= "(`student_id`, `student_name`, `test_no`, `test_token`, `results_1`, `results_2`, `results_3`, `results_4`, `results_analytical`) ";
  29. $query .= " VALUES ";
  30. $query .= "('{$student_id}', '{$student_name}', '{$test_no}', '{$_SESSION["token"]}', '{$results_1}', '{$results_2}', '{$results_3}', '{$results_4}', '{$results_analytical}')";
  31. $admin_set = mysql_query($query);
  32. //$admin = mysql_fetch_assoc($admin_set);
  33. ?>
  34. </div>
  35. </div>
  36. <div class="col-md-12"><a class="btn btn-lg btn-success" href="gre.php" title="Back to GRE Test">Back to GRE Test</a></div>
  37. <div class="col-md-12">
  38. <?php
  39. for($sec=1;$sec<5;$sec++){
  40. if(isset($_SESSION['ques_list_'.$sec])){
  41. $secArray = array();
  42. $secArray = $_SESSION['ques_list_'.$sec];
  43. /*echo '<pre>';
  44. print_r($secArray);
  45. echo '</pre>';*/
  46. echo '<h2 class="text-center">Section '.$sec.'</h2>';
  47. $i=0;
  48. if(!empty($secArray['ques_id'])){
  49. for($i=0;$i<count($secArray['ques_id']);$i++){
  50. $id = $secArray['ques_id'][$i];
  51. $ques_type = $secArray['ques_type'][$i];
  52. if($ques_type == 'mul'){
  53. $ans_given = array();
  54. }
  55. $ans_given = $secArray['ques_ans'][$i];
  56. $query = mysql_query("SELECT * FROM gre WHERE `test`= $test AND `section` = $sec AND `id` = $id");
  57. while($result = mysql_fetch_array($query)){
  58. echo '<div class="col-md-12">';
  59. // if question is single
  60. if($ques_type == 'sin'){
  61. $question_body = $result['question_body'];
  62. if($result['qtype'] == 'sentence_eq' && empty($question_body)){
  63. if(!empty($result['body_img'])){
  64. $question_body = '<img src="img/'.$result['body_img'].'" />';
  65. }
  66. }
  67. echo '<p><span>'.($i+1).'. </span>'.$question_body.'</p>';
  68. if($result['qtype'] == 'menual_input'){
  69. if(($result['ans1']) != 0){
  70. if($result['ans1'] == $ans_given){
  71. echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$ans_given.'</div>';
  72. }
  73. else {
  74. echo '<div class="red-bg"><strong>Your Answer:</strong> '.$ans_given.'</div>';
  75. echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['ans1'].'</div>';
  76. }
  77. }
  78. if($result['single_blank-1'] != 0){
  79. if($result['single_blank-1'] == $ans_given){
  80. echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$ans_given.'</div>';
  81. }
  82. else {
  83. echo '<div class="red-bg"><strong>Your Answer:</strong> '.$ans_given.'</div>';
  84. echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['single_blank-1'].'</div>';
  85. }
  86. }
  87. }
  88. else {
  89. if($result['ans1'] == $ans_given){
  90. echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
  91. }
  92. else {
  93. echo '<div class="red-bg"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
  94. echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['single_blank-'.$result['ans1']].'</div>';
  95. }
  96. }
  97. }
  98. // if question is double
  99. else if($ques_type == 'dub'){
  100. $answer = array();
  101. $answer = explode(',', $ans_given);
  102. echo '<p><span>'.($i+1).'. </span>'.$result['question_body'].'</p>';
  103. if($result['ans1'] == $answer[0]){
  104. echo '<div class="green-bg"><strong>Your Answer (i):</strong> '.$result['single_blank-'.$answer[0]].'</div>';
  105. }
  106. else {
  107. echo '<div class="red-bg"><strong>Your Answer (i):</strong> '.$result['single_blank-'.$answer[0]].'</div>';
  108. echo '<div class="green-bg"><strong>Correct Answer (i):</strong> '.$result['single_blank-'.$result['ans1']].'</div>';
  109. }
  110. if($result['ans2'] == $answer[1]){
  111. echo '<div class="green-bg margin-btm"><strong>Your Answer (ii):</strong> '.$result['single_blank-'.$answer[1]].'</div>';
  112. }
  113. else {
  114. echo '<div class="red-bg"><strong>Your Answer (ii):</strong> '.$result['single_blank-'.$answer[1]].'</div>';
  115. echo '<div class="green-bg margin-btm"><strong>Correct Answer (ii):</strong> '.$result['single_blank-'.$result['ans2']].'</div>';
  116. }
  117. }
  118. // if question is triple
  119. else if($ques_type == 'thr'){
  120. $answer = array();
  121. $answer = explode(',', $ans_given);
  122. echo '<p><span>'.($i+1).'. </span>'.$result['question_body'].'</p>';
  123. $count = 1;
  124. for($a = 0; $a < 3; $a++){
  125. if($result['ans'.$count] == $answer[$a]){
  126. echo '<div class="green-bg"><strong>Your Answer '.$count.':</strong> '.$result['single_blank-'.$answer[$a]].'</div>';
  127. }
  128. else {
  129. echo '<div class="red-bg"><strong>Your Answer '.$count.':</strong> '.$result['single_blank-'.$answer[$a]].'</div>';
  130. echo '<div class="green-bg"><strong>Correct Answer '.$count.':</strong> '.$result['single_blank-'.$result['ans'.$count]].'</div>';
  131. }
  132. $count++;
  133. }
  134. }
  135. // if question is multiple
  136. else if($ques_type == 'mul'){
  137. echo '<p><span>'.($i+1).'. </span>'.$result['question_body'].'</p>';
  138. $numOfAns = 0;
  139. $numOfAnsGiven = sizeof($ans_given);
  140. $answer = array();
  141. if($result['ans1'] !=0){
  142. $answer[] = $result['ans1'];
  143. $numOfAns += 1;
  144. }
  145. if($result['ans2'] !=0){
  146. $answer[] = $result['ans2'];
  147. $numOfAns += 1;
  148. }
  149. if($result['ans3'] !=0){
  150. $answer[] = $result['ans3'];
  151. $numOfAns += 1;
  152. }
  153. echo '<strong>Your Answer:</strong>';
  154. foreach($ans_given as $value){
  155. if(in_array($value, $answer)){
  156. echo '<div class="green-bg">'.$result['single_blank-'.$value].'</div>';
  157. }
  158. else {
  159. echo '<div class="red-bg">'.$result['single_blank-'.$value].'</div>';
  160. }
  161. }
  162. echo '<strong>Correct Answer:</strong>';
  163. foreach($answer as $value){
  164. echo '<div class="green-bg">'.$result['single_blank-'.$value].'</div>';
  165. }
  166. }
  167. // if question is body_choice
  168. if($ques_type == 'bod'){
  169. if($result['ans1'] == $ans_given){
  170. echo '<div class="green-bg margin-btm"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
  171. }
  172. else {
  173. echo '<div class="red-bg"><strong>Your Answer:</strong> '.$result['single_blank-'.$ans_given].'</div>';
  174. echo '<div class="green-bg margin-btm"><strong>Correct Answer:</strong> '.$result['single_blank-'.$result['ans1']].'</div>';
  175. }
  176. }
  177. echo '</div>';
  178. }
  179. }
  180. }
  181. }
  182. }
  183. ?>
  184. </div>
  185. </div>
  186. <?php // exit(); ?>
  187. <div class="container">
  188. <div class="col-md-12">
  189. <h4> Your Verbal Score is: <?php echo $_SESSION['result_one']+$_SESSION['result_three']+130; ?></h4>
  190. <h4> Your Quantitative Score is: <?php echo $_SESSION['result_tow']+$_SESSION['result_four']+130; ?></h4>
  191. </div>
  192. </div>
  193. <?php
  194. $now = time(); // checking the time now when home page starts
  195. if($now > $_SESSION['expire'])
  196. {
  197. session_destroy();
  198. echo "<script>alert(<div class='login_result'>Your session has expire ! <a href='login.php'>Click Here to Login</a></div>)</script>";
  199. }
  200. ?>
  201. </body>
  202. </html>