result.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if ($origin == 'learnpath') {
  15. $show_headers = false;
  16. }
  17. api_protect_course_script($show_headers);
  18. if (empty($id)) {
  19. api_not_allowed($show_headers);
  20. }
  21. $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor;
  22. // Getting results from the exe_id. This variable also contain all the information about the exercise
  23. $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
  24. // No track info
  25. if (empty($track_exercise_info)) {
  26. api_not_allowed($show_headers);
  27. }
  28. $exercise_id = $track_exercise_info['exe_exo_id'];
  29. $student_id = $track_exercise_info['exe_user_id'];
  30. $current_user_id = api_get_user_id();
  31. $objExercise = new Exercise();
  32. if (!empty($exercise_id)) {
  33. $objExercise->read($exercise_id);
  34. }
  35. // Only users can see their own results
  36. if (!$is_allowedToEdit) {
  37. if ($student_id != $current_user_id) {
  38. api_not_allowed($show_headers);
  39. }
  40. }
  41. $htmlHeadXtra[] = api_get_css('js/hotspot/css/hotspot.css');
  42. $htmlHeadXtra[] = api_get_js('js/hotspot/js/hotspot.js');
  43. if ($show_headers) {
  44. $interbreadcrumb[] = array(
  45. "url" => "exercise.php?".api_get_cidreq(),
  46. "name" => get_lang('Exercises')
  47. );
  48. $interbreadcrumb[] = array("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. }