SCORM MDL-22951 New player for SCORM fixes major regression that prevents some SCORM...
[moodle.git] / mod / scorm / prereqs.php
1 <?php
2     require_once('../../config.php');
3     require_once($CFG->dirroot.'/mod/scorm/locallib.php');
5     $id = optional_param('id', '', PARAM_INT);       // Course Module ID, or
6     $a = optional_param('a', '', PARAM_INT);         // scorm ID
7     $scoid = required_param('scoid', PARAM_INT);  // sco ID
8     $attempt = required_param('attempt', PARAM_INT);  // attempt number
9     $mode = optional_param('mode', 'normal', PARAM_ALPHA); // navigation mode
10     $currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
13     if (!empty($id)) {
14         if (! $cm = get_coursemodule_from_id('scorm', $id)) {
15             print_error('invalidcoursemodule');
16         }
17         if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
18             print_error('coursemisconf');
19         }
20         if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
21             print_error('invalidcoursemodule');
22         }
23     } else if (!empty($a)) {
24         if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
25             print_error('invalidcoursemodule');
26         }
27         if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
28             print_error('coursemisconf');
29         }
30         if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
31             print_error('invalidcoursemodule');
32         }
33     } else {
34         print_error('missingparameter');
35     }
37     $PAGE->set_url('/mod/scorm/prereqs.php', array('scoid'=>$scoid,'attempt'=>$attempt, 'id'=>$cm->id));
39     require_login($course->id, false, $cm);
41     $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR));   // Just to be safe
42     if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
43         $scorm->version = 'scorm_12';
44     }
45     require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
48     if (confirm_sesskey() && (!empty($scoid))) {
49         $result = true;
50         $request = null;
51         if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE,$cm->id))) {
52             $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true, false);
53             echo $result->toc;
54         }
55         //echo "<ul><li>The Heading<ul>";
56         //echo "<li><a title='/moodledev/blah1'>Blah 1</a></li>";
57         //echo "<li><a title='/moodledev/blah2'>Blah 2</a></li>";
58         //echo "</ul></li></ul>";
59     }