Permalink
Browse files

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

… into MOODLE_25_STABLE
  • Loading branch information...
2 parents ca7f399 + 3b4752e commit 8a2cee5091bc5f3874ae436baa1b8e08b0dfc2a7 @stronk7 stronk7 committed Jun 3, 2013
Showing with 64 additions and 0 deletions.
  1. +32 −0 course/format/topics/lib.php
  2. +32 −0 course/format/weeks/lib.php
@@ -257,6 +257,38 @@ public function course_format_options($foreditform = false) {
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
*
@@ -262,6 +262,38 @@ public function course_format_options($foreditform = false) {
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
*

0 comments on commit 8a2cee5

Please sign in to comment.