result.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Shows the exercise results
  5. *
  6. * @author Julio Montoya Armas - Simple exercise result page
  7. *
  8. */
  9. // name of the language file that needs to be included
  10. $language_file = array('exercice');
  11. // including additional libraries
  12. require_once 'exercise.class.php';
  13. require_once 'question.class.php';
  14. require_once 'answer.class.php';
  15. require_once '../inc/global.inc.php';
  16. require_once 'exercise.lib.php';
  17. if (empty($origin)) {
  18. $origin = $_REQUEST['origin'];
  19. }
  20. $id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
  21. $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
  22. if ($origin == 'learnpath') {
  23. $show_headers = false;
  24. }
  25. api_protect_course_script($show_headers);
  26. if (empty($id)) {
  27. api_not_allowed($show_headers);
  28. }
  29. $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
  30. //Getting results from the exe_id. This variable also contain all the information about the exercise
  31. $track_exercise_info = get_exercise_track_exercise_info($id);
  32. //No track info
  33. if (empty($track_exercise_info)) {
  34. api_not_allowed($show_headers);
  35. }
  36. $exercise_id = $track_exercise_info['exe_exo_id'];
  37. $student_id = $track_exercise_info['exe_user_id'];
  38. $current_user_id = api_get_user_id();
  39. $objExercise = new Exercise();
  40. if (!empty($exercise_id)) {
  41. $objExercise->read($exercise_id);
  42. }
  43. //Only users can see their own results
  44. if (!$is_allowedToEdit) {
  45. if ($student_id != $current_user_id) {
  46. api_not_allowed($show_headers);
  47. }
  48. }
  49. if ($show_headers) {
  50. $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
  51. $interbreadcrumb[] = array("url" => "#","name" => get_lang('Result'));
  52. $this_section = SECTION_COURSES;
  53. Display::display_header();
  54. } else {
  55. $htmlHeadXtra[] = "
  56. <style>
  57. body { background: none;}
  58. </style>
  59. ";
  60. Display::display_reduced_header();
  61. }
  62. display_question_list_by_attempt($objExercise, $id, false);
  63. if ($show_headers) {
  64. Display::display_footer();
  65. }