Merged from HEAD
[moodle.git] / mod / choice / mod.html
blobe61f9eec777b05d185a27a5e168c2ef52b2ddc28
1 <?php
2 if (empty($form->name)) {
3 $form->name = "";
5 if (empty($form->text)) {
6 $form->text = "";
8 if (empty($form->format)) {
9 $form->format = 0;
11 if (empty($form->display)) {
12 $form->display = 0;
14 if (empty($form->timeopen)) {
15 $form->timeopen = "";
16 $form->timerestrict = 0;
17 } else {
18 $form->timerestrict = 1;
20 if (empty($form->timeclose)) {
21 $form->timeclose = "";
23 if (empty($form->publish)) {
24 $form->publish = 0;
26 if (empty($form->release)) {
27 $form->release = 0;
29 if (empty($form->allowupdate)) {
30 $form->allowupdate = 0;
32 if (empty($form->showunanswered)) {
33 $form->showunanswered = 0;
35 if (empty($form->limitanswers)) {
36 $form->limitanswers = 0;
40 <script type="text/javascript">
41 function lockselects(form, master, subitems) {
42 // subitems is an array of names of sub items
43 // requires that each item in subitems has a
44 // companion hidden item in the form with the
45 // same name but prefixed by "h"
46 // master is the name of the selct
47 // x is the option that is selcted to enforce the lock.
48 if (eval("document."+form+"."+master+".selected")) {
49 for (i=0; i<subitems.length; i++) {
50 lockoption(form, subitems[i]);
52 } else {
53 for (i=0; i<subitems.length; i++) {
54 unlockoption(form, subitems[i]);
57 return(true);
60 </script>
61 <form name="form" method="post" action="mod.php">
63 <table cellpadding="5">
65 <tr valign="top">
66 <td align="right"><strong><?php print_string("choicename","choice") ?>:</strong></td>
67 <td colspan="2">
68 <input type="text" name="name" size="30" alt="<?php print_string("choicename","choice") ?>" value="<?php p($form->name) ?>" />
69 </td>
70 </tr>
72 <tr valign="top">
73 <td align="right"><strong><?php print_string("choicetext","choice") ?>:</strong><br /><br />
74 <?php
75 helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
76 echo "<br />";
77 helpbutton("questions", get_string("helpquestions"), "moodle", true, true);
78 echo "<br />";
79 if ($usehtmleditor) {
80 helpbutton("richtext", get_string("helprichtext"), "moodle", true, true);
81 } else {
82 emoticonhelpbutton("form", "text");
84 echo "<br />";
86 </td>
87 <td colspan="2">
88 <?php
89 print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $form->text);
91 if ($usehtmleditor) {
92 echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
93 } else {
94 echo "<div align=\"right\">";
95 helpbutton("textformat", get_string("formattexttype"));
96 print_string("formattexttype");
97 echo ":&nbsp;";
98 if (!$form->format) {
99 $form->format = $defaultformat;
101 choose_from_menu(format_text_menu(), "format", $form->format, "");
102 echo "</div>";
105 </td>
106 </tr>
108 <?php
109 $standardblanks = 10;
110 $count = 0;
111 $limitfieldlist = '';
112 if (($options = get_records_menu('choice_options','choiceid', $form->instance, 'id', 'id,text')) && ($options2 = get_records_menu('choice_options','choiceid', $form->instance, 'id', 'id,maxanswers')) ) {
113 foreach ($options as $id => $text) {
114 $count++;
116 <tr valign=top>
117 <td align="right"><strong><?php echo get_string("choice","choice").' '.$count; ?>:</strong></td>
118 <td>
119 <input type="text" name="oldoption<?php p($id) ?>" size="60" value="<?php p($text) ?>" id="oldoption<?php p($id) ?>" />
120 <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
121 </td>
122 <td align="right"><strong><?php p(get_string("limit","choice")) ?>:</strong>
123 <input type="text" name="oldlimit<?php p($id) ?>" size="4" value="<?php p($options2[$id]) ?>" id="oldlimit<?php p($id) ?>" />
124 <input type="hidden" name="holdlimit<?php p($id) ?>" value="0"/>
125 </td>
126 </tr>
127 <?php
128 $limitfieldlist .= "'oldlimit".$id."',";
130 $standardblanks = 2;
132 for ($i=1; $i<=$standardblanks; $i++) {
133 $count++;
135 <tr valign=top>
136 <td align="right"><strong><?php echo get_string("choice","choice").' '.$count; ?>:</strong></td>
137 <td>
138 <input type="text" name="newoption<?php p($i) ?>" size="60" value="" id="newoption<?php p($i) ?>">
139 <?php helpbutton("options", get_string("modulenameplural", "choice"), "choice") ?>
140 </td>
141 <td align="right"><strong><?php p(get_string("limit","choice")) ?>:</strong>
142 <input type="text" name="newlimit<?php p($i)?>" size="4" value="0" id="newlimit<?php p($i) ?>" />
143 <input type="hidden" name="hnewlimit<?php p($i) ?>" value="0" />
144 </td>
145 </tr>
146 <?php
147 $limitfieldlist .= "'newlimit".$i."',";
149 $limitfieldlist = trim($limitfieldlist, ",");
151 <script type="text/javascript">
152 limititems = [<?php p($limitfieldlist); ?>];
153 </script>
155 <tr valign="top">
156 <td align="right" colspan="2"><strong><?php print_string("limitanswers", "choice") ?>:</strong></td>
157 <td align="right">
158 <?php
159 $menuoptions[0] = get_string("disable");
160 $menuoptions[1] = get_string("enable");
161 helpbutton("limit", get_string("limit", "choice"), "choice");
162 echo '&nbsp;';
163 choose_from_menu($menuoptions, "limitanswers", "$form->limitanswers", "", "return lockselects('form','limitanswers.options[0]', limititems)");
165 </td>
166 </tr>
168 <?php if ($form->limitanswers == 0) { //lock the limit fields if limit isn't used. ?>
169 <script type="text/javascript">
170 lockoptions('form','limitanswers', limititems);
171 </script>
172 <?php }?>
174 <tr valign="top">
175 <td align="right"><strong><?php print_string("timerestrict", "choice") ?>:</strong></td>
176 <td colspan="2">
177 <script type="text/javascript">
178 var timeitems = ['openday','openmonth','openyear','openhour', 'openminute', 'closeday','closemonth','closeyear','closehour','closeminute'];
179 </script>
181 <input name="timerestrict" type="checkbox" value="1" alt="<?php print_string("timerestrict", "choice") ?>" onclick="return lockoptions('form','timerestrict', timeitems)" <?php if ($form->timerestrict) echo 'checked="checked"'; ?> />
182 <?php
183 helpbutton("timerestrict", get_string("timerestrict","choice"), "choice");
185 </td>
186 </tr>
187 <tr valign="top">
188 <td>&nbsp;</td>
189 <td colspan="2">
190 <table>
191 <tr>
192 <td align="right"><strong><?php print_string("choiceopen", "choice") ?>:</strong></td>
193 <td>
195 <?php
196 if (!$form->timeopen and $course->format == "weeks") {
197 $form->timeopen = $course->startdate + (($form->section - 1) * 608400);
199 print_date_selector("openday", "openmonth", "openyear", $form->timeopen);
200 print_time_selector("openhour", "openminute", $form->timeopen);
203 <input type="hidden" name="hopenday" value="0" />
204 <input type="hidden" name="hopenmonth" value="0" />
205 <input type="hidden" name="hopenyear" value="0" />
206 <input type="hidden" name="hopenhour" value="0" />
207 <input type="hidden" name="hopenminute" value="0" />
208 </td>
209 </tr>
210 <tr>
211 <td align="right"><strong><?php print_string("choiceclose", "choice") ?>:</strong></td>
212 <td>
214 <?php
215 if (!$form->timeclose and $course->format == "weeks") {
216 $form->timeclose = $course->startdate + (($form->section) * 608400);
218 print_date_selector("closeday", "closemonth", "closeyear", $form->timeclose);
219 print_time_selector("closehour", "closeminute", $form->timeclose);
222 <input type="hidden" name="hcloseday" value="0" />
223 <input type="hidden" name="hclosemonth" value="0" />
224 <input type="hidden" name="hcloseyear" value="0" />
225 <input type="hidden" name="hclosehour" value="0" />
226 <input type="hidden" name="hcloseminute" value="0" />
228 <?php
229 if (! $form->timerestrict) {
230 echo "<script type=\"text/javascript\">";
231 echo "lockoptions('form','timerestrict', timeitems);";
232 echo "</script>\n";
236 </td>
237 </tr>
238 </table>
240 </td>
241 </tr>
243 <tr valign="top">
244 <td align="right"><strong><?php print_string("displaymode","choice") ?>:</strong></td>
245 <td colspan="2">
246 <?php
247 require_once("$CFG->dirroot/mod/choice/lib.php");
248 choose_from_menu($CHOICE_DISPLAY, "display", "$form->display", "");
250 <br />
251 </td>
252 </tr>
254 <tr valign="top">
255 <td align="right"><strong><?php print_string("publish","choice") ?>:</strong></td>
256 <td colspan="2">
257 <?php
258 require_once("$CFG->dirroot/mod/choice/lib.php");
259 choose_from_menu($CHOICE_RELEASE, "release", "$form->release", "", "return lockselects('form','release.options[0]',['publish'])");
261 <br />
262 </td>
263 </tr>
265 <tr valign="top">
266 <td align="right"><strong><?php print_string("privacy","choice") ?>:</strong></td>
267 <td colspan="2">
268 <?php
269 require_once("$CFG->dirroot/mod/choice/lib.php");
270 choose_from_menu($CHOICE_PUBLISH, "publish", "$form->publish", "");
272 <br />
273 <input type="hidden" name="hpublish" value="0" />
274 </td>
275 </tr>
276 <script type="text/javascript">
277 lockselects('form','release.options[0]',['publish']);
278 </script>
280 <tr valign="top">
281 <td align="right"><strong><?php print_string("allowupdate","choice") ?>:</strong></td>
282 <td colspan="2">
283 <?php
284 $menuoptions[0] = get_string("no");
285 $menuoptions[1] = get_string("yes");
286 choose_from_menu($menuoptions, "allowupdate", "$form->allowupdate", "");
288 <br />
289 </td>
290 </tr>
293 <tr valign="top">
294 <td align="right"><strong><?php print_string("showunanswered","choice") ?>:</strong></td>
295 <td colspan="2">
296 <?php
297 $menuoptions[0] = get_string("no");
298 $menuoptions[1] = get_string("yes");
299 choose_from_menu($menuoptions, "showunanswered", "$form->showunanswered", "");
301 <br />
302 </td>
303 </tr>
304 <?php print_standard_coursemodule_settings($form); ?>
305 </table>
307 <center>
308 <input type="hidden" name="course" value="<?php p($form->course) ?>" />
309 <input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
310 <input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
311 <input type="hidden" name="section" value="<?php p($form->section) ?>" />
312 <input type="hidden" name="module" value="<?php p($form->module) ?>" />
313 <input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
314 <input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
315 <input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
316 <input type="submit" value="<?php print_string("savechanges") ?>" />
317 <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
318 </center>
319 </form>