2009-09-24 08:28:51 +00:00
|
|
|
<?php
|
2011-06-30 14:59:08 +12:00
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
require_once("../../config.php");
|
|
|
|
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
|
|
|
|
|
|
|
|
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
|
|
|
|
$a = optional_param('a', '', PARAM_INT); // scorm ID
|
|
|
|
$organization = optional_param('organization', '', PARAM_INT); // organization ID
|
2011-12-02 22:06:35 +13:00
|
|
|
$action = optional_param('action', '', PARAM_ALPHA);
|
2011-06-30 14:59:08 +12:00
|
|
|
|
|
|
|
if (!empty($id)) {
|
|
|
|
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
|
|
|
print_error('invalidcoursemodule');
|
2006-08-08 22:09:55 +00:00
|
|
|
}
|
2011-06-30 14:59:08 +12:00
|
|
|
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
|
|
|
print_error('coursemisconf');
|
2008-09-16 20:32:50 +00:00
|
|
|
}
|
2011-06-30 14:59:08 +12:00
|
|
|
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
|
|
|
print_error('invalidcoursemodule');
|
2010-07-21 10:19:38 +00:00
|
|
|
}
|
2011-06-30 14:59:08 +12:00
|
|
|
} else if (!empty($a)) {
|
|
|
|
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
|
|
|
print_error('invalidcoursemodule');
|
2008-11-28 09:20:59 +00:00
|
|
|
}
|
2011-06-30 14:59:08 +12:00
|
|
|
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
|
|
|
print_error('coursemisconf');
|
2008-11-28 09:20:59 +00:00
|
|
|
}
|
2011-06-30 14:59:08 +12:00
|
|
|
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
|
|
|
print_error('invalidcoursemodule');
|
2011-01-31 16:53:10 +13:00
|
|
|
}
|
2011-06-30 14:59:08 +12:00
|
|
|
} else {
|
|
|
|
print_error('missingparameter');
|
|
|
|
}
|
|
|
|
|
|
|
|
$url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
|
|
|
|
if ($organization !== '') {
|
|
|
|
$url->param('organization', $organization);
|
|
|
|
}
|
|
|
|
$PAGE->set_url($url);
|
|
|
|
$forcejs = get_config('scorm', 'forcejavascript');
|
|
|
|
if (!empty($forcejs)) {
|
|
|
|
$PAGE->add_body_class('forcejavascript');
|
|
|
|
}
|
|
|
|
|
|
|
|
require_login($course->id, false, $cm);
|
|
|
|
|
|
|
|
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
|
|
|
$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
|
|
|
|
|
2011-11-05 15:21:19 +13:00
|
|
|
if (isset($SESSION->scorm)) {
|
|
|
|
unset($SESSION->scorm);
|
2011-06-30 14:59:08 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
$strscorms = get_string("modulenameplural", "scorm");
|
|
|
|
$strscorm = get_string("modulename", "scorm");
|
|
|
|
|
2011-09-07 11:46:28 +12:00
|
|
|
$shortname = format_string($course->shortname, true, array('context' => $context));
|
|
|
|
$pagetitle = strip_tags($shortname.': '.format_string($scorm->name));
|
2011-06-30 14:59:08 +12:00
|
|
|
|
|
|
|
add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
|
|
|
|
|
2011-08-02 17:00:01 +12:00
|
|
|
if ((has_capability('mod/scorm:skipview', $contextmodule))) {
|
2011-08-12 12:44:16 +12:00
|
|
|
scorm_simple_play($scorm, $USER, $contextmodule, $cm->id);
|
2011-06-30 14:59:08 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Print the page header
|
|
|
|
//
|
|
|
|
$PAGE->set_title($pagetitle);
|
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
|
2011-12-02 22:06:35 +13:00
|
|
|
if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) {
|
|
|
|
if ($action == 'delete') {
|
|
|
|
$confirmurl = new moodle_url($PAGE->url, array('action'=>'deleteconfirm'));
|
|
|
|
echo $OUTPUT->confirm(get_string('deleteuserattemptcheck', 'scorm'), $confirmurl, $PAGE->url);
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
exit;
|
|
|
|
} else if ($action == 'deleteconfirm') {
|
|
|
|
//delete this users attempts.
|
|
|
|
$DB->delete_records('scorm_scoes_track', array('userid' => $USER->id, 'scormid' => $scorm->id));
|
|
|
|
scorm_update_grades($scorm, $USER->id, true);
|
|
|
|
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-30 14:59:08 +12:00
|
|
|
$currenttab = 'info';
|
|
|
|
require($CFG->dirroot . '/mod/scorm/tabs.php');
|
|
|
|
|
|
|
|
// Print the main part of the page
|
|
|
|
echo $OUTPUT->heading(format_string($scorm->name));
|
|
|
|
$attemptstatus = '';
|
|
|
|
if ($scorm->displayattemptstatus == 1) {
|
2011-12-02 22:06:35 +13:00
|
|
|
$attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
|
2011-06-30 14:59:08 +12:00
|
|
|
}
|
|
|
|
echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
|
|
|
|
|
|
|
|
$scormopen = true;
|
|
|
|
$timenow = time();
|
|
|
|
if (!empty($scorm->timeopen) && $scorm->timeopen > $timenow) {
|
|
|
|
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
|
|
|
|
$scormopen = false;
|
|
|
|
}
|
|
|
|
if (!empty($scorm->timeclose) && $timenow > $scorm->timeclose) {
|
|
|
|
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
|
|
|
|
$scormopen = false;
|
|
|
|
}
|
|
|
|
if ($scormopen) {
|
|
|
|
scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
|
|
|
|
}
|
|
|
|
if (!empty($forcejs)) {
|
|
|
|
echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
|
|
|
|
}
|
|
|
|
echo $OUTPUT->footer();
|