Merge branch 'wip-MDL-39764_master_3' of git://github.com/gjb2048/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-06-04 01:36:16 +02:00
commit 00169e862e
2 changed files with 64 additions and 0 deletions

View file

@ -257,6 +257,38 @@ class format_topics extends format_base {
return $courseformatoptions;
}
/**
* Adds format options elements to the course/section edit form.
*
* This function is called from {@link course_edit_form::definition_after_data()}.
*
* @param MoodleQuickForm $mform form the elements are added to.
* @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form.
* @return array array of references to the added form elements.
*/
public function create_edit_form_elements(&$mform, $forsection = false) {
$elements = parent::create_edit_form_elements($mform, $forsection);
/*
* Increase the number of sections combo box values if the user has increased the number of sections
* using the icon on the course page beyond course 'maxsections' or course 'maxsections' has been
* reduced below the number of sections already set for the course on the site administration course
* defaults page. This is so that the number of sections is not reduced leaving unintended orphaned
* activities / resources.
*/
if (!$forsection) {
$maxsections = get_config('moodlecourse', 'maxsections');
$numsections = $mform->getElementValue('numsections');
$numsections = $numsections[0];
if ($numsections > $maxsections) {
$element = $mform->getElement('numsections');
for ($i = $maxsections+1; $i <= $numsections; $i++) {
$element->addOption("$i", $i);
}
}
}
return $elements;
}
/**
* Updates format options for a course
*

View file

@ -262,6 +262,38 @@ class format_weeks extends format_base {
return $courseformatoptions;
}
/**
* Adds format options elements to the course/section edit form.
*
* This function is called from {@link course_edit_form::definition_after_data()}.
*
* @param MoodleQuickForm $mform form the elements are added to.
* @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form.
* @return array array of references to the added form elements.
*/
public function create_edit_form_elements(&$mform, $forsection = false) {
$elements = parent::create_edit_form_elements($mform, $forsection);
/*
* Increase the number of sections combo box values if the user has increased the number of sections
* using the icon on the course page beyond course 'maxsections' or course 'maxsections' has been
* reduced below the number of sections already set for the course on the site administration course
* defaults page. This is so that the number of sections is not reduced leaving unintended orphaned
* activities / resources.
*/
if (!$forsection) {
$maxsections = get_config('moodlecourse', 'maxsections');
$numsections = $mform->getElementValue('numsections');
$numsections = $numsections[0];
if ($numsections > $maxsections) {
$element = $mform->getElement('numsections');
for ($i = $maxsections+1; $i <= $numsections; $i++) {
$element->addOption("$i", $i);
}
}
}
return $elements;
}
/**
* Updates format options for a course
*