result.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Shows the exercise results.
  6. *
  7. * @author Julio Montoya - Simple exercise result page
  8. */
  9. require_once __DIR__.'/../inc/global.inc.php';
  10. $id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
  11. $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
  12. $origin = api_get_origin();
  13. if ($origin == 'learnpath') {
  14. $show_headers = false;
  15. }
  16. api_protect_course_script($show_headers);
  17. if (empty($id)) {
  18. api_not_allowed($show_headers);
  19. }
  20. $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor;
  21. // Getting results from the exe_id. This variable also contain all the information about the exercise
  22. $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
  23. // No track info
  24. if (empty($track_exercise_info)) {
  25. api_not_allowed($show_headers);
  26. }
  27. $exercise_id = $track_exercise_info['exe_exo_id'];
  28. $student_id = $track_exercise_info['exe_user_id'];
  29. $current_user_id = api_get_user_id();
  30. $objExercise = new Exercise();
  31. if (!empty($exercise_id)) {
  32. $objExercise->read($exercise_id);
  33. }
  34. // Only users can see their own results
  35. if (!$is_allowedToEdit) {
  36. if ($student_id != $current_user_id) {
  37. api_not_allowed($show_headers);
  38. }
  39. }
  40. $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
  41. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
  42. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
  43. if ($show_headers) {
  44. $interbreadcrumb[] = [
  45. "url" => "exercise.php?".api_get_cidreq(),
  46. "name" => get_lang('Exercises'),
  47. ];
  48. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Result')];
  49. $this_section = SECTION_COURSES;
  50. Display::display_header();
  51. } else {
  52. $htmlHeadXtra[] = '<style>
  53. body { background: none;}
  54. </style>';
  55. Display::display_reduced_header();
  56. }
  57. $message = Session::read('attempt_remaining');
  58. Session::erase('attempt_remaining');
  59. ExerciseLib::displayQuestionListByAttempt(
  60. $objExercise,
  61. $id,
  62. false,
  63. $message
  64. );
  65. if ($show_headers) {
  66. Display::display_footer();
  67. } else {
  68. Display::display_reduced_footer();
  69. }