MDL-22052 Improved get_string caching - dirty on-disk cache detection
[moodle.git] / mod / scorm / view.php
CommitLineData
5c508e3f 1<?php
f9d5371b 2
3 require_once("../../config.php");
86996ffe 4 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
e5dd8e3b 5
f9d5371b 6 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
7 $a = optional_param('a', '', PARAM_INT); // scorm ID
0d699c24 8 $organization = optional_param('organization', '', PARAM_INT); // organization ID
f9d5371b 9
10 if (!empty($id)) {
0d699c24 11 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
08b56f93 12 print_error('invalidcoursemodule');
f9d5371b 13 }
bf347041 14 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
08b56f93 15 print_error('coursemisconf');
f9d5371b 16 }
bf347041 17 if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
08b56f93 18 print_error('invalidcoursemodule');
f9d5371b 19 }
20 } else if (!empty($a)) {
bf347041 21 if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
08b56f93 22 print_error('invalidcoursemodule');
f9d5371b 23 }
bf347041 24 if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
08b56f93 25 print_error('coursemisconf');
f9d5371b 26 }
27 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
08b56f93 28 print_error('invalidcoursemodule');
f9d5371b 29 }
30 } else {
08b56f93 31 print_error('missingparameter');
f9d5371b 32 }
33
a6855934 34 $url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
5c508e3f 35 if ($organization !== '') {
36 $url->param('organization', $organization);
37 }
38 $PAGE->set_url($url);
e5dd8e3b 39
f9d5371b 40 require_login($course->id, false, $cm);
41
77bf0c29 42 $context = get_context_instance(CONTEXT_COURSE, $course->id);
0d699c24 43
f9d5371b 44 if (isset($SESSION->scorm_scoid)) {
45 unset($SESSION->scorm_scoid);
46 }
47
48 $strscorms = get_string("modulenameplural", "scorm");
49 $strscorm = get_string("modulename", "scorm");
50
f9d5371b 51 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
52
5b89dfbb 53 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
f9d5371b 54
8e45ba45 55 if ((has_capability('mod/scorm:skipview', get_context_instance(CONTEXT_MODULE,$cm->id))) && scorm_simple_play($scorm,$USER)) {
56 exit;
57 }
58
f9d5371b 59 //
60 // Print the page header
61 //
52869011 62 $PAGE->set_title($pagetitle);
63 $PAGE->set_heading($course->fullname);
52869011 64 echo $OUTPUT->header();
f9d5371b 65
6f8dda46
DM
66 $currenttab = 'info';
67 require($CFG->dirroot . '/mod/scorm/tabs.php');
2b3447c3 68
2b3447c3 69 // Print the main part of the page
465f165d 70 echo $OUTPUT->heading(format_string($scorm->name));
6381fa56 71 $attemptstatus = '';
ac3668bf 72 if ($scorm->displayattemptstatus == 1) {
6381fa56 73 $attemptstatus = scorm_get_attempt_status($USER,$scorm);
74 }
6aff538a 75 echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
e5dd8e3b 76
d54e2145 77 $scormopen = true;
78 $timenow = time();
79 if ($scorm->timeclose !=0) {
80 if ($scorm->timeopen > $timenow) {
6aff538a 81 echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
d54e2145 82 $scormopen = false;
83 } else if ($timenow > $scorm->timeclose) {
6aff538a 84 echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
d54e2145 85 $scormopen = false;
86 }
87 }
88 if ($scormopen) {
89 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
90 }
670bc3e7 91 echo $OUTPUT->footer();
e5dd8e3b 92