Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-36795

In the default course settings, numsections is not limited to maxsections

    Details

    • Testing Instructions:
      Hide

      Test steps

      1. Log in as the administrator.
      2. Go to [Settings ► Site administration ► Courses ► Course default settings].
      3. Set 'Maximum for number of weeks/topics' to 0 and save changes.
        • Check that 'Number of weeks/topics' is set to 0 and that this is the only option.
      4. Set 'Maximum for number of weeks/topics' to nothing and save changes.
        • Check that 'Number of weeks/topics' now has the option to go up to 52.
      5. Create a new course [Settings ► Site administration ► Courses ► Add/edit courses].
      6. Select 'Weekly format'.
        • In the section 'Formatting options for Weekly format' check that 'Number of weeks/topics' has the option to go up to 52.
      7. Change the format to 'Topics format'.
        • In the section 'Formatting options for Topics format' check that 'Number of weeks/topics' has the option to go up to 52.
      Show
      Test steps Log in as the administrator. Go to [Settings ► Site administration ► Courses ► Course default settings] . Set 'Maximum for number of weeks/topics' to 0 and save changes. Check that 'Number of weeks/topics' is set to 0 and that this is the only option. Set 'Maximum for number of weeks/topics' to nothing and save changes. Check that 'Number of weeks/topics' now has the option to go up to 52. Create a new course [Settings ► Site administration ► Courses ► Add/edit courses] . Select 'Weekly format'. In the section 'Formatting options for Weekly format' check that 'Number of weeks/topics' has the option to go up to 52. Change the format to 'Topics format'. In the section 'Formatting options for Topics format' check that 'Number of weeks/topics' has the option to go up to 52.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-36795-master

      Description

      When controlling the maximum number of sections allowed in a course and the default number of sections in a new course, the number of sections should be limited by the maximum value.

      Reproduction steps:

      1. Log in as admin
      2. Navigate to "Course default settings" (Settings -> Site administration -> Courses -> Course default settings)
      3. Change "Maximum for number of weeks/topics moodlecourse | maxsections" to 0
      4. Click save changes
      5. Check "Number of weeks/topics moodlecourse | numsections" drop-down

      Expected result: The number of weeks/topics should only show 0

      Actual result: The number of weeks/topics shows numbers from 0 to 52

      Currently the function that controls this value is in lib/adminlib.php...

      lib/adminlib.php, lines 3813 to 3829
      class admin_settings_num_course_sections extends admin_setting_configselect {
          public function __construct($name, $visiblename, $description, $defaultsetting) {
              parent::__construct($name, $visiblename, $description, $defaultsetting, array());
          }
      
          /** Lazy-load the available choices for the select box */
          public function load_choices() {
              $max = get_config('moodlecourse', 'maxsections');
              if (empty($max)) {
                  $max = 52;
              }
              for ($i = 0; $i <= $max; $i++) {
                  $this->choices[$i] = "$i";
              }
              return true;
          }
      }
      

      The check to see if the maximum value is set fails to allow for a value of zero. Changing the check to use !isset() instead of empty resolves this.

      if (!isset($max)) {
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    14/Jan/13