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