mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-62748 course: maxsections is a limit
For course formats shipped with core, maxsections should be a limit to the number of sections allowed in the course.
This commit is contained in:
parent
f468f6d02a
commit
7c05d8a3d2
6 changed files with 60 additions and 13 deletions
|
@ -45,6 +45,30 @@ require_login($course);
|
|||
require_capability('moodle/course:update', context_course::instance($course->id));
|
||||
require_sesskey();
|
||||
|
||||
$desirednumsections = 0;
|
||||
$courseformat = course_get_format($course);
|
||||
$lastsectionnumber = $courseformat->get_last_section_number();
|
||||
$maxsections = $courseformat->get_max_sections();
|
||||
|
||||
if (isset($courseformatoptions['numsections']) && $increase !== null) {
|
||||
$desirednumsections = $courseformatoptions['numsections'] + 1;
|
||||
} else if (course_get_format($course)->uses_sections() && $insertsection !== null) {
|
||||
// Count the sections in the course.
|
||||
$desirednumsections = $lastsectionnumber + $numsections;
|
||||
}
|
||||
|
||||
if ($desirednumsections > $maxsections) {
|
||||
// Increase in number of sections is not allowed.
|
||||
\core\notification::warning(get_string('maxsectionslimit', 'moodle', $maxsections));
|
||||
$increase = null;
|
||||
$insertsection = null;
|
||||
$numsections = 0;
|
||||
|
||||
if (!$returnurl) {
|
||||
$returnurl = course_get_url($course);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($courseformatoptions['numsections']) && $increase !== null) {
|
||||
if ($increase) {
|
||||
// Add an additional section.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue