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'); } 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'); if ($course->id != SITEID) { if ($scorms = get_all_instances_in_course('scorm', $course)) { // The module SCORM/AICC activity with the first id is the course $firstscorm = current($scorms); if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) { $PAGE->navbar->add($strscorms, new moodle_url($CFG->wwwroot.'/mod/scorm/index.php', array('id'=>$course->id))); } } } $pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name)); $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(format_string($scorm->name,true), new moodle_url($CFG->wwwroot.'/mode/scorm/view.php', array('id'=>$cm->id))); $PAGE->set_button(update_module_button($cm->id, $course->id, $strscorm)); 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); $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?id=$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.update_module_button($cm->id, $course->id, $strscorm)); echo $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height))->in_head(); echo $PAGE->requires->js('mod/scorm/request.js')->in_head(); echo $PAGE->requires->js('mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr)->in_head(); echo $PAGE->requires->js('mod/scorm/rd.js')->in_head(); echo $OUTPUT->header(); $PAGE->requires->js_function_call('attach_resize_event'); if (($sco->previd != 0) && ((!isset($sco->previous)) || ($sco->previous == 0))) { $scostr = '&scoid='.$sco->previd; $PAGE->requires->js_function_call('scorm_set_prev', Array($CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr)); } else { $PAGE->requires->js_function_call('scorm_set_prev', Array($CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id)); } if (($sco->nextid != 0) && ((!isset($sco->next)) || ($sco->next == 0))) { $scostr = '&scoid='.$sco->nextid; $PAGE->requires->js_function_call('scorm_set_next', Array($CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr)); } else { $PAGE->requires->js_function_call('scorm_set_next', Array($CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id)); } ?>