fixing some warnings
[moodle.git] / mod / scorm / view.php
CommitLineData
f9d5371b 1<?php // $Id$
2
3 require_once("../../config.php");
4 require_once('locallib.php');
5
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)) {
f9d5371b 12 error("Course Module ID was incorrect");
13 }
14 if (! $course = get_record("course", "id", $cm->course)) {
15 error("Course is misconfigured");
16 }
17 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
18 error("Course module is incorrect");
19 }
20 } else if (!empty($a)) {
21 if (! $scorm = get_record("scorm", "id", $a)) {
22 error("Course module is incorrect");
23 }
24 if (! $course = get_record("course", "id", $scorm->course)) {
25 error("Course is misconfigured");
26 }
27 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
28 error("Course Module ID was incorrect");
29 }
30 } else {
31 error('A required parameter is missing');
32 }
33
34 require_login($course->id, false, $cm);
35
77bf0c29 36 $context = get_context_instance(CONTEXT_COURSE, $course->id);
0d699c24 37
f9d5371b 38 if (isset($SESSION->scorm_scoid)) {
39 unset($SESSION->scorm_scoid);
40 }
41
42 $strscorms = get_string("modulenameplural", "scorm");
43 $strscorm = get_string("modulename", "scorm");
44
1936c10e 45 if ($course->id != SITEID) {
afd97d1c 46
f9d5371b 47 if ($scorms = get_all_instances_in_course('scorm', $course)) {
48 // The module SCORM activity with the least id is the course
49 $firstscorm = current($scorms);
50 if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
afd97d1c 51 $crumbs[] = array('name' => $strscorms, 'link' => "index.php?id=$course->id", 'type' => 'activity');
f9d5371b 52 }
53 }
f9d5371b 54 }
f9d5371b 55 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
56
57 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
58
8e45ba45 59 if ((has_capability('mod/scorm:skipview', get_context_instance(CONTEXT_MODULE,$cm->id))) && scorm_simple_play($scorm,$USER)) {
60 exit;
61 }
62
f9d5371b 63 //
64 // Print the page header
65 //
afd97d1c 66 $crumbs[] = array('name' => format_string($scorm->name,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance');
70c6c0ad 67 $navigation = build_navigation($crumbs);
afd97d1c 68
69 print_header($pagetitle, $course->fullname, $navigation,
2b3447c3 70 '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
f9d5371b 71
2b3447c3 72 if (empty($cm->visible) and !has_capability('moodle/course:manageactivities', $context)) {
73 notice(get_string("activityiscurrentlyhidden"));
74 }
f9d5371b 75
2b3447c3 76 if (has_capability('moodle/course:manageactivities', $context)) {
2b3447c3 77 $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
78 if ($trackedusers->c > 0) {
fa738731 79 echo "<div class=\"reportlink\"><a $CFG->frametarget href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
2b3447c3 80 } else {
81 echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
82 }
f9d5371b 83 }
2b3447c3 84
2b3447c3 85 // Print the main part of the page
86 print_heading(format_string($scorm->name));
c1afef80 87 print_box(format_text($scorm->summary), 'generalbox', 'intro');
2b3447c3 88 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
89 print_footer($course);
f9d5371b 90?>