MDL-29254 Fixed whitespace
[moodle.git] / mod / scorm / prereqs.php
blob341248c4bd47715d7afa33ae303fa66dd3b11b44
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 // this page is called via AJAX to repopulte the TOC when LMSFinish() is called
19 require_once('../../config.php');
20 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
22 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
23 $a = optional_param('a', '', PARAM_INT); // scorm ID
24 $scoid = required_param('scoid', PARAM_INT); // sco ID
25 $attempt = required_param('attempt', PARAM_INT); // attempt number
26 $mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
27 $currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
29 if (!empty($id)) {
30 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
31 print_error('invalidcoursemodule');
33 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
34 print_error('coursemisconf');
36 if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
37 print_error('invalidcoursemodule');
39 } else if (!empty($a)) {
40 if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
41 print_error('invalidcoursemodule');
43 if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
44 print_error('coursemisconf');
46 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
47 print_error('invalidcoursemodule');
49 } else {
50 print_error('missingparameter');
53 $PAGE->set_url('/mod/scorm/prereqs.php', array('scoid'=>$scoid, 'attempt'=>$attempt, 'id'=>$cm->id));
55 require_login($course->id, false, $cm);
57 $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
58 if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
59 $scorm->version = 'scorm_12';
61 require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
64 if (confirm_sesskey() && (!empty($scoid))) {
65 $result = true;
66 $request = null;
67 if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
68 $result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, false);
69 echo $result->toc;