From dbaa0e20e42c55e6d01b794cf6a4d9026366e8c3 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Thu, 28 Sep 2023 11:42:44 +0100 Subject: [PATCH] Possible --- format.php | 12 +++++------- lib.php | 8 -------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/format.php b/format.php index 1ade4f81..c537c9b1 100755 --- a/format.php +++ b/format.php @@ -59,13 +59,11 @@ global $DB; $numsections = $DB->get_field_sql('SELECT max(section) from {course_sections} WHERE course = ?', [$course->id]); - if (empty($numsections)) { - /* Sections not created, so we need to use the default course setting, - which could be zero but this will still work. */ - $numsections = get_config('moodlecourse', 'numsections'); - } - $format->set_gnumsections($numsections); - $courseformatoptions['gnumsections'] = $numsections; + if (!empty($numsections)) { + // Sections created, so we need set gnumsections to this. + $courseformatoptions['gnumsections'] = $numsections; + } // Else remain the same. + $format->set_gnumsections($courseformatoptions['gnumsections']); $courseformatoptions['gnumsectionsnewcourse'] = 0; } diff --git a/lib.php b/lib.php index a813d6df..c6b15d68 100755 --- a/lib.php +++ b/lib.php @@ -539,14 +539,6 @@ public function create_edit_form_elements(&$mform, $forsection = false) { "$CFG->dirroot/course/format/grid/form/sectionfilemanager.php", 'MoodleQuickForm_sectionfilemanager'); - if (!$forsection) { - // The course edit form is displayed, so user intent rather than from backup / course upload. - $data = [ - 'gnumsectionsnewcourse' => 0, - ]; - $this->update_course_format_options($data); - } - $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