result.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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']) ? (int) $_GET['id'] : 0; // exe id
  11. $show_headers = isset($_REQUEST['show_headers']) ? (int) $_REQUEST['show_headers'] : null;
  12. $origin = api_get_origin();
  13. if (in_array($origin, ['learnpath', 'embeddable'])) {
  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. if (empty($objExercise)) {
  35. api_not_allowed($show_headers);
  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 (!empty($objExercise->getResultAccess())) {
  47. /*$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
  48. $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
  49. $htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
  50. $htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');*/
  51. }
  52. $htmlHeadXtra[] = api_get_build_js('exercise.js');
  53. if ($show_headers) {
  54. $interbreadcrumb[] = [
  55. 'url' => 'exercise.php?'.api_get_cidreq(),
  56. 'name' => get_lang('Tests'),
  57. ];
  58. $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Result')];
  59. $this_section = SECTION_COURSES;
  60. Display::display_header();
  61. } else {
  62. $htmlHeadXtra[] = '<style>
  63. body { background: none;}
  64. </style>';
  65. Display::display_reduced_header();
  66. }
  67. $message = Session::read('attempt_remaining');
  68. Session::erase('attempt_remaining');
  69. ExerciseLib::displayQuestionListByAttempt(
  70. $objExercise,
  71. $id,
  72. false,
  73. $message
  74. );
  75. if ($show_headers) {
  76. Display::display_footer();
  77. } else {
  78. Display::display_reduced_footer();
  79. }