reviewResults.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. $root = $_SERVER['DOCUMENT_ROOT'];
  3. include($root . "/util/session.php");//checks that the user is logged in
  4. include($root . "/util/privilege_check.php");
  5. checkPrivilege("student");
  6. if (isset($_POST['chapterID'])) {
  7. $actualSubject = $_POST['subjectID'];
  8. $actualChapter = $_POST['chapterID'];
  9. $username = mysqli_real_escape_string($db,$_SESSION['login_user']);
  10. $query = "SELECT * FROM results_info WHERE subjectID='$actualSubject' and chapterID = '$actualChapter' and studentUser = '$username'";
  11. $result = mysqli_query($db,$query);
  12. $i = 1;
  13. }else{
  14. echo 'Error in reviewResults - No POST reached';
  15. }
  16. ?>
  17. <html>
  18. <head>
  19. <title>Review exam</title>
  20. <link rel="stylesheet" type="text/css" href="studentStyle.css">
  21. <style>
  22. #results_info {
  23. font-family: Arial, Helvetica, sans-serif;
  24. border-collapse: collapse;
  25. width: 100%;
  26. font-size: 24px;
  27. }
  28. #results_info td, #results_info th {
  29. border: 1px solid #ddd;
  30. padding: 8px;
  31. text-align: center;
  32. background-color: white;
  33. }
  34. #results_info th {
  35. padding-top: 12px;
  36. padding-bottom: 12px;
  37. text-align: center;
  38. background-color: #4CAF50;
  39. color: white;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. <?php
  45. include($root . "/student/header.php")
  46. ?>
  47. <li><a href="/student/checkResults.php">Back</a></li>
  48. <table border="1px" id="results_info">
  49. <thead>
  50. <tr>
  51. <th>Question number</th>
  52. <th>Question type</th>
  53. <th>Question description</th>
  54. <th>Answer A</th>
  55. <th>Answer B</th>
  56. <th>Answer C</th>
  57. <th>Answer D</th>
  58. <th>Your answer</th>
  59. <th>Correct answer</th>
  60. <th>Points obtained</th>
  61. </tr>
  62. </thead>
  63. <tbody>
  64. <?php
  65. while($row=mysqli_fetch_assoc($result)){
  66. $questionID = $row['questionID'];
  67. $query2 = "SELECT * FROM questions WHERE questionID = '$questionID'";
  68. $result2 = mysqli_query($db,$query2);
  69. $row2 = mysqli_fetch_assoc($result2);?>
  70. <tr>
  71. <td><?php echo $i; ?></td>
  72. <td><?php echo $row2['questionType'];?></td>
  73. <td><?php echo $row2['questionDescription'];?></td>
  74. <td><?php echo $row2['descriptionAnswerA'];?></td>
  75. <td><?php echo $row2['descriptionAnswerB'];?></td>
  76. <td><?php echo $row2['descriptionAnswerC'];?></td>
  77. <td><?php echo $row2['descriptionAnswerD'];?></td>
  78. <td><?php echo $row['studentAnswer'];?></td>
  79. <td><?php echo $row['correctAnswer'];?></td>
  80. <?php if($row['studentAnswer'] == $row['correctAnswer']){?>
  81. <td><?php echo $row2['correctPoints'];?></td>
  82. <?php }else{?>
  83. <td><?php echo '-'. $row2['assHolePoints'];?></td>
  84. <?php }?>
  85. </tr>
  86. <?php $i = $i+1;}?>
  87. </tbody>
  88. </table>
  89. <?php
  90. include($root . "/student/footer.php")
  91. ?>
  92. </body>
  93. </html>