2 require_once('../../config.php');
3 require_once('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
9 $delayseconds = 2; // Delay time before sco launch, used to give time to browser to define API
12 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
13 error('Course Module ID was incorrect');
15 if (! $course = get_record('course', 'id', $cm->course
)) {
16 error('Course is misconfigured');
18 if (! $scorm = get_record('scorm', 'id', $cm->instance
)) {
19 error('Course module is incorrect');
21 } else if (!empty($a)) {
22 if (! $scorm = get_record('scorm', 'id', $a)) {
23 error('Course module is incorrect');
25 if (! $course = get_record('course', 'id', $scorm->course
)) {
26 error('Course is misconfigured');
28 if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id
, $course->id
)) {
29 error('Course Module ID was incorrect');
32 error('A required parameter is missing');
35 require_login($course->id
, false, $cm);
40 if ($sco = scorm_get_sco($scoid)) {
41 if ($sco->launch
== '') {
42 // Search for the next launchable sco
43 if ($scoes = get_records_select('scorm_scoes','scorm='.$scorm->id
." AND launch<>'' AND id>".$sco->id
,'id ASC')) {
44 $sco = current($scoes);
50 // If no sco was found get the first of SCORM package
53 $scoes = get_records_select('scorm_scoes','scorm='.$scorm->id
." AND launch<>''",'id ASC');
54 $sco = current($scoes);
57 if ($sco->scormtype
== 'asset') {
58 $attempt = scorm_get_last_attempt($scorm->id
,$USER->id
);
59 $element = $scorm->version
== 'scorm_13'?
'cmi.completion_status':'cmi.core.lesson_status';
61 $result = scorm_insert_track($USER->id
, $scorm->id
, $sco->id
, $attempt, $element, $value);
68 $version = substr($scorm->version
,0,4);
69 if ((isset($sco->parameters
) && (!empty($sco->parameters
))) ||
($version == 'AICC')) {
70 if (stripos($sco->launch
,'?') !== false) {
75 if ((isset($sco->parameters
) && (!empty($sco->parameters
))) && ($sco->parameters
[0] == '?')) {
76 $sco->parameters
= substr($sco->parameters
,1);
80 if ($version == 'AICC') {
81 if (isset($sco->parameters
) && (!empty($sco->parameters
))) {
82 $sco->parameters
= '&'. $sco->parameters
;
84 $launcher = $sco->launch
.$connector.'aicc_sid='.sesskey().'&aicc_url='.$CFG->wwwroot
.'/mod/scorm/aicc.php'.$sco->parameters
;
86 if (isset($sco->parameters
) && (!empty($sco->parameters
))) {
87 $launcher = $sco->launch
.$connector.$sco->parameters
;
89 $launcher = $sco->launch
;
93 if (scorm_external_link($sco->launch
)) {
94 // Remote learning activity
96 } else if ($scorm->reference
[0] == '#') {
98 require_once($repositoryconfigfile);
99 $result = $CFG->repositorywebroot
.substr($scorm->reference
,1).'/'.$sco->launch
;
101 if ((basename($scorm->reference
) == 'imsmanifest.xml') && scorm_external_link($scorm->reference
)) {
103 $result = dirname($scorm->reference
).'/'.$launcher;
105 // Moodle internal package/manifest or remote (auto-imported) package
106 if (basename($scorm->reference
) == 'imsmanifest.xml') {
107 $basedir = dirname($scorm->reference
);
109 $basedir = $CFG->moddata
.'/scorm/'.$scorm->id
;
111 if ($CFG->slasharguments
) {
112 $result = $CFG->wwwroot
.'/file.php/'.$scorm->course
.'/'.$basedir.'/'.$launcher;
114 $result = $CFG->wwwroot
.'/file.php?file=/'.$scorm->course
.'/'.$basedir.'/'.$launcher;
121 <title
>LoadSCO
</title
>
122 <script type
="text/javascript">
124 setTimeout('document.location = "<?php echo $result ?>";',<?php
echo $delayseconds ?
>000);
128 <meta http
-equiv
="refresh" content
="<?php echo $delayseconds ?>;url=<?php echo $result ?>" />