MDL-45943: Replacement for publisher icons
[moodle.git] / mod / scorm / datamodels / sequencinghandler.php
blobf1de51bbbff245a4dc502a26493b0aa075c6b614
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 require_once('../../../config.php');
18 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
20 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
21 $a = optional_param('a', '', PARAM_INT); // scorm ID.
22 $scoid = required_param('scoid', PARAM_INT); // Sco ID.
23 $attempt = required_param('attempt', PARAM_INT); // Attempt number.
24 $function = required_param('function', PARAM_RAW); // Function to call.
25 $request = optional_param('request', '', PARAM_RAW); // Scorm ID.
27 if (!empty($id)) {
28 $cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
29 $course = $DB->get_record("course", array("id" => $cm->course), '*', MUST_EXIST);
30 $scorm = $DB->get_record("scorm", array("id" => $cm->instance), '*', MUST_EXIST);
31 } else if (!empty($a)) {
32 $scorm = $DB->get_record("scorm", array("id" => $a), '*', MUST_EXIST);
33 $course = $DB->get_record("course", array("id" => $scorm->course), '*', MUST_EXIST);
34 $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id, false, MUST_EXIST);
35 } else {
36 print_error('missingparameter');
39 $PAGE->set_url('/mod/scorm/datamodels/sequencinghandler.php',
40 array('scoid'=>$scoid, 'attempt'=>$attempt, 'id'=>$cm->id, 'function' => $function, 'request' => $request));
42 require_login($course, false, $cm);
44 if (!empty($scoid) && !empty($function)) {
45 require_once($CFG->dirroot.'/mod/scorm/datamodels/scorm_13lib.php');
47 if (has_capability('mod/scorm:savetrack', context_module::instance($cm->id))) {
48 $result = null;
49 switch ($function) {
50 case 'scorm_seq_flow' :
51 if ($request == 'forward' || $request == 'backward') {
52 $seq = scorm_seq_navigation ($scoid, $USER->id, $request.'_', $attempt);
53 $sco = scorm_get_sco($scoid);
54 $seq = scorm_seq_flow($sco, $request, $seq, true, $USER->id);
55 if (!empty($seq->nextactivity)) {
56 scorm_seq_end_attempt($sco, $USER->id, $seq);
59 echo json_encode($seq);
60 break;