MDL-32572 fix notice when changing internal auth_db passwords
[moodle.git] / mod / scorm / view.php
blob787b8b1f1e125b1da57d84817abf8673ab21c79d
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 require_once("../../config.php");
18 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
20 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
21 $a = optional_param('a', '', PARAM_INT); // scorm ID
22 $organization = optional_param('organization', '', PARAM_INT); // organization ID
23 $action = optional_param('action', '', PARAM_ALPHA);
25 if (!empty($id)) {
26 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
27 print_error('invalidcoursemodule');
29 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
30 print_error('coursemisconf');
32 if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
33 print_error('invalidcoursemodule');
35 } else if (!empty($a)) {
36 if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
37 print_error('invalidcoursemodule');
39 if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
40 print_error('coursemisconf');
42 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
43 print_error('invalidcoursemodule');
45 } else {
46 print_error('missingparameter');
49 $url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
50 if ($organization !== '') {
51 $url->param('organization', $organization);
53 $PAGE->set_url($url);
54 $forcejs = get_config('scorm', 'forcejavascript');
55 if (!empty($forcejs)) {
56 $PAGE->add_body_class('forcejavascript');
59 require_login($course->id, false, $cm);
61 $context = get_context_instance(CONTEXT_COURSE, $course->id);
62 $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
64 if (isset($SESSION->scorm)) {
65 unset($SESSION->scorm);
68 $strscorms = get_string("modulenameplural", "scorm");
69 $strscorm = get_string("modulename", "scorm");
71 $shortname = format_string($course->shortname, true, array('context' => $context));
72 $pagetitle = strip_tags($shortname.': '.format_string($scorm->name));
74 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
76 if ((has_capability('mod/scorm:skipview', $contextmodule))) {
77 scorm_simple_play($scorm, $USER, $contextmodule, $cm->id);
81 // Print the page header
83 $PAGE->set_title($pagetitle);
84 $PAGE->set_heading($course->fullname);
85 echo $OUTPUT->header();
87 if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) {
88 if ($action == 'delete') {
89 $confirmurl = new moodle_url($PAGE->url, array('action'=>'deleteconfirm'));
90 echo $OUTPUT->confirm(get_string('deleteuserattemptcheck', 'scorm'), $confirmurl, $PAGE->url);
91 echo $OUTPUT->footer();
92 exit;
93 } else if ($action == 'deleteconfirm') {
94 //delete this users attempts.
95 $DB->delete_records('scorm_scoes_track', array('userid' => $USER->id, 'scormid' => $scorm->id));
96 scorm_update_grades($scorm, $USER->id, true);
97 echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
101 $currenttab = 'info';
102 require($CFG->dirroot . '/mod/scorm/tabs.php');
104 // Print the main part of the page
105 echo $OUTPUT->heading(format_string($scorm->name));
106 $attemptstatus = '';
107 if ($scorm->displayattemptstatus == 1) {
108 $attemptstatus = scorm_get_attempt_status($USER, $scorm, $cm);
110 echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
112 $scormopen = true;
113 $timenow = time();
114 if (!empty($scorm->timeopen) && $scorm->timeopen > $timenow) {
115 echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
116 $scormopen = false;
118 if (!empty($scorm->timeclose) && $timenow > $scorm->timeclose) {
119 echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
120 $scormopen = false;
122 if ($scormopen) {
123 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
125 if (!empty($forcejs)) {
126 echo $OUTPUT->box(get_string("forcejavascriptmessage", "scorm"), "generalbox boxaligncenter forcejavascriptmessage");
128 echo $OUTPUT->footer();