MDL-84291 format_topics: create courses with default number of sections
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
issueNumber: MDL-84291
|
||||
notes:
|
||||
format_topics:
|
||||
- message: >-
|
||||
Now the custom sections format won't ask for initial sections on the
|
||||
creation form. Instead it will use the system number of sections
|
||||
settings directly.
|
||||
type: improved
|
||||
@@ -285,17 +285,11 @@ class format_topics extends core_courseformat\base {
|
||||
$elements = parent::create_edit_form_elements($mform, $forsection);
|
||||
|
||||
if (!$forsection && (empty($COURSE->id) || $COURSE->id == SITEID)) {
|
||||
// Add "numsections" element to the create course form - it will force new course to be prepopulated
|
||||
// with empty sections.
|
||||
// The "Number of sections" option is no longer available when editing course, instead teachers should
|
||||
// delete and add sections when needed.
|
||||
// Custom sections are always created with the default number of sections.
|
||||
$courseconfig = get_config('moodlecourse');
|
||||
$max = (int)$courseconfig->maxsections;
|
||||
$element = $mform->addElement('select', 'numsections', get_string('numberweeks'), range(0, $max ?: 52));
|
||||
$element = $mform->addElement('hidden', 'numsections');
|
||||
$mform->setType('numsections', PARAM_INT);
|
||||
if (is_null($mform->getElementValue('numsections'))) {
|
||||
$mform->setDefault('numsections', $courseconfig->numsections);
|
||||
}
|
||||
$mform->setDefault('numsections', $courseconfig->numsections);
|
||||
array_unshift($elements, $element);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
@format @format_topics
|
||||
Feature: Custom sections are created with the system default number of sections
|
||||
In order to create courses
|
||||
As a course creator
|
||||
I need my courses to be created as the system default number of sections
|
||||
|
||||
@javascript
|
||||
Scenario: Default number of sections in course creation
|
||||
Given the following config values are set as admin:
|
||||
| numsections | 5 | moodlecourse |
|
||||
When I log in as "admin"
|
||||
And I navigate to "Courses > Manage courses and categories" in site administration
|
||||
And I click on "Create new course" "link"
|
||||
And I expand all fieldsets
|
||||
And I set the field "Course full name" to "Course 1"
|
||||
And I set the field "Course short name" to "C1"
|
||||
And I set the field "Format" to "Custom sections"
|
||||
Then I should not see "Number of sections"
|
||||
And I click on "Save and display" "button"
|
||||
And "[data-for='section'][data-number='1']" "css_element" should exist
|
||||
And "[data-for='section'][data-number='2']" "css_element" should exist
|
||||
And "[data-for='section'][data-number='3']" "css_element" should exist
|
||||
And "[data-for='section'][data-number='4']" "css_element" should exist
|
||||
And "[data-for='section'][data-number='5']" "css_element" should exist
|
||||
And "[data-for='section'][data-number='6']" "css_element" should not exist
|
||||
Reference in New Issue
Block a user