SCORM MDL-25781 fix links in TOC on view.php
[moodle.git] / mod / scorm / prereqs.php
CommitLineData
5c2aa157 1<?php
e62c1d22
PH
2
3 // this page is called via AJAX to repopulte the TOC when LMSFinish() is called
4
5c2aa157
DM
5 require_once('../../config.php');
6 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
7
8 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
9 $a = optional_param('a', '', PARAM_INT); // scorm ID
10 $scoid = required_param('scoid', PARAM_INT); // sco ID
11 $attempt = required_param('attempt', PARAM_INT); // attempt number
12 $mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
13 $currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
14
15
16 if (!empty($id)) {
17 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
18 print_error('invalidcoursemodule');
19 }
20 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
21 print_error('coursemisconf');
22 }
23 if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
24 print_error('invalidcoursemodule');
25 }
26 } else if (!empty($a)) {
27 if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
28 print_error('invalidcoursemodule');
29 }
30 if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
31 print_error('coursemisconf');
32 }
33 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
34 print_error('invalidcoursemodule');
35 }
36 } else {
37 print_error('missingparameter');
38 }
39
40 $PAGE->set_url('/mod/scorm/prereqs.php', array('scoid'=>$scoid,'attempt'=>$attempt, 'id'=>$cm->id));
41
42 require_login($course->id, false, $cm);
43
44 $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
45 if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
46 $scorm->version = 'scorm_12';
47 }
48 require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
49
50
51 if (confirm_sesskey() && (!empty($scoid))) {
52 $result = true;
53 $request = null;
54 if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {
08868f58 55 $result = scorm_get_toc($USER,$scorm,TOCJSLINK,$currentorg,$scoid,$mode,$attempt,true, false);
5c2aa157
DM
56 echo $result->toc;
57 }
5c2aa157
DM
58 }
59