Incorrect variable name used for parameter.
[moodle-linuxchix.git] / mod / hotpot / mod.html
blob661c63e94635d1b5bf7b8d2ea690058432bab30a
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
5 require_once(
6 $CFG->dirroot.DIRECTORY_SEPARATOR.'mod'.DIRECTORY_SEPARATOR.'hotpot'.DIRECTORY_SEPARATOR.'lib.php'
7 );
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")
19 <CENTER>
20 <FORM name="form" method="post" action="<?php echo $ME ?>">
21 <TABLE cellpadding="5">
22 <TR valign="top">
23 <TD align="right"><B><?php print_string("name") ?>:</B></TD>
24 <TD align="left">
25 <INPUT type="text" name="name" size=40 value="<?php p($form->name) ?>">
26 </TD>
27 </TR>
28 <TR valign="top">
29 <TD align="right">
30 <B><?php
31 print_string("summary")
32 ?>:</B>
33 <FONT size="1"><?php
34 helpbutton("summary", get_string("summary"), "resource", true, true);
35 echo '<BR />';
36 helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
37 echo '<BR />';
38 if (isset($usehtmleditor) && $usehtmleditor) {
39 helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
40 echo '<BR />';
41 } else {
42 helpbutton("text", get_string("helptext"), "moodle", true, true);
43 echo '<BR />';
44 emoticonhelpbutton("form", "description");
45 echo '<BR />';
47 ?></FONT>
48 </TD>
49 <TD align="left"><?php
50 if (function_exists("print_textarea") && isset($usehtmleditor)) {
51 print_textarea($usehtmleditor, 10, 65, 680, 400, "summary", $form->summary);
52 } else {
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>';
56 ?></TD>
57 </TR>
58 <TR valign="top">
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);
65 print ' - ';
66 print_time_selector("openhour", "openminute", $form->timeopen);
67 helpbutton("timeopen", get_string("quizopen","quiz"), "quiz");
68 ?></TD>
69 </TR>
70 <TR valign="top">
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);
77 print ' - ';
78 print_time_selector("closehour", "closeminute", $form->timeclose);
79 helpbutton("timeopen", get_string("quizclose","quiz"), "quiz");
80 ?></TD>
81 </TR>
82 <TR valign="top">
83 <TD align="right" nowrap>
84 <B><?php echo get_string("location","hotpot") ?>:</B>
85 </TD>
86 <TD align="left"><?php
89 if (isadmin()) {
90 $site = get_site();
91 if ($course->id==$site->id) {
92 $id = $site->id;
93 $location = HOTPOT_LOCATION_SITEFILES;
94 } else {
95 $id = "'+(getObjValue(this.form.location)==".HOTPOT_LOCATION_SITEFILES."?".$site->id.":".$course->id.")+'";
96 $location = '';
98 } else { // ordinary teacher or content creator
99 $id = $course->id;
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> &nbsp; ';
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";
121 } else {
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);
129 ?></TD>
130 </TR>
131 <TR valign="top">
132 <TD align="right" nowrap>
133 <B><?php print_string("filename", "resource") ?>:</B>
134 </TD>
135 <TD align="left"><?php
136 if (function_exists("button_to_popup_window")) {
137 echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\">&nbsp;";
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");
142 $options = array();
143 foreach ($dirs as $dir) {
144 $options["$dir"] = $dir;
146 choose_from_menu ($options, "reference", $form->reference);
148 } else {
149 // a very old Moodle (may be none left :-)
150 echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\">&nbsp;";
152 echo '<BR>';
153 hotpot_print_show_links($form->course, $form->location, $form->reference, '', ' &nbsp; ', true);
154 ?></TD>
155 </TR>
156 <TR valign="top">
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");
161 ?></TD>
162 </TR>
163 <TR valign="top">
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");
168 ?></TD>
169 </TR>
170 <TR valign="top">
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");
175 ?></TD>
176 </TR>
177 <TR valign="top">
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");
182 ?></TD>
183 </TR>
184 <TR valign="top">
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");
189 ?></TD>
190 </TR>
191 <TR valign="top">
192 <TD align="right"><B><?php print_string("maximumgrade") ?>:</B></TD>
193 <TD align="left"><?php
194 $options = array();
195 for ($i=100; $i>=1; $i--) {
196 $options[$i] = $i;
198 $options[0] = get_string("nograde");
200 choose_from_menu($options, "grade", "$form->grade", "");
201 helpbutton("maxgrade", get_string("maximumgrade"), "quiz");
202 ?></TD>
203 </TR>
204 <TR valign="top">
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");
209 ?></TD>
210 </TR>
211 <TR valign="top">
212 <TD align="right"><B><?php print_string("attemptsallowed", "quiz") ?>:</B></TD>
213 <TD align="left"><?php
214 $options = array(
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");
223 ?></TD>
224 </TR>
225 <TR valign="top">
226 <TD align="right"><B><?php print_string("requirepassword", "quiz") ?>:</B></TD>
227 <TD align="left">
228 <INPUT type="text" name="password" size=40 value="<?php p($form->password) ?>">
229 <?php helpbutton("requirepassword", get_string("requirepassword", "quiz"), "quiz"); ?>
230 </TD>
231 </TR>
232 <TR valign="top">
233 <TD align="right"><B><?php print_string("requiresubnet", "quiz") ?>:</B></TD>
234 <TD align="left">
235 <INPUT type="text" name="subnet" size=40 value="<?php p($form->subnet) ?>">
236 <?php helpbutton("requiresubnet", get_string("requiresubnet", "quiz"), "quiz"); ?>
237 </TD>
238 </TR>
239 </TABLE>
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) ?>">
251 <?php } ?>
253 <!-- buttons -->
254 <INPUT type="submit" value="<?php print_string("savechanges") ?>"> &nbsp;
255 <INPUT type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
257 </FORM>
258 </CENTER>
259 <?php
261 // ======================
262 // functions
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;