2 // Make sure all variables are defined
3 if (!isset($form->showreports
)) {
4 $form->showreports
= 0;
6 if (!isset($form->maxbytes
)) {
9 if (!isset($form->hiddensections
)) {
10 $form->hiddensections
= 0;
12 if (!isset($form->lang
)) {
15 if (!isset($form->theme
)) {
18 if (!isset($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
))) { ?>
62 <td align=
"right"><?php print_string("category") ?>:
</td>
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"));
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"]); ?>
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"]); ?>
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"]); ?>
95 <td align=
"right"><?php print_string("summary") ?>:
</td>
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"]);
104 <td align=
"right"><?php print_string("format") ?>:
</td>
106 choose_from_menu ($form->courseformats
, "format", "$form->format", "");
107 helpbutton("courseformats", get_string("courseformats"));
112 <td align=
"right"><?php print_string("startdate") ?>:
</td>
114 print_date_selector("startday", "startmonth", "startyear", $form->startdate
);
115 helpbutton("coursestartdate", get_string("startdate"));
119 <td align=
"right"><?php print_string("enrolmentplugins") ?>:
</td>
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;
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"));
138 <td align=
"right"><?php print_string('defaultrole', 'role') ?>:
</td>
140 $roles = get_assignable_roles($context);
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
.')';
148 $choices[-1] = get_string('currentrole', 'role');
152 if ($sitedefaultrole = get_record('role', 'id', $CFG->defaultcourseroleid
)) {
153 $choices[0] = get_string('sitedefault').' ('.$sitedefaultrole->name
.')';
155 $choices[0] = get_string('sitedefault');
158 $choices = $choices +
$roles;
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"));
170 <td align=
"right"><?php print_string("enrollable") ?>:
</td>
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"));
180 <tr valign=
"top" id=
"daterange">
181 <td align=
"right"><?php print_string("enroldate") ?>:
</td>
183 <table cellpadding=
"0" cellspacing=
"0">
185 <td align=
"right"><?php print_string('enrolstartdate') ?>:
</td>
187 print_date_selector("enrolstartday", "enrolstartmonth", "enrolstartyear", $form->enrolstartdate
);
188 print_string('disable');
190 print_checkbox('enrolstartdisabled', 1, "$form->enrolstartdisabled");
194 <td height=
"18" colspan=
"2"> </td>
197 <td align=
"right"><?php print_string('enrolenddate') ?>:
</td>
199 print_date_selector("enrolendday", "enrolendmonth", "enrolendyear", $form->enrolenddate
);
200 print_string('disable');
202 print_checkbox('enrolenddisabled', 1, "$form->enrolenddisabled");
203 if (isset($err["enroldate"])) formerr($err["enroldate"]);
210 <td align=
"right"><?php print_string("enrolperiod") ?>:
</td>
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"));
222 </tr><tr valign=
"top">
223 <td align=
"right"><?php print_string("expirynotify") ?>:
</td>
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 ' ';
233 print_string('expirynotifystudents');
235 choose_from_menu ($choices, "notifystudents", "$form->notifystudents", "");
236 helpbutton("expirynotifystudents", get_string("expirynotifystudents"));
238 echo ' ';
239 print_string('expirythreshold');
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"));
251 <td align=
"right"><?php print_string("numberweeks") ?>:
</td>
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"));
261 <td align=
"right"><?php print_string("groupmode") ?>:
</td>
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 ' ';
271 print_string('force');
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")); ?>
281 <td align=
"right"><?php print_string("availability") ?>:
</td>
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")); ?>
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"]); ?>
298 <td align=
"right"><?php print_string("opentoguests") ?>:
</td>
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")); ?>
309 if (isset($course) && method_exists(enrolment_factory
::factory($course->enrol
), 'print_entry') && $course->enrol
!= 'manual') {
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
") ?>" />
315 $currencies = get_list_of_currencies();
316 choose_from_menu($currencies, 'currency', $form->currency
, '');
317 helpbutton("cost", get_string("cost"));
325 <td align=
"right"><?php print_string("hiddensections") ?>:
</td>
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")); ?>
335 <td align=
"right"><?php print_string("newsitemsnumber") ?>:
</td>
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"));
357 <td align=
"right"><?php print_string("showgrades") ?>:
</td>
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")); ?>
367 <td align=
"right"><?php print_string("showreports") ?>:
</td>
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")); ?>
377 <td align=
"right"><?php print_string("maximumupload") ?>:
</td>
379 $choices = get_max_upload_sizes($CFG->maxbytes
);
380 choose_from_menu ($choices, "maxbytes", $form->maxbytes
, "");
381 helpbutton("courseuploadsize", get_string("maximumupload")); ?>
385 <td align=
"right"><?php print_string("forcelanguage") ?>:
</td>
388 $languages[''] = get_string("forceno");
389 $languages +
= get_list_of_languages();
390 choose_from_menu ($languages, "lang", $form->lang
, "", "", "");
394 <?php if (!empty($CFG->allowcoursethemes
)) { ?>
396 <td align=
"right"> <?php print_string("forcetheme") ?>:
</td>
399 $themes[''] = get_string("forceno");
400 $themes +
= get_list_of_themes();
401 choose_from_menu($themes, 'theme', $form->theme
, "", "", "");
407 <td align=
"right"><?php print_string("managemeta") ?>:
</td>
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
,"","","");
415 echo ((empty($form->metacourse
)) ?
get_string("no") : get_string("yes"));
416 echo " - $disable_meta ";
418 helpbutton("metacourse", get_string("metacourse"));?>
421 <?php if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM
, SITEID
)) && ((!empty($course->requested
) && $CFG->restrictmodulesfor
== 'requested') ||
$CFG->restrictmodulesfor
== 'all')) { ?>
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
) {
428 document
.getElementById('allowedmods').disabled
=true;
431 document
.getElementById('allowedmods').disabled
=false;
437 $options[0] = get_string("no");
438 $options[1] = get_string("yes");
439 choose_from_menu($options,"restrictmodules",$form->restrictmodules
,"","togglemodules(this.selectedIndex);","");
440 ?> </td><td> <?php p(moodle_strtolower(get_string('to')));
?> </td><td>
441 <select name=
"allowedmods[]" id=
"allowedmods" multiple=
"multiple" size=
"10" <?php echo ((empty($form->restrictmodules
)) ?
"disabled=\"disabled\"" : ""); ?>>
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) {
448 if (in_array($mod->id
,$allowedmods))
450 echo '<option '.$selected.' value="'.$mod->id
.'">'.$mod->name
.'</option>'."\n";
453 </select></td></tr></table></td>
456 <input type=
"hidden" name=
"restrictmodules" value=
"<?php p($form->restrictmodules); ?>" />
460 <td><input type=
"submit" value=
"<?php print_string("savechanges
") ?>" /></td
>
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 ?>" />
466 <input type=
"hidden" name=
"id" value=
"<?php echo $form->id ?>" />
467 <input type
="hidden" name
="sesskey" value
="<?php echo $form->sesskey ?>" />