result.php 2.0 KB

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