result.php 1.7 KB

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