changed all the POST with option/required_param functions
[moodle.git] / mod / scorm / view.php
CommitLineData
d1290cec 1<?php // $Id$
98ca59f6 2
3/// This page prints a particular instance of scorm
4/// (Replace scorm with the name of your module)
5
6 require_once("../../config.php");
7 require_once("lib.php");
8
7b873234 9 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
10 $a = optional_param('a', '', PARAM_INT); // scorm ID
11 $organization = optional_param('organization', '', PARAM_INT); // organization ID
98ca59f6 12
7b873234 13 if (!empty($id)) {
98ca59f6 14 if (! $cm = get_record("course_modules", "id", $id)) {
15 error("Course Module ID was incorrect");
16 }
98ca59f6 17 if (! $course = get_record("course", "id", $cm->course)) {
18 error("Course is misconfigured");
19 }
98ca59f6 20 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
21 error("Course module is incorrect");
22 }
7b873234 23 } else if (!empty($a)) {
98ca59f6 24 if (! $scorm = get_record("scorm", "id", $a)) {
25 error("Course module is incorrect");
26 }
27 if (! $course = get_record("course", "id", $scorm->course)) {
28 error("Course is misconfigured");
29 }
30 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
31 error("Course Module ID was incorrect");
32 }
7b873234 33 } else {
34 error('A required parameter is missing');
98ca59f6 35 }
36
ec81373f 37 require_login($course->id, false, $cm);
9633a423 38
a5463b34 39 if (isset($SESSION->scorm_scoid)) {
5e5b6b7f 40 unset($SESSION->scorm_scoid);
a5463b34 41 }
9633a423 42
98ca59f6 43 $strscorms = get_string("modulenameplural", "scorm");
44 $strscorm = get_string("modulename", "scorm");
5e5b6b7f 45
98ca59f6 46 if ($course->category) {
47 $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
48 <a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
49 } else {
50 $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
51 }
52
9633a423 53 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
54
55 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
56
98ca59f6 57 //
58 // Print the page header
59 //
60 if (!$cm->visible and !isteacher($course->id)) {
9633a423 61 print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
62 update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
63 notice(get_string('activityiscurrentlyhidden'));
98ca59f6 64 } else {
9633a423 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));
68
5e5b6b7f 69 if (isteacher($course->id)) {
79714e2a 70 $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
71 if ($trackedusers->c > 0) {
9633a423 72 echo "<div class=\"reportlink\"><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\">".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
98ca59f6 73 } else {
9633a423 74 echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
98ca59f6 75 }
5e5b6b7f 76 }
77 // Print the main part of the page
98ca59f6 78
5e5b6b7f 79 print_heading(format_string($scorm->name));
98ca59f6 80
5e5b6b7f 81 print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');
98ca59f6 82
5e5b6b7f 83 if (isguest()) {
98ca59f6 84 print_heading(get_string("guestsno", "scorm"));
85 print_footer($course);
86 exit;
5e5b6b7f 87 }
9633a423 88 print_simple_box_start('center');
89?>
90 <div class="structurehead"><?php print_string('coursestruct','scorm') ?></div>
91<?php
7b873234 92 if (empty($organization)) {
93 $organization = $scorm->launch;
94 }
5e5b6b7f 95 if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) {
7b873234 96 if (count($orgs) > 1) {
9633a423 97?>
98 <div class='center'>
7b873234 99 <?php print_string('organizations','scorm') ?>
9633a423 100 <form name='changeorg' method='post' action='view.php?id=<?php echo $cm->id ?>'>
101 <?php choose_from_menu($orgs, 'organization', "$organization", '','submit()') ?>
102 </form>
103 </div>
104<?php
5e5b6b7f 105 }
5e5b6b7f 106 }
9633a423 107 $orgidentifier = '';
108 if ($org = get_record('scorm_scoes','id',$organization)) {
109 if (($org->organization == '') && ($org->launch == '')) {
110 $orgidentifier = $org->identifier;
111 } else {
112 $orgidentifier = $org->organization;
113 }
5e5b6b7f 114 }
261ee0b0 115 $result = scorm_get_toc($scorm,'structurelist',$orgidentifier);
116 $incomplete = $result->incomplete;
117 echo $result->toc;
118 print_simple_box_end();
119 ?>
9633a423 120 <div class="center">
121 <form name="theform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>">
122<?php
261ee0b0 123 if ($scorm->hidebrowse == 0) {
5e5b6b7f 124 print_string("mode","scorm");
9633a423 125 echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">'.get_string('browse','scorm').'</label>'."\n";
5e5b6b7f 126 if ($incomplete === true) {
9633a423 127 echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">'.get_string('normal','scorm')."</label>\n";
5e5b6b7f 128 } else {
9633a423 129 echo '<input type="radio" id="r" name="mode" value="review" checked="checked" /><label for="r">'.get_string('review','scorm')."</label>\n";
5e5b6b7f 130 }
131 } else {
132 if ($incomplete === true) {
133 echo '<input type="hidden" name="mode" value="normal" />'."\n";
134 } else {
135 echo '<input type="hidden" name="mode" value="review" />'."\n";
136 }
9633a423 137 }
98ca59f6 138?>
9633a423 139 <br />
140 <input type="hidden" name="scoid" />
141 <input type="hidden" name="currentorg" value="<?php echo $orgidentifier ?>" />
142 <input type="submit" value="<? print_string('entercourse','scorm') ?>" />
143 </form>
144 </div>
59c71f4b 145<script language="javascript" type="text/javascript">
98ca59f6 146<!--
4928a2f3 147 function playSCO(scoid) {
5e5b6b7f 148 document.theform.scoid.value = scoid;
149 document.theform.submit();
98ca59f6 150 }
9633a423 151
98ca59f6 152 function expandCollide(which,list) {
5e5b6b7f 153 var nn=document.ids?true:false
154 var w3c=document.getElementById?true:false
155 var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
156 var mid=w3c?").style":".style";
9633a423 157
5e5b6b7f 158 if (eval(beg+list+mid+".display") != "none") {
bc5a6319 159 which.src = "<?php echo $CFG->wwwroot ?>/mod/scorm/pix/plus.gif";
5e5b6b7f 160 eval(beg+list+mid+".display='none';");
161 } else {
bc5a6319 162 which.src = "<?php echo $CFG->wwwroot ?>/mod/scorm/pix/minus.gif";
5e5b6b7f 163 eval(beg+list+mid+".display='block';");
9633a423 164 }
98ca59f6 165 }
166-->
167</script>
168<?php
5e5b6b7f 169 print_footer($course);
98ca59f6 170 }
171?>