2009-09-24 08:28:51 +00:00
< ? PHP
2006-08-08 22:09:55 +00:00
/// This page prints a particular instance of aicc/scorm package
require_once ( '../../config.php' );
2010-05-06 00:13:54 +00:00
require_once ( $CFG -> dirroot . '/mod/scorm/locallib.php' );
2006-08-08 22:09:55 +00:00
//
// Checkin' script parameters
//
2010-07-09 04:18:15 +00:00
$id = optional_param ( 'cm' , '' , PARAM_INT ); // Course Module ID, or
2006-08-08 22:09:55 +00:00
$a = optional_param ( 'a' , '' , PARAM_INT ); // scorm ID
$scoid = required_param ( 'scoid' , PARAM_INT ); // sco ID
$mode = optional_param ( 'mode' , 'normal' , PARAM_ALPHA ); // navigation mode
$currentorg = optional_param ( 'currentorg' , '' , PARAM_RAW ); // selected organization
$newattempt = optional_param ( 'newattempt' , 'off' , PARAM_ALPHA ); // the user request to start a new attempt
2007-05-08 15:44:37 +00:00
2009-12-18 06:40:59 +00:00
//IE 6 Bug workaround
if ( strpos ( $_SERVER [ 'HTTP_USER_AGENT' ], 'MSIE 6' ) !== false && ini_get ( 'zlib.output_compression' ) == 'On' ) {
ini_set ( 'zlib.output_compression' , 'Off' );
}
2006-08-08 22:09:55 +00:00
if ( ! empty ( $id )) {
if ( ! $cm = get_coursemodule_from_id ( 'scorm' , $id )) {
2008-06-15 11:00:30 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-08 22:09:55 +00:00
}
2008-06-05 10:02:26 +00:00
if ( ! $course = $DB -> get_record ( " course " , array ( " id " => $cm -> course ))) {
2008-06-15 11:00:30 +00:00
print_error ( 'coursemisconf' );
2006-08-08 22:09:55 +00:00
}
2008-06-05 10:02:26 +00:00
if ( ! $scorm = $DB -> get_record ( " scorm " , array ( " id " => $cm -> instance ))) {
2008-06-15 11:00:30 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-08 22:09:55 +00:00
}
} else if ( ! empty ( $a )) {
2008-06-05 10:02:26 +00:00
if ( ! $scorm = $DB -> get_record ( " scorm " , array ( " id " => $a ))) {
2008-06-15 11:00:30 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-08 22:09:55 +00:00
}
2008-06-05 10:02:26 +00:00
if ( ! $course = $DB -> get_record ( " course " , array ( " id " => $scorm -> course ))) {
2008-06-15 11:00:30 +00:00
print_error ( 'coursemisconf' );
2006-08-08 22:09:55 +00:00
}
if ( ! $cm = get_coursemodule_from_instance ( " scorm " , $scorm -> id , $course -> id )) {
2008-06-15 11:00:30 +00:00
print_error ( 'invalidcoursemodule' );
2006-08-08 22:09:55 +00:00
}
} else {
2008-06-15 11:00:30 +00:00
print_error ( 'missingparameter' );
2006-08-08 22:09:55 +00:00
}
2010-07-09 04:18:15 +00:00
$url = new moodle_url ( '/mod/scorm/player.php' , array ( 'scoid' => $scoid , 'cm' => $cm -> id ));
2009-09-24 08:28:51 +00:00
if ( $mode !== 'normal' ) {
$url -> param ( 'mode' , $mode );
}
if ( $currentorg !== '' ) {
$url -> param ( 'currentorg' , $currentorg );
}
if ( $newattempt !== 'off' ) {
$url -> param ( 'newattempt' , $newattempt );
}
$PAGE -> set_url ( $url );
2006-08-08 22:09:55 +00:00
require_login ( $course -> id , false , $cm );
$strscorms = get_string ( 'modulenameplural' , 'scorm' );
$strscorm = get_string ( 'modulename' , 'scorm' );
$strpopup = get_string ( 'popup' , 'scorm' );
2007-05-27 17:08:54 +00:00
$strexit = get_string ( 'exitactivity' , 'scorm' );
2006-08-08 22:09:55 +00:00
$pagetitle = strip_tags ( " $course->shortname : " . format_string ( $scorm -> name ));
2009-09-04 01:41:51 +00:00
$PAGE -> set_title ( $pagetitle );
$PAGE -> set_heading ( $course -> fullname );
2008-12-05 02:50:17 +00:00
2009-09-04 01:41:51 +00:00
if ( ! $cm -> visible and ! has_capability ( 'moodle/course:viewhiddenactivities' , get_context_instance ( CONTEXT_COURSE , $course -> id ))) {
echo $OUTPUT -> header ();
2006-08-08 22:09:55 +00:00
notice ( get_string ( " activityiscurrentlyhidden " ));
2009-08-06 14:20:31 +00:00
echo $OUTPUT -> footer ();
2008-11-28 09:20:59 +00:00
die ;
2006-08-08 22:09:55 +00:00
}
2008-11-28 09:20:59 +00:00
//check if scorm closed
$timenow = time ();
if ( $scorm -> timeclose != 0 ) {
if ( $scorm -> timeopen > $timenow ) {
2009-09-04 01:41:51 +00:00
echo $OUTPUT -> header ();
2009-08-18 05:16:50 +00:00
echo $OUTPUT -> box ( get_string ( " notopenyet " , " scorm " , userdate ( $scorm -> timeopen )), " generalbox boxaligncenter " );
2009-08-06 14:20:31 +00:00
echo $OUTPUT -> footer ();
2008-11-28 09:20:59 +00:00
die ;
} elseif ( $timenow > $scorm -> timeclose ) {
2009-09-04 01:41:51 +00:00
echo $OUTPUT -> header ();
2009-08-18 05:16:50 +00:00
echo $OUTPUT -> box ( get_string ( " expired " , " scorm " , userdate ( $scorm -> timeclose )), " generalbox boxaligncenter " );
2009-08-06 14:20:31 +00:00
echo $OUTPUT -> footer ();
2008-11-28 09:20:59 +00:00
die ;
}
}
2006-08-08 22:09:55 +00:00
//
// TOC processing
//
2006-08-31 08:34:13 +00:00
$scorm -> version = strtolower ( clean_param ( $scorm -> version , PARAM_SAFEDIR )); // Just to be safe
2006-11-28 03:04:50 +00:00
if ( ! file_exists ( $CFG -> dirroot . '/mod/scorm/datamodels/' . $scorm -> version . 'lib.php' )) {
2006-11-28 02:53:44 +00:00
$scorm -> version = 'scorm_12' ;
}
2006-08-31 08:34:13 +00:00
require_once ( $CFG -> dirroot . '/mod/scorm/datamodels/' . $scorm -> version . 'lib.php' );
$attempt = scorm_get_last_attempt ( $scorm -> id , $USER -> id );
2006-08-08 22:09:55 +00:00
if (( $newattempt == 'on' ) && (( $attempt < $scorm -> maxattempt ) || ( $scorm -> maxattempt == 0 ))) {
$attempt ++ ;
2006-09-26 07:56:07 +00:00
$mode = 'normal' ;
2006-08-08 22:09:55 +00:00
}
$attemptstr = '&attempt=' . $attempt ;
2010-07-23 18:20:04 +00:00
$result = scorm_get_toc ( $USER , $scorm , 'structurelist' , $currentorg , $scoid , $mode , $attempt , true , true );
2006-08-08 22:09:55 +00:00
$sco = $result -> sco ;
if (( $mode == 'browse' ) && ( $scorm -> hidebrowse == 1 )) {
$mode = 'normal' ;
}
if ( $mode != 'browse' ) {
if ( $trackdata = scorm_get_tracks ( $sco -> id , $USER -> id , $attempt )) {
if (( $trackdata -> status == 'completed' ) || ( $trackdata -> status == 'passed' ) || ( $trackdata -> status == 'failed' )) {
$mode = 'review' ;
} else {
$mode = 'normal' ;
}
2006-09-26 14:37:13 +00:00
} else {
$mode = 'normal' ;
2006-08-08 22:09:55 +00:00
}
}
2010-07-09 04:18:15 +00:00
add_to_log ( $course -> id , 'scorm' , 'view' , " player.php?cm= $cm->id &scoid= $sco->id " , " $scorm->id " , $cm -> id );
2008-12-05 02:50:17 +00:00
2006-08-08 22:09:55 +00:00
$scoidstr = '&scoid=' . $sco -> id ;
$scoidpop = '&scoid=' . $sco -> id ;
$modestr = '&mode=' . $mode ;
if ( $mode == 'browse' ) {
$modepop = '&mode=' . $mode ;
} else {
$modepop = '' ;
}
$orgstr = '¤torg=' . $currentorg ;
$SESSION -> scorm_scoid = $sco -> id ;
$SESSION -> scorm_status = 'Not Initialized' ;
$SESSION -> scorm_mode = $mode ;
2006-08-31 08:34:13 +00:00
$SESSION -> scorm_attempt = $attempt ;
2006-08-08 22:09:55 +00:00
//
// Print the page header
//
$bodyscript = '' ;
if ( $scorm -> popup == 1 ) {
$bodyscript = 'onunload="main.close();"' ;
}
2007-07-03 09:38:56 +00:00
2007-05-27 17:08:54 +00:00
$exitlink = '<a href="' . $CFG -> wwwroot . '/course/view.php?id=' . $scorm -> course . '" title="' . $strexit . '">' . $strexit . '</a> ' ;
2008-12-05 02:50:17 +00:00
2009-12-23 01:47:57 +00:00
$PAGE -> set_button ( $exitlink );
2009-06-26 06:31:26 +00:00
2010-02-06 13:30:15 +00:00
$PAGE -> requires -> data_for_js ( 'scormplayerdata' , Array ( 'cwidth' => $scorm -> width , 'cheight' => $scorm -> height ), true );
2010-02-06 14:09:33 +00:00
$PAGE -> requires -> js ( '/mod/scorm/request.js' , true );
$PAGE -> requires -> js ( '/lib/cookies.js' , true );
2010-07-22 00:48:06 +00:00
//$PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr, true);
$PAGE -> requires -> css ( '/mod/scorm/styles.css' );
2009-09-04 01:41:51 +00:00
echo $OUTPUT -> header ();
2009-06-26 06:31:26 +00:00
2010-07-22 00:48:06 +00:00
// NEW IMS TOC
$PAGE -> requires -> string_for_js ( 'navigation' , 'scorm' );
$PAGE -> requires -> string_for_js ( 'toc' , 'scorm' );
$PAGE -> requires -> string_for_js ( 'hide' , 'moodle' );
$PAGE -> requires -> string_for_js ( 'show' , 'moodle' );
2010-07-25 22:54:29 +00:00
$PAGE -> requires -> string_for_js ( 'popupsblocked' , 'scorm' );
2010-07-22 00:48:06 +00:00
$name = false ;
2006-08-08 22:09:55 +00:00
?>
< div id = " scormpage " >
2010-07-22 00:48:06 +00:00
< div id = " tocbox " >
< div id = 'scormapi-parent' >
< script id = " external-scormapi " type = " text/JavaScript " ></ script >
</ div >
< div id = " scormtop " >
2008-12-05 02:50:17 +00:00
< ? php
2010-07-22 00:48:06 +00:00
if ( $result -> prerequisites ) {
if ( $scorm -> popup != 0 ) {
2010-07-22 01:52:25 +00:00
//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.
2010-07-22 00:48:06 +00:00
$linkcourse = '<a href="' . $CFG -> wwwroot . '/course/view.php?id=' . $scorm -> course . '">' . get_string ( 'finishscormlinkname' , 'scorm' ) . '</a>' ;
2010-07-25 23:47:33 +00:00
echo $OUTPUT -> box ( get_string ( 'finishscorm' , 'scorm' , $linkcourse ), 'generalbox' , 'altfinishlink' );
2008-04-18 04:29:03 +00:00
}
2006-08-08 22:09:55 +00:00
}
?>
2008-07-29 00:42:28 +00:00
< ? php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">' . get_string ( 'browsemode' , 'scorm' ) . " </div> \n " : '' ; ?>
< ? php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">' . get_string ( 'reviewmode' , 'scorm' ) . " </div> \n " : '' ; ?>
2010-07-22 00:48:06 +00:00
< div id = " scormnav " class = " scorm-right " >
2006-08-08 22:09:55 +00:00
< ? php
2010-07-22 00:48:06 +00:00
if ( $scorm -> hidetoc == 2 ) {
echo $result -> tocmenu ;
2008-12-05 02:50:17 +00:00
}
2006-08-08 22:09:55 +00:00
?>
2010-07-22 00:48:06 +00:00
</ div > <!-- Scormnav -->
</ div > <!-- Scormtop -->
< div id = " toctree " class = " generalbox " >
< ? php echo $result -> toc ; ?>
</ div > <!-- toctree -->
</ div > <!-- tocbox -->
2006-08-08 22:09:55 +00:00
< noscript >
< div id = " noscript " >
< ? php print_string ( 'noscriptnoscorm' , 'scorm' ); // No Martin(i), No Party ;-) ?>
</ div >
</ noscript >
< ? php
if ( $result -> prerequisites ) {
2010-08-17 04:03:44 +00:00
if ( $scorm -> popup != 0 ) {
2008-07-31 22:16:30 +00:00
// Clean the name for the window as IE is fussy
2009-06-22 01:22:37 +00:00
$name = preg_replace ( " /[^A-Za-z0-9]/ " , " " , $scorm -> name );
2008-07-31 22:16:30 +00:00
if ( ! $name ) {
$name = 'DefaultPlayerWindow' ;
}
$name = 'scorm_' . $name ;
2006-08-08 22:09:55 +00:00
2010-01-26 09:36:00 +00:00
echo html_writer :: script ( '' , $CFG -> wwwroot . '/mod/scorm/player.js' );
echo html_writer :: script ( js_writer :: function_call ( 'scorm_openpopup' , Array ( " loadSCO.php?id= " . $cm -> id . $scoidpop , $name , $scorm -> options , $scorm -> width , $scorm -> height )));
2009-06-29 02:38:22 +00:00
?>
2010-05-13 23:01:38 +00:00
< noscript >
2010-05-16 22:39:49 +00:00
<!-- [ if IE ] >
2010-05-16 22:35:09 +00:00
< iframe id = " main " class = " scoframe " name = " main " src = " loadSCO.php?id=<?php echo $cm->id . $scoidstr . $modestr ; ?> " ></ iframe >
2010-05-16 22:39:49 +00:00
<! [ endif ] -->
<!-- [ if ! IE ] >
2010-05-16 22:35:09 +00:00
< object id = " main " class = " scoframe " type = " text/html " data = " loadSCO.php?id=<?php echo $cm->id . $scoidstr . $modestr ; ?> " ></ object >
2010-05-16 22:39:49 +00:00
<! [ endif ] -->
2010-05-13 23:01:38 +00:00
</ noscript >
2008-12-05 02:50:17 +00:00
< ? php
2006-08-08 22:09:55 +00:00
}
} else {
2009-09-24 08:28:51 +00:00
echo $OUTPUT -> box ( get_string ( 'noprerequisites' , 'scorm' ));
2006-08-08 22:09:55 +00:00
}
?>
2008-08-05 22:58:32 +00:00
</ div > <!-- SCORM page -->
2010-07-05 00:40:13 +00:00
< ? php
2010-07-22 00:48:06 +00:00
// NEW IMS TOC
if ( ! isset ( $result -> toctitle )) {
$result -> toctitle = get_string ( 'toc' , 'scorm' );
}
2010-07-25 22:54:29 +00:00
$PAGE -> requires -> js_init_call ( 'M.mod_scorm.init' , array ( $scorm -> hidenav , $scorm -> hidetoc , $result -> toctitle , $name , $sco -> id ));
2010-07-22 00:48:06 +00:00
2010-07-05 00:40:13 +00:00
$completion = new completion_info ( $course );
$completion -> set_module_viewed ( $cm );
echo $OUTPUT -> footer ();