exercise_history.php 3.4 KB

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