MDL-63660 tool_dataprivacy: Increase expected export file size
[moodle.git] / mod / scorm / prereqs.php
blob00a7662daea1382e7639ec9222c85cdc12b00c5f
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 // PARAM_RAW is used for $currentorg, validate it against records stored in the table.
54 if (!empty($currentorg)) {
55 if (!$DB->record_exists('scorm_scoes', array('scorm' => $scorm->id, 'identifier' => $currentorg))) {
56 $currentorg = '';
60 $PAGE->set_url('/mod/scorm/prereqs.php', array('scoid' => $scoid, 'attempt' => $attempt, 'id' => $cm->id));
62 require_login($course, false, $cm);
64 $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe.
65 if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
66 $scorm->version = 'scorm_12';
68 require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
71 if (confirm_sesskey() && (!empty($scoid))) {
72 $result = true;
73 $request = null;
74 if (has_capability('mod/scorm:savetrack', context_module::instance($cm->id))) {
75 $result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, false);
76 echo $result->toc;