result.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Shows the exercise results
  5. *
  6. * @author Julio Montoya Armas - Simple exercise result page
  7. *
  8. */
  9. // name of the language file that needs to be included
  10. $language_file = array('exercice');
  11. require_once '../inc/global.inc.php';
  12. if (empty($origin)) {
  13. $origin = $_REQUEST['origin'];
  14. }
  15. $id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
  16. $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
  17. if ($origin == 'learnpath') {
  18. $show_headers = false;
  19. }
  20. api_protect_course_script($show_headers);
  21. if (empty($id)) {
  22. api_not_allowed($show_headers);
  23. }
  24. $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
  25. //Getting results from the exe_id. This variable also contain all the information about the exercise
  26. $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
  27. //No track info
  28. if (empty($track_exercise_info)) {
  29. api_not_allowed($show_headers);
  30. }
  31. $exercise_id = $track_exercise_info['exe_exo_id'];
  32. $student_id = $track_exercise_info['exe_user_id'];
  33. $current_user_id = api_get_user_id();
  34. $objExercise = new Exercise();
  35. if (!empty($exercise_id)) {
  36. $objExercise->read($exercise_id);
  37. }
  38. //Only users can see their own results
  39. if (!$is_allowedToEdit) {
  40. if ($student_id != $current_user_id) {
  41. api_not_allowed($show_headers);
  42. }
  43. }
  44. if ($show_headers) {
  45. $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
  46. $interbreadcrumb[] = array("url" => "#","name" => get_lang('Result'));
  47. $this_section = SECTION_COURSES;
  48. Display::display_header();
  49. } else {
  50. Display::display_reduced_header();
  51. }
  52. ExerciseLib::display_question_list_by_attempt($objExercise, $id, false);
  53. if ($show_headers) {
  54. Display::display_footer();
  55. }