mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
playscorm.php
executable file
·248 lines (229 loc) · 9.41 KB
/
playscorm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?PHP // $Id$
/// This page prints a particular instance of scorm
require_once('../../config.php');
require_once('lib.php');
//
// Checkin' script parameters
//
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', '', PARAM_INT); // sco ID
$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
$modestring = '';
$scoidstring = '';
$currentorgstring = '';
if (!empty($mode)) {
$modestring = '&mode='.$mode;
}
if (!empty($scoid)) {
$scoidstring = '&scoid='.$scoid;
}
if (!empty($currentorg)) {
$currentorgstring = '¤torg='.$currentorg;
}
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("Course is misconfigured");
}
if (! $scorm = get_record("scorm", "id", $cm->instance)) {
error("Course module is incorrect");
}
} else if (!empty($a)) {
if (! $scorm = get_record("scorm", "id", $a)) {
error("Course module is incorrect");
}
if (! $course = get_record("course", "id", $scorm->course)) {
error("Course is misconfigured");
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
error("Course Module ID was incorrect");
}
} else {
error('A required parameter is missing');
}
require_login($course->id, false, $cm);
$strscorms = get_string('modulenameplural', 'scorm');
$strscorm = get_string('modulename', 'scorm');
$strexpand = get_string('expcoll','scorm');
$strpopup = get_string('popup','scorm');
if ($course->category) {
$navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
} else {
$navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
}
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
if (!$cm->visible and !isteacher($course->id)) {
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);
notice(get_string("activityiscurrentlyhidden"));
}
//
// TOC processing
//
$result = scorm_get_toc($scorm,'structurelist',$currentorg,$scoid,$mode,true);
$sco = $result->sco;
if ($mode == 'normal') {
if ($trackdata = scorm_get_tracks($USER->id,$sco->id)) {
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
$mode = 'review';
}
}
}
add_to_log($course->id, 'scorm', 'view', "playscorm.php?id=$cm->id&scoid=$sco->id", "$scorm->id");
if ($scorm->popup == 0) {
$scoidstring = '&scoid='.$sco->id;
$modestring = '&mode='.$mode;
} else {
$scoidstring = '&scoid='.$sco->id;
$modestring = '&mode='.$mode;
}
$SESSION->scorm_scoid = $sco->id;
$SESSION->scorm_status = 'Not Initialized';
$SESSION->scorm_mode = $mode;
//
// Print the page header
//
$bodyscript = '';
if ($scorm->popup == 1) {
$bodyscript = 'onunload="main.close();"';
}
$exitbutton = '<input name="exit" type="button" value="'.get_string('exit','scorm').'" onClick="document.location = \''.$CFG->wwwroot.'/course/view.php?id='.$cm->course.'\';" />';
print_header($pagetitle, "$course->fullname",
"$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
'', '', true, $exitbutton.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);
?>
<script language="JavaScript" type="text/javascript" src="request.js"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></script>
<table class="fullscreen">
<tr>
<?php
if ($scorm->hidetoc == 0) {
?>
<td class="top">
<table class='generalbox'>
<tr>
<td class="structurehead"><?php print_string('coursestruct','scorm') ?></td>
</tr>
<tr>
<td><?php echo $result->toc; ?></td>
</tr>
</table>
</td>
<?php
}
?>
<td class="top">
<table class="fullscreen">
<tr>
<?php echo $mode == 'browse' ? '<td class="left">'.get_string('browsemode','scorm')."</td>\n" : ''; ?>
<td class="right">
<form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
<input name="scoid" type="hidden" />
<input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
<input name="mode" type="hidden" value="<?php echo $mode ?>" />
<?php
if ($scorm->hidenav == 0) {
?>
<input name="prev" type="<?php if (($sco->prev == 0) || ($sco->showprev == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="prevSCO();" />
<input name="next" type="<?php if (($sco->next == 0) || ($sco->shownext == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('next','scorm') ?>" onClick="nextSCO();" />
<?php
}
?>
</form>
</td>
</tr>
<tr><td <?php echo $mode=='browse'?'colspan="2" ':'' ?>class="right">
<?php
if ($result->prerequisites) {
if ($scorm->popup == 0) {
?>
<iframe name="main"
class="scoframe"
width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>">
</iframe>
<?php
} else {
?>
<script lanuguage="javascript">
function openpopup(url,name,options,width,height) {
fullurl = "http://tiger.local/develop/mod/scorm/" + url;
windowobj = window.open(fullurl,name,options);
if ((width==100) && (height==100)) {
// Fullscreen
windowobj.moveTo(0,0);
}
if (width<=100) {
width = Math.round(screen.availWidth * width / 100);
}
if (height<=100) {
height = Math.round(screen.availHeight * height / 100);
}
windowobj.resizeTo(width,height);
windowobj.focus();
return windowobj;
}
url = "loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>";
width = <?php p($scorm->width) ?>;
height = <?php p($scorm->height) ?>;
var main = openpopup(url, "<?php p($scorm->name) ?>", "<?php p($scorm->options) ?>", width, height);
</script>
<?php
}
} else {
print_simple_box(get_string('noprerequisites','scorm'),'center');
}
?>
</td></tr>
</table>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
<!--
function playSCO(scoid) {
document.navform.scoid.value=scoid;
document.navform.submit();
}
function prevSCO() {
playSCO(<?php echo $sco->prev ?>);
}
function nextSCO() {
playSCO(<?php echo $sco->next ?>);
}
-->
</script>
<?php
if ($scorm->hidetoc == 0) {
?>
<script language="javascript" type="text/javascript">
<!--
function expandCollide(which,list) {
var nn=document.ids?true:false
var w3c=document.getElementById?true:false
var beg=nn?"document.ids.":w3c?"document.getElementById(":"document.all.";
var mid=w3c?").style":".style";
if (eval(beg+list+mid+".display") != "none") {
which.src = "pix/plus.gif";
eval(beg+list+mid+".display='none';");
} else {
which.src = "pix/minus.gif";
eval(beg+list+mid+".display='block';");
}
}
-->
</script>
<?php
}
?>
</div> <!-- Content -->
</div> <!-- Page -->
</body>
</html>