Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/scorm/view.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 require_once("../../config.php");
00018 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
00019 
00020 $id = optional_param('id', '', PARAM_INT);       // Course Module ID, or
00021 $a = optional_param('a', '', PARAM_INT);         // scorm ID
00022 $organization = optional_param('organization', '', PARAM_INT); // organization ID
00023 $action = optional_param('action', '', PARAM_ALPHA);
00024 
00025 if (!empty($id)) {
00026     if (! $cm = get_coursemodule_from_id('scorm', $id)) {
00027         print_error('invalidcoursemodule');
00028     }
00029     if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
00030         print_error('coursemisconf');
00031     }
00032     if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
00033         print_error('invalidcoursemodule');
00034     }
00035 } else if (!empty($a)) {
00036     if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
00037         print_error('invalidcoursemodule');
00038     }
00039     if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
00040         print_error('coursemisconf');
00041     }
00042     if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
00043         print_error('invalidcoursemodule');
00044     }
00045 } else {
00046     print_error('missingparameter');
00047 }
00048 
00049 $url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
00050 if ($organization !== '') {
00051     $url->param('organization', $organization);
00052 }
00053 $PAGE->set_url($url);
00054 $forcejs = get_config('scorm', 'forcejavascript');
00055 if (!empty($forcejs)) {
00056     $PAGE->add_body_class('forcejavascript');
00057 }
00058 
00059 require_login($course->id, false, $cm);
00060 
00061 $context = get_context_instance(CONTEXT_COURSE, $course->id);
00062 $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
00063 
00064 if (isset($SESSION->scorm)) {
00065     unset($SESSION->scorm);
00066 }
00067 
00068 $strscorms = get_string("modulenameplural", "scorm");
00069 $strscorm  = get_string("modulename", "scorm");
00070 
00071 $shortname = format_string($course->shortname, true, array('context' => $context));
00072 $pagetitle = strip_tags($shortname.': '.format_string($scorm->name));
00073 
00074 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
00075 
00076 if ((has_capability('mod/scorm:skipview', $contextmodule))) {
00077     scorm_simple_play($scorm, $USER, $contextmodule, $cm->id);
00078 }
00079 
00080 //
00081 // Print the page header
00082 //
00083 $PAGE->set_title($pagetitle);
00084 $PAGE->set_heading($course->fullname);
00085 echo $OUTPUT->header();
00086 
00087 if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) {
00088     if ($action == 'delete') {
00089         $confirmurl = new moodle_url($PAGE->url, array('action'=>'deleteconfirm'));
00090         echo $OUTPUT->confirm(get_string('deleteuserattemptcheck', 'scorm'), $confirmurl, $PAGE->url);
00091         echo $OUTPUT->footer();
00092         exit;
00093     } else if ($action == 'deleteconfirm') {
00094         //delete this users attempts.
00095         $DB->delete_records('scorm_scoes_track', array('userid' => $USER->id, 'scormid' => $scorm->id));
00096         scorm_update_grades($scorm, $USER->id, true);
00097         echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
00098     }
00099 }
00100 
00101 $currenttab = 'info';
00102 require($CFG->dirroot . '/mod/scorm/tabs.php');
00103 
00104 // Print the main part of the page
00105 echo $OUTPUT->heading(format_string($scorm->name));
00106 $attemptstatus = '';
00107 if ($scorm->displayattemptstatus == 1) {
00108     $attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
00109 }
00110 echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
00111 
00112 $scormopen = true;
00113 $timenow = time();
00114 if (!empty($scorm->timeopen) && $scorm->timeopen > $timenow) {
00115     echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
00116     $scormopen = false;
00117 }
00118 if (!empty($scorm->timeclose) && $timenow > $scorm->timeclose) {
00119     echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
00120     $scormopen = false;
00121 }
00122 if ($scormopen) {
00123     scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
00124 }
00125 if (!empty($forcejs)) {
00126     echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
00127 }
00128 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations