exercise_jump.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Sets needed course variables and then jumps to the exercises result page.
  5. * This intermediate page is needed because the user is not inside a course
  6. * when visiting the gradebook, and several course scripts rely on these
  7. * variables.
  8. * Most code here is ripped from /main/course_home/course_home.php
  9. * @author Bert Steppé
  10. * @package chamilo.gradebook
  11. */
  12. require_once '../inc/global.inc.php';
  13. api_block_anonymous_users();
  14. $this_section=SECTION_COURSES;
  15. $course_id = api_get_course_int_id();
  16. $course_info = api_get_course_info_by_id($course_id);
  17. $course_title = $course_info['title'];
  18. $course_code = $return_result['code'];
  19. $gradebook = Security::remove_XSS($_GET['gradebook']);
  20. $session_id = api_get_session_id();
  21. $cidReq = Security::remove_XSS($_GET['cidReq']);
  22. $type = Security::remove_XSS($_GET['type']);
  23. $doExerciseUrl = api_get_path(WEB_CODE_PATH).'exercice/overview.php?session_id='.$session_id.'&cidReq='.$cidReq.'&gradebook='.$gradebook.'&origin=&learnpath_id=&learnpath_item_id=&exerciseId='.intval($_GET['doexercise']);
  24. // no support for hot potatoes
  25. if ($type == LINK_HOTPOTATOES) {
  26. $doExerciseUrl = api_get_path(WEB_CODE_PATH).'exercice/exercice.php?session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq);
  27. }
  28. $_course['name'] = $course_title;
  29. $_course['official_code'] = $course_code;
  30. if (isset($_GET['doexercise'])) {
  31. header('Location: '.$doExerciseUrl);
  32. exit;
  33. } else {
  34. $url = api_get_path(WEB_CODE_PATH).'exercice/overview.php?session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq);
  35. if (isset($_GET['gradebook'])) {
  36. $url .= '&gradebook=view&exerciseId='.intval($_GET['exerciseId']);
  37. // Check if exercise is inserted inside a LP, if that's the case
  38. $exerciseId = $_GET['exerciseId'];
  39. $exercise = new Exercise();
  40. $exercise->read($exerciseId);
  41. if (!empty($exercise->id)) {
  42. if ($exercise->exercise_was_added_in_lp) {
  43. if (!empty($exercise->lpList)) {
  44. $count = count($exercise->lpList);
  45. if ($count == 1) {
  46. // If the exercise was added once redirect to the LP
  47. $firstLp = current($exercise->lpList);
  48. if (isset($firstLp['lp_id'])) {
  49. $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&lp_id=' . $firstLp['lp_id'] . '&action=view&isStudentView=true';
  50. }
  51. } else {
  52. // If the exercise was added multiple times show the LP list
  53. $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq().'&action=list';
  54. }
  55. }
  56. }
  57. }
  58. }
  59. header('Location: '.$url);
  60. exit;
  61. }