dirroot.'/mod/scorm/locallib.php'); // // Checkin' script parameters // $id = optional_param('cm', '', PARAM_INT); // Course Module ID, or $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 //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'); } if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { print_error('coursemisconf'); } if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) { print_error('invalidcoursemodule'); } } else if (!empty($a)) { if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) { print_error('invalidcoursemodule'); } if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) { print_error('coursemisconf'); } if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { print_error('invalidcoursemodule'); } } else { print_error('missingparameter'); } $url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id)); if ($mode !== 'normal') { $url->param('mode', $mode); } if ($currentorg !== '') { $url->param('currentorg', $currentorg); } if ($newattempt !== 'off') { $url->param('newattempt', $newattempt); } $PAGE->set_url($url); require_login($course->id, false, $cm); $strscorms = get_string('modulenameplural', 'scorm'); $strscorm = get_string('modulename', 'scorm'); $strpopup = get_string('popup','scorm'); $strexit = get_string('exitactivity','scorm'); $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name)); $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE,$course->id))) { echo $OUTPUT->header(); notice(get_string("activityiscurrentlyhidden")); echo $OUTPUT->footer(); die; } //check if scorm closed $timenow = time(); if ($scorm->timeclose !=0) { if ($scorm->timeopen > $timenow) { echo $OUTPUT->header(); echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter"); echo $OUTPUT->footer(); die; } elseif ($timenow > $scorm->timeclose) { echo $OUTPUT->header(); echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter"); echo $OUTPUT->footer(); die; } } // // TOC processing // $scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) { $scorm->version = 'scorm_12'; } require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php'); $attempt = scorm_get_last_attempt($scorm->id, $USER->id); if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) { $attempt++; $mode = 'normal'; } $attemptstr = '&attempt=' . $attempt; $result = scorm_get_toc($USER, $scorm, 'structurelist', $currentorg, $scoid, $mode, $attempt, true, true); $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'; } } else { $mode = 'normal'; } } add_to_log($course->id, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id); $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; $SESSION->scorm_attempt = $attempt; // // Print the page header // $bodyscript = ''; if ($scorm->popup == 1) { $bodyscript = 'onunload="main.close();"'; } $exitlink = ''.$strexit.' '; $PAGE->set_button($exitlink); $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height), true); $PAGE->requires->js('/mod/scorm/request.js', true); $PAGE->requires->js('/lib/cookies.js', true); //$PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr, true); $PAGE->requires->css('/mod/scorm/styles.css'); echo $OUTPUT->header(); // 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'); $PAGE->requires->string_for_js('popupsblocked', 'scorm'); $name = false; ?>