result.php 2.3 KB

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