exercise_history.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Exercise list: This script shows the list of exercises for administrators and students.
  5. *
  6. * @author Olivier Brouckaert, original author
  7. * @author Denes Nagy, HotPotatoes integration
  8. * @author Wolfgang Schneider, code/html cleanup
  9. */
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. $this_section = SECTION_COURSES;
  12. api_protect_course_script(true);
  13. $show = isset($_GET['show']) && $_GET['show'] === 'result' ? 'result' : 'test';
  14. /* Constants and variables */
  15. $is_allowedToEdit = api_is_allowed_to_edit(null, true);
  16. $is_tutor = api_is_allowed_to_edit(true);
  17. if (!$is_allowedToEdit) {
  18. header('Location: '.api_get_path(WEB_CODE_PATH).'exercise/exercise.php?'.api_get_cidreq());
  19. exit;
  20. }
  21. $interbreadcrumb[] = [
  22. 'url' => 'exercise_report.php?'.api_get_cidreq(),
  23. 'name' => get_lang('Tests'),
  24. ];
  25. $interbreadcrumb[] = [
  26. 'url' => 'exercise_report.php?filter=2&'.api_get_cidreq(),
  27. 'name' => get_lang('Learner score'),
  28. ];
  29. $interbreadcrumb[] = [
  30. 'url' => 'exercise_history.php?exe_id='.intval($_GET['exe_id']).'&'.api_get_cidreq(),
  31. 'name' => get_lang('Details'),
  32. ];
  33. $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
  34. $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
  35. $TBL_EXERCISES_QUESTION = Database::get_course_table(TABLE_QUIZ_QUESTION);
  36. $TBL_TRACK_ATTEMPT_RECORDING = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
  37. Display::display_header($nameTools, get_lang('Test'));
  38. if (isset($_GET['message'])) {
  39. if (in_array($_GET['message'], ['ExerciseEdited'])) {
  40. $my_message_history = Security::remove_XSS($_GET['message']);
  41. echo Display::return_message(get_lang($my_message_history), 'confirm');
  42. }
  43. }
  44. echo '<div class="actions">';
  45. echo '<a href="exercise_report.php?'.api_get_cidreq().'&filter=2">'.
  46. Display::return_icon('back.png', get_lang('Back to result list'), '', ICON_SIZE_MEDIUM).'</a>';
  47. echo '</div>';
  48. ?>
  49. <table class="data_table">
  50. <tr class="row_odd">
  51. <th><?php echo get_lang('Question'); ?></th>
  52. <th width="50px"><?php echo get_lang('Value'); ?></th>
  53. <th><?php echo get_lang('Feedback'); ?></th>
  54. <th><?php echo get_lang('Author'); ?></th>
  55. <th width="160px"><?php echo get_lang('Date'); ?></th>
  56. </tr>
  57. <?php
  58. $sql = "SELECT *, quiz_question.question, firstname, lastname
  59. FROM $TBL_TRACK_ATTEMPT_RECORDING t, $TBL_USER,
  60. $TBL_EXERCISES_QUESTION quiz_question
  61. WHERE
  62. quiz_question.id = question_id AND
  63. user_id = author AND
  64. exe_id = '".(int) $_GET['exe_id']."'
  65. ORDER BY position";
  66. $query = Database::query($sql);
  67. while ($row = Database::fetch_array($query)) {
  68. echo '<tr';
  69. if ($i % 2 == 0) {
  70. echo 'class="row_odd"';
  71. } else {
  72. echo 'class="row_even"';
  73. }
  74. echo '>';
  75. echo '<td>'.$row['question'].'</td>';
  76. echo '<td>'.$row['marks'].'</td>';
  77. if (!empty($row['teacher_comment'])) {
  78. echo '<td>'.$row['teacher_comment'].'</td>';
  79. } else {
  80. echo '<td>'.get_lang('Without comment').'</td>';
  81. }
  82. echo '<td>'.(empty($row['firstname']) && empty($row['lastname']) ? '<i>'.get_lang('Original value').'</i>' : api_get_person_name($row['firstname'], $row['lastname'])).'</td>';
  83. echo '<td>'.api_convert_and_format_date($row['insert_date'], DATE_TIME_FORMAT_LONG).'</td>';
  84. echo '</tr>';
  85. }
  86. echo '</table>';
  87. Display::display_footer();