Fixed a bug in mode selection
[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
45 if ($course->category != 0) {
46 $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
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))) {
51 $navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
52 }
53 }
54 } else {
55 $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
56 }
57
58 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
59
60 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
61
62 //
63 // Print the page header
64 //
2b3447c3 65 print_header($pagetitle, "$course->fullname",
66 "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
67 '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
f9d5371b 68
2b3447c3 69 if (empty($cm->visible) and !has_capability('moodle/course:manageactivities', $context)) {
70 notice(get_string("activityiscurrentlyhidden"));
71 }
f9d5371b 72
2b3447c3 73 if (has_capability('moodle/course:manageactivities', $context)) {
2b3447c3 74 $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
75 if ($trackedusers->c > 0) {
0d699c24 76 echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
2b3447c3 77 } else {
78 echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
79 }
f9d5371b 80 }
2b3447c3 81
2b3447c3 82 // Print the main part of the page
83 print_heading(format_string($scorm->name));
84 print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');
85 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
86 print_footer($course);
f9d5371b 87?>