3 /// This page prints a particular instance of aicc/scorm package
5 require_once('../../config.php');
6 require_once($CFG->dirroot
.'/mod/scorm/locallib.php');
7 require_once($CFG->libdir
. '/completionlib.php');
10 // Checkin' script parameters
12 $id = optional_param('cm', '', PARAM_INT
); // Course Module ID, or
13 $a = optional_param('a', '', PARAM_INT
); // scorm ID
14 $scoid = required_param('scoid', PARAM_INT
); // sco ID
15 $mode = optional_param('mode', 'normal', PARAM_ALPHA
); // navigation mode
16 $currentorg = optional_param('currentorg', '', PARAM_RAW
); // selected organization
17 $newattempt = optional_param('newattempt', 'off', PARAM_ALPHA
); // the user request to start a new attempt
20 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
21 @ini_set
('zlib.output_compression', 'Off');
22 @apache_setenv
('no-gzip', 1);
26 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
27 print_error('invalidcoursemodule');
29 if (! $course = $DB->get_record("course", array("id"=>$cm->course
))) {
30 print_error('coursemisconf');
32 if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance
))) {
33 print_error('invalidcoursemodule');
35 } else if (!empty($a)) {
36 if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
37 print_error('invalidcoursemodule');
39 if (! $course = $DB->get_record("course", array("id"=>$scorm->course
))) {
40 print_error('coursemisconf');
42 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id
, $course->id
)) {
43 print_error('invalidcoursemodule');
46 print_error('missingparameter');
49 $url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id
));
50 if ($mode !== 'normal') {
51 $url->param('mode', $mode);
53 if ($currentorg !== '') {
54 $url->param('currentorg', $currentorg);
56 if ($newattempt !== 'off') {
57 $url->param('newattempt', $newattempt);
60 $forcejs = get_config('scorm','forcejavascript');
61 if (!empty($forcejs)) {
62 $PAGE->add_body_class('forcejavascript');
65 require_login($course->id
, false, $cm);
67 $strscorms = get_string('modulenameplural', 'scorm');
68 $strscorm = get_string('modulename', 'scorm');
69 $strpopup = get_string('popup','scorm');
70 $strexit = get_string('exitactivity','scorm');
72 $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name
));
73 $PAGE->set_title($pagetitle);
74 $PAGE->set_heading($course->fullname
);
76 if (!$cm->visible
and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE
,$course->id
))) {
77 echo $OUTPUT->header();
78 notice(get_string("activityiscurrentlyhidden"));
79 echo $OUTPUT->footer();
83 //check if scorm closed
85 if ($scorm->timeclose
!=0) {
86 if ($scorm->timeopen
> $timenow) {
87 echo $OUTPUT->header();
88 echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen
)), "generalbox boxaligncenter");
89 echo $OUTPUT->footer();
91 } elseif ($timenow > $scorm->timeclose
) {
92 echo $OUTPUT->header();
93 echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose
)), "generalbox boxaligncenter");
94 echo $OUTPUT->footer();
102 $scorm->version
= strtolower(clean_param($scorm->version
, PARAM_SAFEDIR
)); // Just to be safe
103 if (!file_exists($CFG->dirroot
.'/mod/scorm/datamodels/'.$scorm->version
.'lib.php')) {
104 $scorm->version
= 'scorm_12';
106 require_once($CFG->dirroot
.'/mod/scorm/datamodels/'.$scorm->version
.'lib.php');
107 $attempt = scorm_get_last_attempt($scorm->id
, $USER->id
);
108 if (($newattempt=='on') && (($attempt < $scorm->maxattempt
) ||
($scorm->maxattempt
== 0))) {
112 $attemptstr = '&attempt=' . $attempt;
114 $result = scorm_get_toc($USER, $scorm, $cm->id
, TOCJSLINK
, $currentorg, $scoid, $mode, $attempt, true, true);
117 if (($mode == 'browse') && ($scorm->hidebrowse
== 1)) {
120 if ($mode != 'browse') {
121 if ($trackdata = scorm_get_tracks($sco->id
,$USER->id
,$attempt)) {
122 if (($trackdata->status
== 'completed') ||
($trackdata->status
== 'passed') ||
($trackdata->status
== 'failed')) {
132 add_to_log($course->id
, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id
);
135 $scoidstr = '&scoid='.$sco->id
;
136 $scoidpop = '&scoid='.$sco->id
;
137 $modestr = '&mode='.$mode;
138 if ($mode == 'browse') {
139 $modepop = '&mode='.$mode;
143 $orgstr = '¤torg='.$currentorg;
145 $SESSION->scorm_scoid
= $sco->id
;
146 $SESSION->scorm_status
= 'Not Initialized';
147 $SESSION->scorm_mode
= $mode;
148 $SESSION->scorm_attempt
= $attempt;
150 // Mark module viewed
151 $completion = new completion_info($course);
152 $completion->set_module_viewed($cm);
155 // Print the page header
158 if ($scorm->popup
== 1) {
159 $bodyscript = 'onunload="main.close();"';
162 $exitlink = '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$scorm->course
.'" title="'.$strexit.'">'.$strexit.'</a> ';
164 $PAGE->set_button($exitlink);
166 $PAGE->requires
->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width
,'cheight'=>$scorm->height
,
167 'popupoptions' => $scorm->options
), true);
168 $PAGE->requires
->js('/mod/scorm/request.js', true);
169 $PAGE->requires
->js('/lib/cookies.js', true);
170 //$PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr, true);
171 $PAGE->requires
->css('/mod/scorm/styles.css');
173 echo $OUTPUT->header();
176 $PAGE->requires
->string_for_js('navigation', 'scorm');
177 $PAGE->requires
->string_for_js('toc', 'scorm');
178 $PAGE->requires
->string_for_js('hide', 'moodle');
179 $PAGE->requires
->string_for_js('show', 'moodle');
180 $PAGE->requires
->string_for_js('popupsblocked', 'scorm');
188 <div id
='scormapi-parent'>
189 <script id
="external-scormapi" type
="text/JavaScript"></script
>
193 if ($result->prerequisites
) {
194 if ($scorm->popup
!= 0) {
195 //Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
196 $linkcourse = '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$scorm->course
.'">' . get_string('finishscormlinkname','scorm') . '</a>';
197 echo $OUTPUT->box(get_string('finishscorm','scorm',$linkcourse), 'generalbox', 'altfinishlink');
201 <?php
echo $mode == 'browse' ?
'<div id="scormmode" class="scorm-left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?
>
202 <?php
echo $mode == 'review' ?
'<div id="scormmode" class="scorm-left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?
>
203 <div id
="scormnav" class="scorm-right">
205 if ($scorm->hidetoc
== SCORM_TOC_POPUP
) {
206 echo $result->tocmenu
;
209 </div
> <!-- Scormnav
-->
210 </div
> <!-- Scormtop
-->
211 <div id
="toctree" class="generalbox">
212 <?php
echo $result->toc
; ?
>
213 </div
> <!-- toctree
-->
214 </div
> <!-- tocbox
-->
217 <?php
print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
222 if ($result->prerequisites
) {
223 if ($scorm->popup
!= 0) {
224 // Clean the name for the window as IE is fussy
225 $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name
);
227 $name = 'DefaultPlayerWindow';
229 $name = 'scorm_'.$name;
231 echo html_writer
::script('', $CFG->wwwroot
.'/mod/scorm/player.js');
232 echo html_writer
::script(js_writer
::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id
.$scoidpop, $name, $scorm->options
, $scorm->width
, $scorm->height
)));
236 <iframe id
="main" class="scoframe" name
="main" src
="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></iframe
>
239 <object id
="main" class="scoframe" type
="text/html" data
="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></object>
245 echo $OUTPUT->box(get_string('noprerequisites','scorm'));
248 </div
> <!-- SCORM page
-->
251 if (!isset($result->toctitle
)) {
252 $result->toctitle
= get_string('toc', 'scorm');
255 $PAGE->requires
->js_init_call('M.mod_scorm.init', array($scorm->hidenav
, $scorm->hidetoc
, $result->toctitle
, $name, $sco->id
));
257 if (!empty($forcejs)) {
258 echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
260 echo $OUTPUT->footer();