06a163abfe17a1e83fc9d5d0aae9bda7fb45cedb
[moodle.git] / course / edit.html
1 <?php
2     // Make sure all variables are defined
3     if (!isset($form->showreports)) {
4         $form->showreports = 0;
5     }
6     if (!isset($form->maxbytes)) {
7         $form->maxbytes = 0;
8     }
9     if (!isset($form->hiddensections)) {
10         $form->hiddensections = 0;
11     }
12     if (!isset($form->lang)) {
13         $form->lang = '';
14     }
15     if (!isset($form->theme)) {
16         $form->theme = '';
17     }
18     if (!isset($form->enrol)) {
19         $form->enrol = '';
20     }
21     if (!isset($form->enrollable)) {
22         $form->enrollable = 1;
23     }
24     if (!isset($form->enrolstartdate)) {
25         $form->enrolstartdate = 0;
26     }
27     if (!$form->enrolstartdate) {
28         $form->enrolstartdisabled = 1;
29     }
30     if (!isset($form->enrolenddate)) {
31         $form->enrolenddate = 0;
32     }
33     if (!$form->enrolenddate) {
34         $form->enrolenddisabled = 1;
35     }
36     if (!isset($form->enrolperiod)) {
37         $form->enrolperiod = 0;
38     }
39     if (!isset($form->expirynotify)) {
40         $form->expirynotify = 0;
41     }
42     if (!isset($form->notifystudents)) {
43         $form->notifystudents = 0;
44     }
45     if (!isset($form->expirythreshold)) {
46         $form->expirythreshold = 10 * 86400;
47     }
48     if (!isset($form->metacourse)) {
49         $form->metacourse = 0;
50     }
51     if(!isset($form->restrictmodules)) {
52         $form->restrictmodules = 0;
53     }
54 ?>
55 <form method="post" action="edit.php" name="form">
56 <table cellpadding="9" cellspacing="0" >
57 <?php if (iscreator()) { ?>
58 <tr valign="top">
59     <td align="right"><?php  print_string("category") ?>:</td>
60     <td><?php
61            $displaylist = array();
62            $parentlist = array();
63            make_categories_list($displaylist, $parentlist);
64            choose_from_menu($displaylist, "category", "$form->category", "");
65            helpbutton("coursecategory", get_string("category"));
66         ?>
67     </td>
68 </tr>
69 <?php } ?>
70 <tr valign="top">
71     <td align="right"><?php  print_string("fullname") ?>:</td>
72     <td><input type="text" name="fullname" maxlength="254" size="50" value="<?php  p($form->fullname) ?>" alt="<?php  print_string("fullname") ?>" />
73     <?php  helpbutton("coursefullname", get_string("fullname")) ?>
74     <?php  if (isset($err["fullname"])) formerr($err["fullname"]); ?>
75     </td>
76 </tr>
77 <tr valign="top">
78     <td align="right"><?php  print_string("shortname") ?>:</td>
79     <td><input type="text" name="shortname" maxlength="15"  size="10" value="<?php  p($form->shortname) ?>" alt="<?php  print_string("shortname") ?>" />
80     <?php  helpbutton("courseshortname", get_string("shortname")) ?>
81     <?php  if (isset($err["shortname"])) formerr($err["shortname"]); ?>
82     </td>
83 </tr>
84 <tr valign="top">
85     <td align="right"><?php  print_string("idnumbercourse") ?>:</td>
86     <td><input type="text" name="idnumber" maxlength="100"  size="10" value="<?php  p($form->idnumber) ?>" alt="><?php  print_string("idnumbercourse") ?>" />
87     <?php  helpbutton("courseidnumber", get_string("idnumbercourse")) ?>
88     <?php  if (isset($err["idnumber"])) formerr($err["idnumber"]); ?>
89     </td>
90 </tr>
91 <tr valign="top">
92     <td align="right"><?php  print_string("summary") ?>:</td>
93     <td><?php
94         print_textarea($usehtmleditor, 10, 50, 660, 200, "summary", $form->summary);
95         helpbutton("text", get_string("helptext"));
96         if (isset($err["summary"])) formerr($err["summary"]);
97     ?>
98     </td>
99 </tr>
100 <tr valign="top">
101     <td align="right"><?php  print_string("format") ?>:</td>
102     <td><?php
103            choose_from_menu ($form->courseformats, "format", "$form->format", "");
104            helpbutton("courseformats", get_string("courseformats"));
105         ?>
106     </td>
107 </tr>
108 <tr valign="top">
109     <td align="right"><?php  print_string("startdate") ?>:</td>
110     <td><?php
111            print_date_selector("startday", "startmonth", "startyear", $form->startdate);
112            helpbutton("coursestartdate", get_string("startdate"));
113     ?></td>
114 </tr>
115 <tr valign="top">
116     <td align="right"><?php  print_string("enrolmentplugins") ?>:</td>
117     <td><?php
118             unset($choices);
119             $modules = explode(',', $CFG->enrol_plugins_enabled);
120             foreach ($modules as $module) {
121                 $name = get_string("enrolname", "enrol_$module");
122                 $plugin = enrolment_factory::factory($module);
123                 if (method_exists($plugin, 'print_entry')) {
124                     $choices[$name] = $module;
125                 }
126             }
127             asort($choices);
128             $choices = array_flip($choices);
129             $choices = array_merge(array('' => get_string('sitedefault').' ('.get_string("enrolname", "enrol_$CFG->enrol").')'), $choices);
130             choose_from_menu ($choices, "enrol", "$form->enrol", "");
131             helpbutton("courseenrolmentplugins", get_string("enrolmentplugins"));
132     ?></td>
133 </tr>
134 <tr valign="top">
135     <td align="right"><?php  print_string("enrollable") ?>:</td>
136     <td><?php
137             unset($choices);
138             $choices["0"] = get_string("no");
139             $choices["1"] = get_string("yes");
140             $choices["2"] = get_string("enroldate");
141             choose_from_radio ($choices, "enrollable", "$form->enrollable", "");
142             helpbutton("courseenrollable", get_string("enrollable"));
143     ?></td>
144 </tr>
145 <tr valign="top" id="daterange">
146     <td align="right"><?php  print_string("enroldate") ?>:</td>
147     <td>
148         <table cellpadding="0" cellspacing="0">
149             <tr>
150                 <td align="right"><?php print_string('enrolstartdate') ?>: </td>
151                 <td><?php
152                     print_date_selector("enrolstartday", "enrolstartmonth", "enrolstartyear", $form->enrolstartdate);
153                     print_string('disable');
154                     echo ': ';
155                     print_checkbox('enrolstartdisabled', 1, "$form->enrolstartdisabled");
156                     ?></td>
157             </tr>
158             <tr>
159                 <td height="18" colspan="2"> </td>
160             </tr>
161             <tr>
162                 <td align="right"><?php print_string('enrolenddate') ?>: </td>
163                 <td><?php
164                     print_date_selector("enrolendday", "enrolendmonth", "enrolendyear", $form->enrolenddate);
165                     print_string('disable');
166                     echo ': ';
167                     print_checkbox('enrolenddisabled', 1, "$form->enrolenddisabled");
168                     if (isset($err["enroldate"])) formerr($err["enroldate"]);
169                     ?></td>
170             </tr>
171         </table>
172     </td>
173 </tr>
174 <tr valign="top">
175     <td align="right"><?php  print_string("enrolperiod") ?>:</td>
176     <td>
177         <?php
178             $periodmenu[0] = get_string('unlimited');
179             for ($i=1; $i<=365; $i++) {
180                 $seconds = $i * 86400;
181                 $periodmenu[$seconds] = get_string('numdays', '', $i);
182             }
183             choose_from_menu ($periodmenu, "enrolperiod", "$form->enrolperiod", "");
184             helpbutton("enrolperiod", get_string("enrolperiod"));
185         ?>
186     </td>
187 </tr><tr valign="top">
188     <td align="right"><?php  print_string("expirynotify") ?>:</td>
189     <td>
190         <?php
191             unset($choices);
192             $choices["0"] = get_string("no");
193             $choices["1"] = get_string("yes");
194             choose_from_menu ($choices, "expirynotify", "$form->expirynotify", "");
195             helpbutton("expirynotify", get_string("expirynotify"));
197             echo '&nbsp;&nbsp;&nbsp;&nbsp;';
198             print_string('expirynotifystudents');
199             echo ': ';
200             choose_from_menu ($choices, "notifystudents", "$form->notifystudents", "");
201             helpbutton("expirynotifystudents", get_string("expirynotifystudents"));
203             echo '&nbsp;&nbsp;&nbsp;&nbsp;';
204             print_string('expirythreshold');
205             echo ': ';
206             for ($i=1; $i<=30; $i++) {
207                 $seconds = $i * 86400;
208                 $thresholdmenu[$seconds] = get_string('numdays', '', $i);
209             }
210             choose_from_menu ($thresholdmenu, "expirythreshold", "$form->expirythreshold", "");
211             helpbutton("expirythreshold", get_string("expirythreshold"));
212         ?>
213     </td>
214 </tr>
215 <tr valign="top">
216     <td align="right"><?php  print_string("numberweeks") ?>:</td>
217     <td><?php
218            for ($i=1; $i<=52; $i++) {
219               $sectionmenu[$i] = "$i";
220            }
221            choose_from_menu ($sectionmenu, "numsections", "$form->numsections", "");
222            helpbutton("coursenumsections", get_string("numberweeks"));
223     ?></td>
224 </tr>
225 <tr valign="top">
226     <td align="right"><?php  print_string("groupmode") ?>:</td>
227     <td><?php
228     unset($choices);
229     $choices[NOGROUPS] = get_string("groupsnone");
230     $choices[SEPARATEGROUPS] = get_string("groupsseparate");
231     $choices[VISIBLEGROUPS] = get_string("groupsvisible");
232     choose_from_menu ($choices, "groupmode", $form->groupmode, "");
233     helpbutton("groupmode", get_string("groupmode"));
235     echo '&nbsp;&nbsp;&nbsp;&nbsp;';
236     print_string('force');
237     echo ': ';
238     unset($choices);
239     $choices["0"] = get_string("no");
240     $choices["1"] = get_string("yes");
241     choose_from_menu ($choices, "groupmodeforce", $form->groupmodeforce, "");
242     helpbutton("groupmodeforce", get_string("groupmodeforce")); ?>
243     </td>
244 </tr>
245 <tr valign="top">
246     <td align="right"><?php  print_string("availability") ?>:</td>
247     <td><?php
248     unset($choices);
249     $choices["0"] = get_string("courseavailablenot");
250     $choices["1"] = get_string("courseavailable");
251     choose_from_menu ($choices, "visible", $form->visible, "");
252     helpbutton("courseavailability", get_string("availability")); ?>
253     </td>
254 </tr>
255 <tr valign="top">
256     <td align="right"><?php  print_string("enrolmentkey") ?>:</td>
257     <td><input type="text" name="password" size="25" value="<?php  p($form->password) ?>" alt="<?php  print_string("enrolmentkey") ?>" />
258     <?php  helpbutton("enrolmentkey", get_string("enrolmentkey")) ?>
259     <?php  if (isset($err["password"])) formerr($err["password"]); ?>
260     </td>
261 </tr>
262 <tr valign="top">
263     <td align="right"><?php  print_string("opentoguests") ?>:</td>
264     <td><?php
265     unset($choices);
266     $choices["0"] = get_string("guestsno");
267     $choices["1"] = get_string("guestsyes");
268     $choices["2"] = get_string("guestskey");
269     choose_from_menu ($choices, "guest", $form->guest, "");
270     helpbutton("guestaccess", get_string("opentoguests")); ?>
271     </td>
272 </tr>
273 <?php
274     if (isset($course) && method_exists(enrolment_factory::factory($course->enrol), 'print_entry') && $course->enrol != 'manual') {
275 ?>
276 <tr valign="top">
277     <td align="right"><?php  print_string("cost") ?>:</td>
278     <td><input type="text" name="cost" maxlength="6" size="6" value="<?php  p($form->cost) ?>" alt="<?php  print_string("cost") ?>" />
279     <?php
280         $currencies = get_list_of_currencies();
281         choose_from_menu($currencies, 'currency', $form->currency, '');
282         helpbutton("cost", get_string("cost"));
283     ?>
284     </td>
285 </tr>
286 <?php
287     }
288 ?>
289 <tr valign="top">
290     <td align="right"><?php  print_string("hiddensections") ?>:</td>
291     <td><?php
292     unset($choices);
293     $choices["0"] = get_string("hiddensectionscollapsed");
294     $choices["1"] = get_string("hiddensectionsinvisible");
295     choose_from_menu ($choices, "hiddensections", $form->hiddensections, "");
296     helpbutton("coursehiddensections", get_string("hiddensections")); ?>
297     </td>
298 </tr>
299 <tr valign="top">
300     <td align="right"><?php  print_string("newsitemsnumber") ?>:</td>
301     <td><?php
302        $newsitem = get_string("newsitem");
303        $newsitems = get_string("newsitems");
305        $options = array("0" => "0 $newsitems",
306                         "1" => "1 $newsitem",
307                         "2" => "2 $newsitems",
308                         "3" => "3 $newsitems",
309                         "4" => "4 $newsitems",
310                         "5" => "5 $newsitems",
311                         "6" => "6 $newsitems",
312                         "7" => "7 $newsitems",
313                         "8" => "8 $newsitems",
314                         "9" => "9 $newsitems",
315                         "10" => "10 $newsitems");
316        choose_from_menu ($options, "newsitems", "$form->newsitems", "");
317        helpbutton("coursenewsitems", get_string("newsitemsnumber"));
318     ?>
319     </td>
320 </tr>
321 <tr valign="top">
322     <td align="right"><?php  print_string("showgrades") ?>:</td>
323     <td><?php
324     unset($choices);
325     $choices["0"] = get_string("no");
326     $choices["1"] = get_string("yes");
327     choose_from_menu ($choices, "showgrades", $form->showgrades, "");
328     helpbutton("coursegrades", get_string("grades")); ?>
329     </td>
330 </tr>
331 <tr valign="top">
332     <td align="right"><?php  print_string("showreports") ?>:</td>
333     <td><?php
334     unset($choices);
335     $choices["0"] = get_string("no");
336     $choices["1"] = get_string("yes");
337     choose_from_menu ($choices, "showreports", $form->showreports, "");
338     helpbutton("coursereports", get_string("activityreport")); ?>
339     </td>
340 </tr>
341 <tr valign="top">
342     <td align="right"><?php  print_string("maximumupload") ?>:</td>
343     <td><?php
344     $choices = get_max_upload_sizes($CFG->maxbytes);
345     choose_from_menu ($choices, "maxbytes", $form->maxbytes, "");
346     helpbutton("courseuploadsize", get_string("maximumupload")); ?>
347     </td>
348 </tr>
349 <tr valign="top">
350     <td align="right"><?php  print_string("wordforteacher") ?>:</td>
351     <td><input type="text" name="teacher" maxlength="100" size="25" value="<?php  p($form->teacher) ?>" alt="<?php  print_string("wordforteacher") ?>" />
352     (<?php  print_string("wordforteachereg") ?>)
353     <?php  if (isset($err["teacher"])) formerr($err["teacher"]); ?>
354     </td>
355 </tr>
356 <tr valign="top">
357     <td align="right"><?php  print_string("wordforteachers") ?>:</td>
358     <td><input type="text" name="teachers" maxlength="100" size="25" value="<?php  p($form->teachers) ?>" alt="<?php  print_string("wordforteachers") ?>" />
359     (<?php  print_string("wordforteacherseg") ?>)
360     <?php  if (isset($err["teachers"])) formerr($err["teachers"]); ?>
361     </td>
362 </tr>
363 <tr valign="top">
364     <td align="right"><?php  print_string("wordforstudent") ?>:</td>
365     <td><input type="text" name="student" maxlength="100" size="25" value="<?php  p($form->student) ?>" alt="<?php  print_string("wordforstudent") ?>" />
366     (<?php  print_string("wordforstudenteg") ?>)
367     <?php  if (isset($err["student"])) formerr($err["student"]); ?>
368     </td>
369 </tr>
370 <tr valign="top">
371     <td align="right"><?php  print_string("wordforstudents") ?>:</td>
372     <td><input type="text" name="students" maxlength="100" size="25" value="<?php  p($form->students) ?>" alt="<?php  print_string("wordforstudents") ?>" />
373     (<?php  print_string("wordforstudentseg") ?>)
374     <?php  if (isset($err["students"])) formerr($err["students"]); ?>
375     </td>
376 </tr>
377 <tr valign="top">
378     <td align="right"><?php  print_string("forcelanguage") ?>:</td>
379   <td>
380     <?php
381         $languages[''] = get_string("forceno");
382         $languages += get_list_of_languages();
383         choose_from_menu ($languages, "lang", $form->lang, "", "", "");
384     ?>
385     </td>
386 </tr>
387 <?php if (!empty($CFG->allowcoursethemes)) { ?>
388 <tr valign="top">
389     <td align="right"> <?php print_string("forcetheme") ?>: </td>
390     <td>
391       <?php
392          $themes[''] = get_string("forceno");
393          $themes += get_list_of_themes();
394          choose_from_menu($themes, 'theme', $form->theme, "", "", "");
395       ?>
396     </td>
397 </tr>
398 <?php } ?>
399 <tr valign="top">
400   <td align="right"><?php print_string("managemeta") ?>:</td>
401     <td>
402       <?php
403       if (empty($disable_meta)) {
404           $meta[0] = get_string('no');
405           $meta[1] = get_string('yes');
406           choose_from_menu($meta,"metacourse",$form->metacourse,"","","");
407       } else {
408           echo ((empty($form->metacourse)) ? get_string("no") : get_string("yes"));
409           echo " - $disable_meta ";
410       }
411       helpbutton("metacourse", get_string("metacourse"));?>
412     </td>
413 </tr>
414 <?php if (isadmin() && ((!empty($course->requested) && $CFG->restrictmodulesfor == 'requested') || $CFG->restrictmodulesfor == 'all')) { ?>
415 <tr valign="top">
416     <td align="right"><?php print_string("restrictmodules") ?>:</td>
417     <td valign="top"><table cellpadding="0" border="0"><tr valign="top"><td>
418     <script language="JavaScript">
419     function togglemodules(index) {
420         if (index == 0) {
421             document.getElementById('allowedmods').disabled=true;
422         }
423         else {
424             document.getElementById('allowedmods').disabled=false;
425         }
426     }
427     </script>
428     <?php
429     unset($options);
430     $options[0] = get_string("no");
431     $options[1] = get_string("yes");
432     choose_from_menu($options,"restrictmodules",$form->restrictmodules,"","togglemodules(this.selectedIndex);","");
433 ?>&nbsp;</td><td>&nbsp;<?php p(strtolower(get_string('to'))); ?>&nbsp;</td><td>&nbsp;
434     <select name="allowedmods[]" id="allowedmods" multiple="multiple" size="10" <?php echo ((empty($form->restrictmodules)) ? "disabled=\"disabled\"" : ""); ?>>
435     <?php
436     $mods = get_records("modules");
437     $s = "selected=\"selected\"";
438     echo '<option value="0" '.((empty($allowedmods)) ? $s : '').'>'.get_string('allownone').'</option>'."\n";
439     foreach ($mods as $mod) {
440         $selected = "";
441         if (in_array($mod->id,$allowedmods)) 
442             $selected = $s;
443         echo '<option '.$selected.' value="'.$mod->id.'">'.$mod->name.'</option>'."\n";
444     }  
445     ?>
446     </select></td></tr></table></td>
447 </tr>
448 <?php } else { ?>
449    <input type="hidden" name="restrictmodules" value="<?php p($form->restrictmodules); ?>" />
450 <?php } ?>
451 <tr>
452     <td></td>
453     <td><input type="submit" value="<?php  print_string("savechanges") ?>" /></td>
454 </tr>
455 </table>
456 <?php if(!iscreator()) { ?>
457 <input type="hidden" name="category" value="<?php echo $form->category ?>" />
458 <?php } ?>
459 <input type="hidden" name="id" value="<?php echo $form->id ?>" />
460 <input type="hidden" name="sesskey" value="<?php echo $form->sesskey ?>" />
461 </form>