result.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. if (empty($origin)) {
  20. $origin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : null;
  21. }
  22. $id = isset($_REQUEST['id']) ? intval($_GET['id']) : null; //exe id
  23. $show_headers = isset($_REQUEST['show_headers']) ? intval($_REQUEST['show_headers']) : null; //exe id
  24. if ($origin == 'learnpath') {
  25. $show_headers = false;
  26. }
  27. api_protect_course_script($show_headers);
  28. if (empty($id)) {
  29. api_not_allowed($show_headers);
  30. }
  31. $is_allowedToEdit = api_is_allowed_to_edit(null,true) || $is_courseTutor;
  32. //Getting results from the exe_id. This variable also contain all the information about the exercise
  33. $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
  34. //No track info
  35. if (empty($track_exercise_info)) {
  36. api_not_allowed($show_headers);
  37. }
  38. $exercise_id = $track_exercise_info['exe_exo_id'];
  39. $student_id = $track_exercise_info['exe_user_id'];
  40. $current_user_id = api_get_user_id();
  41. $objExercise = new Exercise();
  42. if (!empty($exercise_id)) {
  43. $objExercise->read($exercise_id);
  44. }
  45. //Only users can see their own results
  46. if (!$is_allowedToEdit) {
  47. if ($student_id != $current_user_id) {
  48. api_not_allowed($show_headers);
  49. }
  50. }
  51. if ($show_headers) {
  52. $interbreadcrumb[] = array("url" => "exercice.php","name" => get_lang('Exercices'));
  53. $interbreadcrumb[] = array("url" => "#","name" => get_lang('Result'));
  54. $this_section = SECTION_COURSES;
  55. Display::display_header();
  56. } else {
  57. Display::display_reduced_header();
  58. }
  59. $objExercise->displayQuestionListByAttempt($id, false);
  60. Display::display_footer();