adding some strings
[moodle-linuxchix.git] / mod / hotpot / mod.html
blobc6a0a8fe191db0b4c5a6ce8211176044d892b025
1 <!-- This page defines the form to create or edit an instance of this module -->
2 <!-- It is used from /course/mod.php.The whole instance is available as $form. -->
4 <?php
6 require_once("$CFG->dirroot/mod/hotpot/lib.php");
8 // set default values in form fields, if necessary
9 set_form_fields($form);
11 // commonly used array of <select> options
12 $yes_no_options = array(
13 HOTPOT_NO => get_string("no"),
14 HOTPOT_YES => get_string("yes")
16 $text_source_options = array(
17 HOTPOT_TEXTSOURCE_QUIZ => get_string("textsourcequiz", "hotpot"),
18 HOTPOT_TEXTSOURCE_FILENAME => get_string("textsourcefilename", "hotpot"),
19 HOTPOT_TEXTSOURCE_FILEPATH => get_string("textsourcefilepath", "hotpot"),
20 HOTPOT_TEXTSOURCE_SPECIFIC => get_string("textsourcespecific", "hotpot")
23 <script type="text/javascript">
24 //<![CDATA[
25 var nameoffvalues = new Array(0,1,2);
26 var namelockitems = new Array('name');
28 var timeoffvalues = new Array('0'); // needs to be '0', not just 0
29 var timeopenlockitems = new Array('openday','openmonth','openyear','openhour', 'openminute');
30 var timecloselockitems = new Array('closeday','closemonth','closeyear','closehour','closeminute');
32 var feedbackoffvalues = new Array(0,3,4,5);
33 var feedbacklockitems = new Array('studentfeedbackurl');
35 function hotpot_lockoptions(form, master, subitems, offvalues) {
36 var disabled = false;
37 var obj = eval("document."+form+"."+master);
38 if (obj) {
39 var v = '';
40 if (obj.type=='select-one') {
41 var v = obj.options[obj.selectedIndex].value;
42 for (i=0; i<offvalues.length; i++) {
43 if (v==offvalues[i]) {
44 disabled = true;
47 } else if (obj.type=='checkbox') {
48 if (obj.checked==false) {
49 disabled = true;
53 if (document.getElementById) {
54 for (i=0; i<subitems.length; i++) {
55 eval("document."+form+"."+subitems[i]+".disabled="+disabled);
58 return(true);
60 //]]>
61 </script>
62 <center>
63 <form id="form" method="post" action="mod.php">
64 <table cellpadding="5">
65 <tr valign="top">
66 <td align="right"><b><?php print_string("name") ?>:</b></td>
67 <td align="left"><?php
68 if ($form->mode=='add') {
69 choose_from_menu(
70 $text_source_options, "namesource", "$form->namesource", "",
71 "return hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues)"
73 } else {
74 print '<input type="hidden" name="namesource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'" />';
76 print '<input type="text" name="name" size=40 value="'.$form->name.'">';
77 ?></td>
78 </tr>
79 <tr valign="top">
80 <td align="right">
81 <b><?php
82 print_string("summary")
83 ?>:</b><br />
84 <font size="1"><?php
85 helpbutton("summary", get_string("summary"), "resource", true, true);
86 print '<br />';
87 helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
88 print '<br />';
89 if (isset($usehtmleditor) && $usehtmleditor) {
90 helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
91 print '<br />';
92 } else {
93 helpbutton("text", get_string("helptext"), "moodle", true, true);
94 print '<br />';
95 emoticonhelpbutton("form", "description");
97 ?></font>
98 </span>
99 </td>
100 <td align="left"><?php
101 if ($form->mode=='add') {
102 choose_from_menu($text_source_options, "summarysource", "$form->summarysource", "");
103 print '<br />';
104 } else {
105 print '<input type="hidden" name="summarysource" value="'.HOTPOT_TEXTSOURCE_SPECIFIC.'" />';
107 if (function_exists("print_textarea") && isset($usehtmleditor)) {
108 print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary);
109 } else {
110 // Moodle 1.1.1 (original size was rows="5" cols="50")
111 print '<textarea name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary.'</textarea>';
113 ?></td>
114 </tr>
115 <tr valign="top">
116 <td align="right"><b><?php print_string("quizopen", "quiz") ?>:</b></td>
117 <td align="left"><?php
118 if (!$form->timeopen && $course->format == "weeks") {
119 $form->timeopen = $course->startdate + (($form->section - 1) * 608400);
121 print '<input name="enabletimeopen" type="checkbox" value="1" alt="'.get_string("quizopen", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems)".'" '.(empty($form->timeopen) ? '' : 'checked="checked"').' />';
122 print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
123 print ' - ';
124 print_time_selector("openhour", "openminute", $form->timeopen);
125 helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
126 ?></td>
127 </tr>
128 <tr valign="top">
129 <td align="right"><b><?php print_string("quizclose", "quiz") ?>:</b></td>
130 <td align="left"><?php
131 if (!$form->timeclose && $course->format == "weeks") {
132 $form->timeclose= $course->startdate + (($form->section) * 608400);
134 print '<input name="enabletimeclose" type="checkbox" value="1" alt="'.get_string("quizclose", "quiz").'" onclick="'."return hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems)".'" '.(empty($form->timeclose) ? '' : 'checked="checked"').' />';
135 print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
136 print ' - ';
137 print_time_selector("closehour", "closeminute", $form->timeclose);
138 helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
139 ?></td>
140 </tr>
141 <tr valign="top">
142 <td align="right" nowrap>
143 <b><?php print get_string("location","hotpot") ?>:</b>
144 </td>
145 <td align="left"><?php
147 if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
148 $site = get_site();
149 if ($course->id==$site->id) {
150 $id = $site->id;
151 $location = HOTPOT_LOCATION_SITEFILES;
152 } else {
153 $id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'";
154 $location = '';
156 } else { // ordinary teacher or content creator
157 $id = $course->id;
158 $location = HOTPOT_LOCATION_COURSEFILES;
161 if (array_key_exists($location, $HOTPOT_LOCATION)) {
162 print '<input type="hidden" name="location" value="'.$location.'" />';
163 print '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> &nbsp; ';
165 } else { // admin can select from "site" or "course" files
166 choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", "");
170 if (function_exists("button_to_popup_window")) {
172 // use javascript to extract wdir from the reference field
173 $wdir = "'+getDir(getObjValue(this.form.reference))+'";
175 // set button url depending on Moodle version
176 if ($CFG->version < 2004083125) { // version may need refining
177 // up to and including Moodle 1.4.1
178 $url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir";
179 } else {
180 // Moodle 1.4.2 and beyond
181 $url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference";
184 $strchooseafile = get_string("chooseafile", "resource");
185 button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
187 ?></td>
188 </tr>
189 <tr valign="top">
190 <td align="right" nowrap>
191 <b><?php print_string("filename", "resource") ?>:</b>
192 </td>
193 <td align="left"><?php
194 if (function_exists("button_to_popup_window")) {
195 print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
197 } else if (function_exists("get_directory_list")) {
198 // Moodle 1.1 (and perhaps some others)
199 $dirs = get_directory_list("$CFG->dataroot/$course->id");
200 $options = array();
201 foreach ($dirs as $dir) {
202 $options["$dir"] = $dir;
204 choose_from_menu ($options, "reference", $form->reference);
206 } else {
207 // a very old Moodle (may be none left :-)
208 print '<input name="reference" size="50" value="'.$form->reference.'">&nbsp;';
210 print '<br />';
211 hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true);
212 ?></td>
213 </tr>
214 <tr valign="top">
215 <td align="right"><b><?php
216 $quizchain = "{$form->mode}quizchain";
217 print_string($quizchain, "hotpot");
218 ?>:</b></td>
219 <td align="left"><?php
220 choose_from_menu($yes_no_options, "quizchain", $form->quizchain, "");
221 helpbutton($quizchain, get_string($quizchain,"hotpot"), "hotpot");
222 ?></td>
223 </tr>
224 <tr valign="top">
225 <td align="right"><b><?php print_string("outputformat", "hotpot") ?>:</b></td>
226 <td align="left"><?php
227 choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", "");
228 helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot");
229 ?></td>
230 </tr>
231 <tr valign="top">
232 <td align="right"><b><?php print_string("navigation", "hotpot") ?>:</b></td>
233 <td align="left"><?php
234 choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", "");
235 helpbutton("navigation", get_string("navigation","hotpot"), "hotpot");
236 ?></td>
237 </tr>
238 <tr valign="top">
239 <td align="right"><b><?php print_string("studentfeedback", "hotpot") ?>:</b></td>
240 <td align="left"><?php
241 choose_from_menu(
242 $HOTPOT_FEEDBACK, "studentfeedback", "$form->studentfeedback", "",
243 "return hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues)"
245 print '<span id="studentfeedbackurlSPAN">';
246 print "<input name=\"studentfeedbackurl\" size=\"50\" value=\"$form->studentfeedbackurl\">";
247 print '</span>';
248 helpbutton("studentfeedback", get_string("studentfeedback","hotpot"), "hotpot");
249 ?></td>
250 </tr>
251 <tr valign="top">
252 <td align="right"><b><?php print_string("forceplugins", "hotpot") ?>:</b></td>
253 <td align="left"><?php
254 choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", "");
255 helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot");
256 ?></td>
257 </tr>
258 <tr valign="top">
259 <td align="right"><b><?php print_string("shownextquiz", "hotpot") ?>:</b></td>
260 <td align="left"><?php
261 choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", "");
262 helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot");
263 ?></td>
264 </tr>
265 <tr valign="top">
266 <td align="right"><b><?php print_string("allowreview", "quiz") ?>:</b></td>
267 <td align="left"><?php
268 choose_from_menu($yes_no_options, "review", "$form->review", "");
269 helpbutton("review", get_string("allowreview","quiz"), "quiz");
270 ?></td>
271 </tr>
272 <tr valign="top">
273 <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
274 <td align="left"><?php
275 $options = array();
276 for ($i=100; $i>=1; $i--) {
277 $options[$i] = $i;
279 $options[0] = get_string("nograde");
281 choose_from_menu($options, "grade", "$form->grade", "");
282 helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
283 ?></td>
284 </tr>
285 <tr valign="top">
286 <td align="right"><b><?php print_string("grademethod", "quiz") ?>:</b></td>
287 <td align="left"><?php
288 choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", "");
289 helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
290 ?></td>
291 </tr>
292 <tr valign="top">
293 <td align="right"><b><?php print_string("attemptsallowed", "quiz") ?>:</b></td>
294 <td align="left"><?php
295 $options = array(
296 0 => get_string("attemptsunlimited", "quiz"),
297 1 => '1 '.strtolower(get_string("attempt", "quiz"))
299 for ($i=2; $i<=10; $i++) {
300 $options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
302 choose_from_menu($options, "attempts", "$form->attempts", "");
303 helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
304 ?></td>
305 </tr>
306 <tr valign="top">
307 <td align="right"><b><?php print_string("requirepassword", "quiz") ?>:</b></td>
308 <td align="left">
309 <input type="text" name="password" size=40 value="<?php p($form->password) ?>">
310 <?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
311 </td>
312 </tr>
313 <tr valign="top">
314 <td align="right"><b><?php print_string("requiresubnet", "quiz") ?>:</b></td>
315 <td align="left">
316 <input type="text" name="subnet" size=40 value="<?php p($form->subnet) ?>">
317 <?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
318 </td>
319 </tr>
320 <tr valign="top">
321 <td align="right"><b><?php print_string("clickreporting", "hotpot") ?>:</b></td>
322 <td align="left"><?php
323 choose_from_menu($yes_no_options, "clickreporting", "$form->clickreporting", "");
324 helpbutton("clickreporting", get_string("clickreporting","hotpot"), "hotpot");
325 ?></td>
326 </tr>
327 <?php
328 print_standard_coursemodule_settings($form);
330 <tr valign="top">
331 <td align="right">&nbsp;</td>
332 <td align="left">
333 <!-- buttons -->
334 <input type="submit" value="<?php print_string("savechanges") ?>"> &nbsp; &nbsp;
335 <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" /><br />
336 <?php
337 if (isset($CFG->release) && substr($CFG->release, 0, 3)>=1.5) {
338 $options = array(
339 HOTPOT_DISPLAYNEXT_QUIZ => get_string("displayhotpotnext", "hotpot"),
340 HOTPOT_DISPLAYNEXT_COURSE => get_string("displaycoursenext", "hotpot"),
341 HOTPOT_DISPLAYNEXT_INDEX => get_string("displayindexnext", "hotpot")
343 choose_from_menu($options, "displaynext", "$form->displaynext", "");
344 } else {
345 print '<input type="hidden" name="displaynext" value="'.HOTPOT_NO.'" />'."\n";
348 </table>
350 <!-- hidden fields -->
351 <input type="hidden" name="course" value="<?php p($form->course) ?>">
352 <input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>">
353 <input type="hidden" name="section" value="<?php p($form->section) ?>">
354 <input type="hidden" name="module" value="<?php p($form->module) ?>">
355 <input type="hidden" name="modulename" value="<?php p($form->modulename) ?>">
356 <input type="hidden" name="instance" value="<?php p($form->instance) ?>">
357 <input type="hidden" name="mode" value="<?php p($form->mode) ?>">
358 <?php if (isset($USER->sesskey)) { ?>
359 <input type="hidden" name="sesskey" value="<?php p($USER->sesskey) ?>">
360 <?php } ?>
362 </form>
363 </center>
364 <script type="text/javascript">
365 <!--
366 hotpot_lockoptions('form', 'namesource', namelockitems, nameoffvalues);
367 hotpot_lockoptions('form', 'enabletimeopen', timeopenlockitems, timeoffvalues);
368 hotpot_lockoptions('form', 'enabletimeclose', timecloselockitems, timeoffvalues);
369 hotpot_lockoptions('form', 'studentfeedback', feedbacklockitems, feedbackoffvalues);
371 // override the standard Moodle "setfocus" function,
372 // which gives a js error if the "name" field is hidden
373 function setfocus() {
374 var f = getElementById('form');
375 if (f) {
376 if (canfocus(f, 'namesource')) {
377 f.namesource.focus();
378 } else if (canfocus(f, 'name')) {
379 f.name.focus();
383 function canfocus(f, name) {
384 var obj = eval('f.'+name);
385 return (obj==null || obj.type=='hidden' || obj.focus==null || (obj.style && obj.style.display=='none')) ? false : true;
387 //-->
388 </script>
389 <?php
391 // ======================
392 // functions
393 // ======================
395 function set_form_fields(&$form) {
396 set_form_field($form, 'name');
397 set_form_field($form, 'summary');
398 set_form_field($form, 'timeopen', get_user_preferences('hotpot_timeopen', 0));
399 set_form_field($form, 'enabletimeopen', empty($form->timeopen) ? HOTPOT_NO : HOTPOT_YES);
400 set_form_field($form, 'timeclose', get_user_preferences('hotpot_timeclose', 0));
401 set_form_field($form, 'enabletimeclose', empty($form->timeclose) ? HOTPOT_NO : HOTPOT_YES);
402 set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES);
403 set_form_field($form, 'reference');
404 set_form_field($form, 'navigation', get_user_preferences('hotpot_navigation', HOTPOT_NAVIGATION_BAR));
405 set_form_field($form, 'outputformat', get_user_preferences('hotpot_outputformat', HOTPOT_OUTPUTFORMAT_BEST));
406 set_form_field($form, 'studentfeedback', get_user_preferences('hotpot_studentfeedback', HOTPOT_FEEDBACK_NONE));
407 set_form_field($form, 'studentfeedbackurl', get_user_preferences('hotpot_studentfeedbackurl', 'http://'));
408 set_form_field($form, 'forceplugins', get_user_preferences('hotpot_forceplugins', HOTPOT_NO));
409 if ($form->mode=='add') {
410 set_form_field($form, 'namesource', get_user_preferences('hotpot_namesource', HOTPOT_TEXTSOURCE_QUIZ));
411 set_form_field($form, 'summarysource', get_user_preferences('hotpot_summarysource', HOTPOT_TEXTSOURCE_QUIZ));
412 $quizchain = get_user_preferences('hotpot_quizchain', HOTPOT_NO);
413 } else {
414 $quizchain = empty($form->quizchain) ? HOTPOT_NO : HOTPOT_YES;
416 set_form_field($form, 'quizchain', $quizchain);
417 set_form_field($form, 'shownextquiz', get_user_preferences('hotpot_shownextquiz', HOTPOT_NO));
418 set_form_field($form, 'review', get_user_preferences('hotpot_review', HOTPOT_YES));
419 set_form_field($form, 'grade', get_user_preferences('hotpot_grade', 100));
420 set_form_field($form, 'grademethod', get_user_preferences('hotpot_grademethod', HOTPOT_GRADEMETHOD_HIGHEST));
421 set_form_field($form, 'attempts', get_user_preferences('hotpot_attempts', 0)); // 0=unlimited
422 set_form_field($form, 'password');
423 set_form_field($form, 'subnet', get_user_preferences('hotpot_subnet'));
424 set_form_field($form, 'clickreporting', HOTPOT_NO);
425 set_form_field($form, 'displaynext', get_user_preferences('hotpot_displaynext', HOTPOT_DISPLAYNEXT_QUIZ));
427 function set_form_field(&$form, $fieldname, $defaultvalue='') {
428 if (!isset($form->$fieldname)) {
429 $form->$fieldname = $defaultvalue;