changed all the POST with option/required_param functions
[moodle.git] / mod / scorm / mod.html
CommitLineData
98ca59f6 1<?php
2a0407b7 2 require_once("$CFG->dirroot/mod/scorm/lib.php");
98ca59f6 3 if (empty($form->name)) {
5e5b6b7f 4 $form->name = "";
98ca59f6 5 }
e84ce5c8 6 if (empty($form->reference)) {
5e5b6b7f 7 $form->reference = "";
e84ce5c8 8 }
98ca59f6 9 if (empty($form->summary)) {
5e5b6b7f 10 $form->summary = "";
98ca59f6 11 }
5d8790cb 12 if (empty($form->launch)) {
5e5b6b7f 13 $form->launch = "";
2a0407b7 14 }
15 if (empty($form->auto)) {
16 $form->auto = "";
17 }
7b873234 18 if (empty($form->popup)) {
b5127f1e 19 $form->popup = "0";
20 }
2a0407b7 21 if (empty($form->datadir)) {
22 $form->datadir = "";
23 }
2a0407b7 24 if (empty($form->maxgrade)) {
25 $form->maxgrade = "";
26 }
27 if (empty($form->grademethod)) {
28 $form->grademethod = "0";
29 }
261ee0b0 30 if (empty($form->hidebrowse)) {
31 $form->hidebrowse = "0";
32 }
33 if (empty($form->hidetoc)) {
34 $form->hidetoc = "0";
26b3d26d 35 }
5f18d4e7 36 if (empty($form->width)) {
37 $form->width = $CFG->scorm_framewidth;
38 }
39 if (empty($form->height)) {
40 $form->height = $CFG->scorm_frameheight;
41 }
42
1daed920 43 $scormid = '';
2a0407b7 44 if (!empty($form->instance)) {
45 $scormid = '&instance='.$form->instance;
46 }
1daed920 47 $datadir = '';
2a0407b7 48 if (!empty($form->datadir)) {
49 $datadir = '&datadir='.$form->datadir;
5d8790cb 50 }
1daed920 51 $sessionkey = '';
52 if (!empty($form->sesskey)) {
53 $sessionkey = '&sesskey='.$form->sesskey;
54 }
261ee0b0 55
56 $strfilename = get_string("coursepacket", "scorm");
57 $strchooseafile = get_string("chooseapacket", "scorm");
98ca59f6 58?>
59
ae377545 60<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
2a0407b7 61<script type="text/javascript">
62 function validate_scorm(theform,filename) {
2a0407b7 63 var myRequest = NewHttpReq();
261ee0b0 64 result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php","id=<?php p($form->course) ?>&reference="+filename+"<?php echo $sessionkey.$scormid.$datadir ?>");
5e5b6b7f 65 results = result.split('\n');
66 result = '';
67 errorlogs = '';
68 datadir = '';
69 for (i=0;i<results.length;i++) {
70 element = results[i].split('=');
5e5b6b7f 71 switch(element[0]) {
9633a423 72 case 'result':
73 result = element[1];
74 break;
75 case 'launch':
76 launch = element[1];
77 break;
78 case 'datadir':
79 datadir = element[1];
80 break;
81 case 'pkgtype':
82 pkgtype = element[1];
83 break;
84 case 'errorlogs':
85 i++;
86 do {
87 errorlogs.concat(results[i]+'\n');
88 i++;
89 } while (i<results.lenght());
90
91 break;
5e5b6b7f 92 }
93 }
94 if ((result == "found") || (result == "regular")) {
95 theform.datadir.value = datadir;
96 theform.pkgtype.value = pkgtype;
97 theform.launch.value = launch;
98 if (launch == 0) {
99 if ('<?php echo $scormid ?>' != '') {
100 return confirm('<?php print_string('trackingloose','scorm') ?>');
101 }
102 }
103 return true;
104 } else {
105 result = '<?php print_string('validation','scorm') ?>: '+ result + '\n';
106 if (errorlogs != '') {
9633a423 107 result.concat('<?php print_string('errorlogs','scorm') ?>:\n'+errorlogs);
5e5b6b7f 108 }
109 alert(result);
110 return false;
111 }
2a0407b7 112 }
ae377545 113
114 function checkmethod (grademethod,maxgrade) {
5e5b6b7f 115 if (grademethod.options[grademethod.selectedIndex].value == 0) {
116 maxgrade.disabled=true;
117 } else {
118 maxgrade.disabled=false;
119 }
ae377545 120 }
261ee0b0 121
122 function showhide (id, set) {
123 divobj = document.getElementById(id);
124 butobj = document.getElementById(id+'button');
125 prefobj = document.getElementById(id+'pref');
126 if (set == true) {
127 if (prefobj.value == '1') {
128 divobj.style.display = 'block';
129 butobj.value = '<?php print_string("hidesettings") ?>';
130 } else {
131 divobj.style.display = 'none';
132 butobj.value = '<?php print_string("showsettings") ?>...';
133 }
134 } else {
135 if (prefobj.value == '1') {
136 divobj.style.display = 'none';
137 butobj.value = '<?php print_string("showsettings") ?>...';
138 prefobj.value = '0';
139 } else {
140 divobj.style.display = 'block';
141 butobj.value = '<?php print_string("hidesettings") ?>';
142 prefobj.value = '1';
143 }
144 }
145 }
2a0407b7 146</script>
98ca59f6 147
8b1b2407 148<form name="form" method="post" action="mod.php" onsubmit="return validate_scorm(document.form,document.form.reference.value);">
d1290cec 149 <table cellpadding="5">
5e5b6b7f 150 <tr valign="top">
151 <td align="right"><b><?php print_string("name") ?>:</b></td>
152 <td>
153 <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
154 </td>
155 </tr>
5e5b6b7f 156 <tr valign="top">
157 <td align="right"><b><?php print_string("summary") ?>:</b><br />
261ee0b0 158 <?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
5e5b6b7f 159 </td>
160 <td>
261ee0b0 161 <?php print_textarea($usehtmleditor, 10, 50, 680, 400, "summary", $form->summary); ?>
5e5b6b7f 162 </td>
163 </tr>
164 <tr valign="top">
165 <td align="right" nowrap="nowrap">
9633a423 166 <b><?php echo $strfilename?>:</b>
5e5b6b7f 167 </td>
168 <td>
9633a423 169 <?php
170 echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
171 button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference",
261ee0b0 172 "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
9633a423 173 helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
174 ?>
5e5b6b7f 175 </td>
176 </tr>
2a0407b7 177 <tr valign="top">
178 <td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
179 <td>
180 <?php
ae377545 181 choose_from_menu($SCORM_GRADE_METHOD, 'grademethod', "$form->grademethod", '','checkmethod(this,document.form.maxgrade);');
2a0407b7 182 helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
183 ?>
184 </td>
185 </tr>
186 <tr valign="top">
187 <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
188 <td>
189 <?php
190 for ($i=100; $i>=1; $i--) {
191 $grades[$i] = $i;
192 }
261ee0b0 193 $disabled = $form->grademethod=='0';
ae377545 194 choose_from_menu($grades, 'maxgrade', "$form->maxgrade", '','','0',false,$disabled);
195 helpbutton('maxgrade', get_string('maximumgrade'), 'scorm');
2a0407b7 196 ?>
197 </td>
9633a423 198 </tr>
b5127f1e 199 <tr><td colspan="2"><hr /></td></tr>
200
201 <tr>
202 <td align="right"><b><?php print_string("advanced", "scorm") ?>:</b></td>
203 <td>
b5127f1e 204 <input type="button" value="<?php print_string("hidesettings") ?>" id="advancedsettingsbutton" onclick="javascrip: return showhide('advancedsettings');" />
205 <input type="hidden" name="advancedsettingspref" id="advancedsettingspref"
206 value="<?php echo get_user_preferences('scorm_advancedsettingspref', $CFG->scorm_advancedsettings); ?>" />
207 <?php helpbutton("advanced", get_string("advanced", "scorm"), "scorm", true) ?>
208 </td>
209 </tr>
5e5b6b7f 210 <tr>
261ee0b0 211 <td colspan="2">
212 <div id="advancedsettings">
213 <table align="center">
214 <tr>
215 <td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
216 <td>
217 <?php
218 $options = array();
219 $options[0]=get_string("no");
220 $options[1]=get_string("yes");
221 choose_from_menu ($options, "auto", $form->auto,'');
222 helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
223 ?>
224 </td>
225 </tr>
226 <tr>
227 <td align="right"><b><?php print_string("hidebrowse","scorm") ?>:</b></td>
228 <td>
229 <?php
230 $options = array();
231 $options[0]=get_string("no");
232 $options[1]=get_string("yes");
233 choose_from_menu ($options, "hidebrowse", $form->hidebrowse, '');
234 helpbutton("browsemode", get_string("hidebrowse", "scorm"), "scorm", true);
235 ?>
236 </td>
237 </tr>
238 <tr>
239 <td align="right"><b><?php print_string("hidetoc","scorm") ?>:</b></td>
240 <td>
241 <?php
242 $options = array();
243 $options[0]=get_string("no");
244 $options[1]=get_string("yes");
245 choose_from_menu ($options, "hidetoc", $form->hidetoc, '');
246 helpbutton("tocdisplay", get_string("hidetoc", "scorm"), "scorm", true);
247 ?>
248 </td>
249 </tr>
250 </table>
251 </div>
5e5b6b7f 252 </td>
253 </tr>
254 <tr>
261ee0b0 255 <td align="right"><b><?php print_string("window", "scorm") ?>:</b></td>
26b3d26d 256 <td>
261ee0b0 257 <input type="button" value="<?php print_string("hidesettings") ?>" id="windowsettingsbutton" onclick="javascrip: return showhide('windowsettings');" />
258 <input type="hidden" name="windowsettingspref" id="windowsettingspref"
259 value="<?php echo get_user_preferences('scorm_windowsettingspref', $CFG->scorm_windowsettings); ?>" />
260 <?php helpbutton("window", get_string("window", "scorm"), "scorm", true) ?>
5e5b6b7f 261 </td>
262 </tr>
b5127f1e 263 <tr>
261ee0b0 264 <td colspan="2">
265 <div id="windowsettings">
266 <table align="center">
267 <tr>
268 <td align="right"><b><?php print_string("popup","scorm") ?>:</b></td>
269 <td>
270 <?php
271 $options = array();
272 $options[0]=get_string("no");
273 $options[1]=get_string("yes");
274 choose_from_menu ($options, "popup", $form->popup,'');
275 helpbutton("popupwindow", get_string("popup", "scorm"), "scorm", true);
276 ?>
277 </td>
278 </tr>
279 <tr valign="top">
280 <td align="right">
281 <b><?php print_string("stagesize","scorm") ?></b>
282 <?php helpbutton("size", get_string("stagesize", "scorm"), "scorm", true); ?>
283 </td>
284 <td>&nbsp;</td>
285 </tr>
286 <tr valign="top">
287 <td align="right"><b><?php print_string("width","scorm") ?>:</b></td>
288 <td>
289 <input type="text" name="width" value="<?php echo $form->width ?>" size="4" />
290 </td>
291 </tr>
292 <tr valign="top">
293 <td align="right"><b><?php print_string("height","scorm") ?>:</b></td>
294 <td>
295 <input type="text" name="height" value="<?php echo $form->height ?>" size="4" />
296 </td>
297 </tr>
298 </table>
299 </div>
300 <script language="javascript" type="text/javascript">
301 showhide('advancedsettings', true);
302 showhide('windowsettings', true);
303 </script>
5e5b6b7f 304 </td>
305 </tr>
4928a2f3 306 </table>
9633a423 307 <input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
308 <input type="hidden" name="pkgtype" value="<?php p($form->pkgtype) ?>" />
309 <input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
b5127f1e 310 <?php
311 $scorms = get_all_instances_in_course("scorm", $course);
312 $coursescorm = current($scorms);
313 if (($course->format == 'scorm') && ((count($scorms) == 0) || ($form->instance == $coursescorm->id))) {
314 ?>
315 <input type="hidden" name="redirect" value="yes" />
316 <input type="hidden" name="redirecturl" value="../course/view.php?id=<?php p($form->course) ?>" />
317 <?php
318 }
319 ?>
9633a423 320 <input type="hidden" name="course" value="<?php p($form->course) ?>" />
321 <input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
322 <input type="hidden" name="section" value="<?php p($form->section) ?>" />
323 <input type="hidden" name="module" value="<?php p($form->module) ?>" />
324 <input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
325 <input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
326 <input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
327 <input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
98ca59f6 328 <center>
5e5b6b7f 329 <input type="submit" value="<?php print_string('savechanges') ?>" />
330 <input type="button" name="cancel" value="<?php print_string('cancel') ?>" onclick="document.location='view.php?id=<?php echo $form->course ?>'" />
98ca59f6 331 </center>
e84ce5c8 332</form>