exercise_history.php 3.5 KB

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