result.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. */
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. $id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
  12. $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
  13. $origin = api_get_origin();
  14. $class = 'result-body';
  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. $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
  43. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
  44. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
  45. if ($show_headers) {
  46. $interbreadcrumb[] = array(
  47. "url" => "exercise.php?".api_get_cidreq(),
  48. "name" => get_lang('Exercises')
  49. );
  50. $interbreadcrumb[] = array("url" => "#", "name" => get_lang('Result'));
  51. $this_section = SECTION_COURSES;
  52. Display::display_header();
  53. } else {
  54. $htmlHeadXtra[] = '<style>
  55. body { background: none;}
  56. </style>';
  57. Display::display_reduced_header();
  58. }
  59. $message = Session::read('attempt_remaining');
  60. Session::erase('attempt_remaining');
  61. echo '<div class="'.$class.'">';
  62. ExerciseLib::displayQuestionListByAttempt(
  63. $objExercise,
  64. $id,
  65. false,
  66. $message
  67. );
  68. echo '</div>';
  69. if ($show_headers) {
  70. Display::display_footer();
  71. }