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. -->
6 $CFG->dirroot
.DIRECTORY_SEPARATOR
.'mod'.DIRECTORY_SEPARATOR
.'hotpot'.DIRECTORY_SEPARATOR
.'lib.php'
9 // set default values in form fields, if necessary
10 set_form_fields($form);
12 // commonly used array of <SELECT> options
13 $yes_no_options = array(
14 HOTPOT_NO
=> get_string("no"),
15 HOTPOT_YES
=> get_string("yes")
20 <FORM name=
"form" method=
"post" action=
"<?php echo $ME ?>">
21 <TABLE cellpadding
="5">
23 <TD align
="right"><B
><?php
print_string("name") ?>:
</B></TD>
25 <INPUT type=
"text" name=
"name" size=
40 value=
"<?php p($form->name) ?>">
31 print_string("summary")
34 helpbutton("summary", get_string("summary"), "resource", true, true);
36 helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
38 if (isset($usehtmleditor) && $usehtmleditor) {
39 helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
42 helpbutton("text", get_string("helptext"), "moodle", true, true);
44 emoticonhelpbutton("form", "description");
49 <TD align=
"left"><?php
50 if (function_exists("print_textarea") && isset($usehtmleditor)) {
51 print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary
);
53 // Moodle 1.1.1 (original size was rows="5" cols="50")
54 print '<TEXTAREA name="summary" rows="10" cols="65" wrap="virtual">'.$form->summary
.'</TEXTAREA>';
59 <TD align=
"right"><B><?php print_string("quizopen", "quiz") ?>:
</B></TD>
60 <TD align=
"left"><?php
61 if (!$form->timeopen
and $course->format
== "weeks") {
62 $form->timeopen
= $course->startdate +
(($form->section
- 1) * 608400);
64 print_date_selector("openday", "openmonth", "openyear", $form->timeopen
);
66 print_time_selector("openhour", "openminute", $form->timeopen
);
67 helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
71 <TD align=
"right"><B><?php print_string("quizclose", "quiz") ?>:
</B></TD>
72 <TD align=
"left"><?php
73 if (!$form->timeclose
and $course->format
== "weeks") {
74 $form->timeclose
= $course->startdate +
(($form->section
) * 608400);
76 print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose
);
78 print_time_selector("closehour", "closeminute", $form->timeclose
);
79 helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
83 <TD align=
"right" nowrap
>
84 <B><?php echo get_string("location","hotpot") ?>:
</B>
86 <TD align=
"left"><?php
91 if ($course->id
==$site->id
) {
93 $location = HOTPOT_LOCATION_SITEFILES
;
95 $id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES
."?".$site->id
.":".$course->id
.")+'";
98 } else { // ordinary teacher or content creator
100 $location = HOTPOT_LOCATION_COURSEFILES
;
103 if (array_key_exists($location, $HOTPOT_LOCATION)) {
104 echo '<INPUT type="hidden" name="location" value="'.$location.'" />';
105 echo '<i><font size="-1">'.$HOTPOT_LOCATION[$location].'</font></i> ';
107 } else { // admin can select from "site" or "course" files
108 choose_from_menu($HOTPOT_LOCATION, "location", "$form->location", "");
112 if (function_exists("button_to_popup_window")) {
114 // use javascript to extract wdir from the reference field
115 $wdir = "'+getDir(getObjValue(this.form.reference))+'";
117 // set button url depending on Moodle version
118 if ($CFG->version
< 2004083125) { // version may need refining
119 // up to and including Moodle 1.4.1
120 $url = "/mod/resource/coursefiles.php?id=$id&wdir=$wdir";
122 // Moodle 1.4.2 and beyond
123 $url = "/files/index.php?id=$id&wdir=$wdir&choose=form.reference";
126 $strchooseafile = get_string("chooseafile", "resource");
127 button_to_popup_window ($url, 'coursefiles', $strchooseafile, 500, 750, $strchooseafile);
132 <TD align=
"right" nowrap
>
133 <B><?php print_string("filename", "resource") ?>:
</B>
135 <TD align=
"left"><?php
136 if (function_exists("button_to_popup_window")) {
137 echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\"> ";
139 } else if (function_exists("get_directory_list")) {
140 // Moodle 1.1 (and perhaps some others)
141 $dirs = get_directory_list("$CFG->dataroot/$course->id");
143 foreach ($dirs as $dir) {
144 $options["$dir"] = $dir;
146 choose_from_menu ($options, "reference", $form->reference
);
149 // a very old Moodle (may be none left :-)
150 echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\"> ";
153 hotpot_print_show_links($form->course
, $form->location
, $form->reference
, '', ' ', true);
157 <TD align=
"right"><B><?php print_string("navigation", "hotpot") ?>:
</B></TD>
158 <TD align=
"left"><?php
159 choose_from_menu($HOTPOT_NAVIGATION, "navigation", "$form->navigation", "");
160 helpbutton("navigation", get_string("navigation","hotpot"), "hotpot");
164 <TD align=
"right"><B><?php print_string("outputformat", "hotpot") ?>:
</B></TD>
165 <TD align=
"left"><?php
166 choose_from_menu($HOTPOT_OUTPUTFORMAT, "outputformat", "$form->outputformat", "");
167 helpbutton("outputformat", get_string("outputformat","hotpot"), "hotpot");
171 <TD align=
"right"><B><?php print_string("forceplugins", "hotpot") ?>:
</B></TD>
172 <TD align=
"left"><?php
173 choose_from_menu($yes_no_options, "forceplugins", "$form->forceplugins", "");
174 helpbutton("forceplugins", get_string("forceplugins","hotpot"), "hotpot");
178 <TD align=
"right"><B><?php print_string("shownextquiz", "hotpot") ?>:
</B></TD>
179 <TD align=
"left"><?php
180 choose_from_menu($yes_no_options, "shownextquiz", "$form->shownextquiz", "");
181 helpbutton("shownextquiz", get_string("shownextquiz","hotpot"), "hotpot");
185 <TD align=
"right"><B><?php print_string("allowreview", "quiz") ?>:
</B></TD>
186 <TD align=
"left"><?php
187 choose_from_menu($yes_no_options, "review", "$form->review", "");
188 helpbutton("review", get_string("allowreview","quiz"), "quiz");
192 <TD align=
"right"><B><?php print_string("maximumgrade") ?>:
</B></TD>
193 <TD align=
"left"><?php
195 for ($i=100; $i>=1; $i--) {
198 $options[0] = get_string("nograde");
200 choose_from_menu($options, "grade", "$form->grade", "");
201 helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
205 <TD align=
"right"><B><?php print_string("grademethod", "quiz") ?>:
</B></TD>
206 <TD align=
"left"><?php
207 choose_from_menu($HOTPOT_GRADEMETHOD, "grademethod", "$form->grademethod", "");
208 helpbutton("grademethod", get_string("grademethod","quiz"), "quiz");
212 <TD align=
"right"><B><?php print_string("attemptsallowed", "quiz") ?>:
</B></TD>
213 <TD align=
"left"><?php
215 0 => get_string("attemptsunlimited", "quiz"),
216 1 => '1 '.strtolower(get_string("attempt", "quiz"))
218 for ($i=2; $i<=10; $i++
) {
219 $options[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
221 choose_from_menu($options, "attempts", "$form->attempts", "");
222 helpbutton("attempts", get_string("attemptsallowed","quiz"), "quiz");
226 <TD align=
"right"><B><?php print_string("requirepassword", "quiz") ?>:
</B></TD>
228 <INPUT type=
"text" name=
"password" size=
40 value=
"<?php p($form->password) ?>">
229 <?php
helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
233 <TD align=
"right"><B><?php print_string("requiresubnet", "quiz") ?>:
</B></TD>
235 <INPUT type=
"text" name=
"subnet" size=
40 value=
"<?php p($form->subnet) ?>">
236 <?php
helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
241 <!-- hidden fields -->
242 <INPUT type=
"hidden" name=
"course" value=
"<?php p($form->course) ?>">
243 <INPUT type
="hidden" name
="coursemodule" value
="<?php p($form->coursemodule) ?>">
244 <INPUT type
="hidden" name
="section" value
="<?php p($form->section) ?>">
245 <INPUT type
="hidden" name
="module" value
="<?php p($form->module) ?>">
246 <INPUT type
="hidden" name
="modulename" value
="<?php p($form->modulename) ?>">
247 <INPUT type
="hidden" name
="instance" value
="<?php p($form->instance) ?>">
248 <INPUT type
="hidden" name
="mode" value
="<?php p($form->mode) ?>">
249 <?php
if (isset($USER->sesskey
)) { ?>
250 <INPUT type=
"hidden" name=
"sesskey" value=
"<?php p($USER->sesskey) ?>">
254 <INPUT type=
"submit" value=
"<?php print_string("savechanges
") ?>">  
;
255 <INPUT type
="submit" name
="cancel" value
="<?php print_string("cancel
") ?>" />
261 // ======================
263 // ======================
265 function set_form_fields(&$form) {
266 set_form_field($form, 'name');
267 set_form_field($form, 'summary');
268 set_form_field($form, 'timeopen');
269 set_form_field($form, 'timeclose');
270 set_form_field($form, 'location', HOTPOT_LOCATION_COURSEFILES
);
271 set_form_field($form, 'reference');
272 set_form_field($form, 'navigation', HOTPOT_NAVIGATION_BAR
);
273 set_form_field($form, 'outputformat', HOTPOT_OUTPUTFORMAT_BEST
);
274 set_form_field($form, 'forceplugins', HOTPOT_NO
);
275 set_form_field($form, 'shownextquiz', HOTPOT_NO
);
276 set_form_field($form, 'review', HOTPOT_YES
);
277 set_form_field($form, 'grade', 100);
278 set_form_field($form, 'grademethod', HOTPOT_GRADEMETHOD_HIGHEST
);
279 set_form_field($form, 'attempts', 0); // unlimited
280 set_form_field($form, 'password');
281 set_form_field($form, 'subnet');
283 function set_form_field(&$form, $fieldname, $defaultvalue='') {
284 if (!isset($form->$fieldname)) {
285 $form->$fieldname = $defaultvalue;