MDL-36017 Fields numsections, hiddensections and coursedisplay are now format-specific options

- Fields added to format_legacy as default course format options;
- Upgrade script copies fields values from table course to course_format_options;
- Fields removed from table course;
- Fields removed from edit course form;
- Since front-page course has a 'numsections' setting, format_site defines it as it's option;
- Removed accessing those fields in core code unless we know that format supports them and in this
  case instead of $course = $DB->get_record('course'); we use:
  $course = course_get_format($courseorid)->get_course(); This way all format-specific options
  are added to the $course object
This commit is contained in:
Marina Glancy
2012-11-02 10:56:19 +08:00
parent 7b7d2f4d12
commit b5cf83f080
24 changed files with 196 additions and 99 deletions
-19
View File
@@ -126,29 +126,10 @@ class course_edit_form extends moodleform {
$mform->registerNoSubmitButton('updatecourseformat');
$mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
$mform->addElement('select', 'coursedisplay', get_string('coursedisplay'),
array(COURSE_DISPLAY_SINGLEPAGE => get_string('coursedisplay_single'),
COURSE_DISPLAY_MULTIPAGE => get_string('coursedisplay_multi')));
$mform->addHelpButton('coursedisplay', 'coursedisplay');
$mform->setDefault('coursedisplay', $courseconfig->coursedisplay);
for ($i = 0; $i <= $courseconfig->maxsections; $i++) {
$sectionmenu[$i] = "$i";
}
$mform->addElement('select', 'numsections', get_string('numberweeks'), $sectionmenu);
$mform->setDefault('numsections', $courseconfig->numsections);
$mform->addElement('date_selector', 'startdate', get_string('startdate'));
$mform->addHelpButton('startdate', 'startdate');
$mform->setDefault('startdate', time() + 3600 * 24);
$choices = array();
$choices['0'] = get_string('hiddensectionscollapsed');
$choices['1'] = get_string('hiddensectionsinvisible');
$mform->addElement('select', 'hiddensections', get_string('hiddensections'), $choices);
$mform->addHelpButton('hiddensections', 'hiddensections');
$mform->setDefault('hiddensections', $courseconfig->hiddensections);
$options = range(0, 10);
$mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
$mform->addHelpButton('newsitems', 'newsitemsnumber');