3 /// This page prints a particular instance of aicc/scorm package
5 require_once('../../config.php');
6 require_once('locallib.php');
9 // Checkin' script parameters
11 $id = optional_param('id', '', PARAM_INT
); // Course Module ID, or
12 $a = optional_param('a', '', PARAM_INT
); // scorm ID
13 $scoid = required_param('scoid', PARAM_INT
); // sco ID
14 $mode = optional_param('mode', 'normal', PARAM_ALPHA
); // navigation mode
15 $currentorg = optional_param('currentorg', '', PARAM_RAW
); // selected organization
16 $newattempt = optional_param('newattempt', 'off', PARAM_ALPHA
); // the user request to start a new attempt
19 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
20 error("Course Module ID was incorrect");
22 if (! $course = get_record("course", "id", $cm->course
)) {
23 error("Course is misconfigured");
25 if (! $scorm = get_record("scorm", "id", $cm->instance
)) {
26 error("Course module is incorrect");
28 } else if (!empty($a)) {
29 if (! $scorm = get_record("scorm", "id", $a)) {
30 error("Course module is incorrect");
32 if (! $course = get_record("course", "id", $scorm->course
)) {
33 error("Course is misconfigured");
35 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id
, $course->id
)) {
36 error("Course Module ID was incorrect");
39 error('A required parameter is missing');
42 require_login($course->id
, false, $cm);
44 $strscorms = get_string('modulenameplural', 'scorm');
45 $strscorm = get_string('modulename', 'scorm');
46 $strpopup = get_string('popup','scorm');
47 $strexit = get_string('exitactivity','scorm');
51 if ($course->id
!= SITEID
) {
52 if ($scorms = get_all_instances_in_course('scorm', $course)) {
53 // The module SCORM/AICC activity with the first id is the course
54 $firstscorm = current($scorms);
55 if (!(($course->format
== 'scorm') && ($firstscorm->id
== $scorm->id
))) {
56 $navlinks[] = array('name' => $strscorms, 'link' => "index.php?id=$course->id", 'type' => 'activity');
61 $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name
));
63 if (!$cm->visible
and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE
,$course->id
))) {
64 $navlinks[] = array('name' => format_string($scorm->name
,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance');
65 $navigation = build_navigation($navlinks);
67 print_header($pagetitle, $course->fullname
, $navigation,
68 '', '', true, update_module_button($cm->id
, $course->id
, $strscorm), '', false);
69 notice(get_string("activityiscurrentlyhidden"));
75 $scorm->version
= strtolower(clean_param($scorm->version
, PARAM_SAFEDIR
)); // Just to be safe
76 if (!file_exists($CFG->dirroot
.'/mod/scorm/datamodels/'.$scorm->version
.'lib.php')) {
77 $scorm->version
= 'scorm_12';
79 require_once($CFG->dirroot
.'/mod/scorm/datamodels/'.$scorm->version
.'lib.php');
80 $attempt = scorm_get_last_attempt($scorm->id
, $USER->id
);
81 if (($newattempt=='on') && (($attempt < $scorm->maxattempt
) ||
($scorm->maxattempt
== 0))) {
85 $attemptstr = '&attempt=' . $attempt;
87 $result = scorm_get_toc($USER,$scorm,'structurelist',$currentorg,$scoid,$mode,$attempt,true);
90 if (($mode == 'browse') && ($scorm->hidebrowse
== 1)) {
93 if ($mode != 'browse') {
94 if ($trackdata = scorm_get_tracks($sco->id
,$USER->id
,$attempt)) {
95 if (($trackdata->status
== 'completed') ||
($trackdata->status
== 'passed') ||
($trackdata->status
== 'failed')) {
105 add_to_log($course->id
, 'scorm', 'view', "player.php?id=$cm->id&scoid=$sco->id", "$scorm->id");
107 $scoidstr = '&scoid='.$sco->id
;
108 $scoidpop = '&scoid='.$sco->id
;
109 $modestr = '&mode='.$mode;
110 if ($mode == 'browse') {
111 $modepop = '&mode='.$mode;
115 $orgstr = '¤torg='.$currentorg;
117 $SESSION->scorm_scoid
= $sco->id
;
118 $SESSION->scorm_status
= 'Not Initialized';
119 $SESSION->scorm_mode
= $mode;
120 $SESSION->scorm_attempt
= $attempt;
123 // Print the page header
126 if ($scorm->popup
== 1) {
127 $bodyscript = 'onunload="main.close();"';
130 $navlinks[] = array('name' => format_string($scorm->name
,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance');
131 $navigation = build_navigation($navlinks);
132 $exitlink = '<a href="'.$CFG->wwwroot
.'/course/view.php?id='.$scorm->course
.'" title="'.$strexit.'">'.$strexit.'</a> ';
134 print_header($pagetitle, $course->fullname
,
136 '', '', true, $exitlink.update_module_button($cm->id
, $course->id
, $strscorm), '', false, $bodyscript);
137 //if ($sco->scormtype == 'sco') {
139 <script type
="text/javascript" src
="request.js"></script
>
140 <script type
="text/javascript" src
="api.php?id=<?php echo $cm->id.$scoidstr.$modestr.$attemptstr ?>"></script
>
143 if (($sco->previd
!= 0) && ((!isset($sco->previous
)) ||
($sco->previous
== 0))) {
144 $scostr = '&scoid='.$sco->previd
;
145 echo ' <script type="text/javascript">'."\n//<![CDATA[\n".'var prev="'.$CFG->wwwroot
.'/mod/scorm/player.php?id='.$cm->id
.$orgstr.$modepop.$scostr."\";\n//]]>\n</script>\n";
147 echo ' <script type="text/javascript">'."\n//<![CDATA[\n".'var prev="'.$CFG->wwwroot
.'/mod/scorm/view.php?id='.$cm->id
."\";\n//]]>\n</script>\n";
149 if (($sco->nextid
!= 0) && ((!isset($sco->next
)) ||
($sco->next
== 0))) {
150 $scostr = '&scoid='.$sco->nextid
;
151 echo ' <script type="text/javascript">'."\n//<![CDATA[\n".'var next="'.$CFG->wwwroot
.'/mod/scorm/player.php?id='.$cm->id
.$orgstr.$modepop.$scostr."\";\n//]]>\n</script>\n";
153 echo ' <script type="text/javascript">'."\n//<![CDATA[\n".'var next="'.$CFG->wwwroot
.'/mod/scorm/view.php?id='.$cm->id
."\";\n//]]>\n</script>\n";
158 if ($scorm->hidetoc
== 0) {
160 <div id
="tocbox" class="generalbox">
161 <div id
="tochead" class="header"><?php
print_string('contents','scorm') ?
></div
>
163 <?php
echo $result->toc
; ?
>
167 $class = ' class="toc"';
169 $class = ' class="no-toc"';
172 <div id
="scormbox"<?php
echo $class ?
>>
174 // This very big test check if is necessary the "scormtop" div
176 ($mode != 'normal') ||
// We are not in normal mode so review or browse text will displayed
178 ($scorm->hidenav
== 0) && // Teacher want to display navigation links
181 ($sco->previd
!= 0) && // This is not the first learning object of the package
182 ((!isset($sco->previous
)) ||
($sco->previous
== 0)) // Moodle must manage the previous link
185 ($sco->nextid
!= 0) && // This is not the last learning object of the package
186 ((!isset($sco->next
)) ||
($sco->next
== 0)) // Moodle must manage the next link
189 ) ||
($scorm->hidetoc
== 2) // Teacher want to display toc in a small dropdown menu
193 <?php
echo $mode == 'browse' ?
'<div id="scormmode" class="left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?
>
194 <?php
echo $mode == 'review' ?
'<div id="scormmode" class="left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?
>
196 if (($scorm->hidenav
== 0) ||
($scorm->hidetoc
== 2)) {
198 <div id
="scormnav" class="right">
200 $orgstr = '&currentorg='.$currentorg;
201 if (($scorm->hidenav
== 0) && ($sco->previd
!= 0) && ((!isset($sco->previous
)) ||
($sco->previous
== 0))) {
202 /// Print the prev LO link
203 $scostr = '&scoid='.$sco->previd
;
204 $url = $CFG->wwwroot
.'/mod/scorm/player.php?id='.$cm->id
.$orgstr.$modestr.$scostr;
205 echo '<a href="'.$url.'">< '.get_string('prev','scorm').'</a>';
207 if ($scorm->hidetoc
== 2) {
208 echo $result->tocmenu
;
210 if (($scorm->hidenav
== 0) && ($sco->nextid
!= 0) && ((!isset($sco->next
)) ||
($sco->next
== 0))) {
211 /// Print the next LO link
212 $scostr = '&scoid='.$sco->nextid
;
213 $url = $CFG->wwwroot
.'/mod/scorm/player.php?id='.$cm->id
.$orgstr.$modestr.$scostr;
214 echo ' <a href="'.$url.'">'.get_string('next','scorm').' ></a>';
224 } // The end of the very big test
226 <div id
="scormobject" class="right">
229 <?php
print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
234 if ($result->prerequisites
) {
235 if ($scorm->popup
== 0) {
239 width
="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
240 height
="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
241 src
="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
246 <script type
="text/javascript">
248 function openpopup(url
,name
,options
,width
,height
) {
249 fullurl
= "<?php echo $CFG->wwwroot.'/mod/scorm/' ?>" + url
;
250 windowobj
= window
.open(fullurl
,name
,options
);
251 if ((width
==100) && (height
==100)) {
253 windowobj
.moveTo(0,0);
256 width
= Math
.round(screen
.availWidth
* width
/ 100);
259 height
= Math
.round(screen
.availHeight
* height
/ 100);
261 windowobj
.resizeTo(width
,height
);
266 url
= "loadSCO.php?id=<?php echo $cm->id.$scoidpop ?>";
267 width
= <?php
p($scorm->width
) ?
>;
268 height
= <?php
p($scorm->height
) ?
>;
269 var main
= openpopup(url
, "scormpopup", "<?php p($scorm->options) ?>", width
, height
);
275 width
="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
276 height
="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
277 src
="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
283 print_simple_box(get_string('noprerequisites','scorm'),'center');
286 </div
> <!-- SCORM
object -->
287 </div
> <!-- SCORM box
-->
288 </div
> <!-- SCORM content
-->
289 <?php
if (!empty($THEME->customcorners
)) {
290 require_once($CFG->dirroot
.'/lib/custom_corners_lib.php');
291 print_custom_corners_end();
293 <div
class="clearer"> 
;</div
>
294 <?php
print_footer(); ?
>