Choice MDL-23448 lang tidy for users that can be enrolled - don't call them guests.
[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);
489797d9 43 $contextmodule = get_context_instance(CONTEXT_MODULE,$cm->id);
0d699c24 44
f9d5371b 45 if (isset($SESSION->scorm_scoid)) {
46 unset($SESSION->scorm_scoid);
47 }
48
49 $strscorms = get_string("modulenameplural", "scorm");
50 $strscorm = get_string("modulename", "scorm");
51
f9d5371b 52 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
53
5b89dfbb 54 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id", $cm->id);
f9d5371b 55
489797d9 56 if ((has_capability('mod/scorm:skipview', $contextmodule)) && scorm_simple_play($scorm,$USER, $contextmodule)) {
8e45ba45 57 exit;
58 }
59
f9d5371b 60 //
61 // Print the page header
62 //
52869011 63 $PAGE->set_title($pagetitle);
64 $PAGE->set_heading($course->fullname);
52869011 65 echo $OUTPUT->header();
f9d5371b 66
6f8dda46
DM
67 $currenttab = 'info';
68 require($CFG->dirroot . '/mod/scorm/tabs.php');
2b3447c3 69
2b3447c3 70 // Print the main part of the page
465f165d 71 echo $OUTPUT->heading(format_string($scorm->name));
6381fa56 72 $attemptstatus = '';
ac3668bf 73 if ($scorm->displayattemptstatus == 1) {
6381fa56 74 $attemptstatus = scorm_get_attempt_status($USER,$scorm);
75 }
6aff538a 76 echo $OUTPUT->box(format_module_intro('scorm', $scorm, $cm->id).$attemptstatus, 'generalbox boxaligncenter boxwidthwide', 'intro');
e5dd8e3b 77
d54e2145 78 $scormopen = true;
79 $timenow = time();
80 if ($scorm->timeclose !=0) {
81 if ($scorm->timeopen > $timenow) {
6aff538a 82 echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
d54e2145 83 $scormopen = false;
84 } else if ($timenow > $scorm->timeclose) {
6aff538a 85 echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
d54e2145 86 $scormopen = false;
87 }
88 }
89 if ($scormopen) {
90 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
91 }
670bc3e7 92 echo $OUTPUT->footer();
e5dd8e3b 93