MDL-80295 core_course: mod and modedit compatible with section id

This commit is contained in:
ferran
2025-08-27 16:55:50 +02:00
parent ea0e555182
commit f553947bd5
2 changed files with 18 additions and 6 deletions
+8 -2
View File
@@ -76,16 +76,22 @@ require_login();
//check if we are adding / editing a module that has new forms using formslib
if (!empty($add)) {
$id = required_param('id', PARAM_INT);
$section = required_param('section', PARAM_INT);
$sectionid = optional_param('sectionid', null, PARAM_INT);
$type = optional_param('type', '', PARAM_ALPHA);
$returntomod = optional_param('return', 0, PARAM_BOOL);
$beforemod = optional_param('beforemod', 0, PARAM_INT);
if (empty($sectionid)) {
$section = required_param('section', PARAM_INT);
$sectioninfo = get_fast_modinfo($id)->get_section_info($section);
$sectionid = $sectioninfo?->id;
}
$params = [
'add' => $add,
'type' => $type,
'course' => $id,
'section' => $section,
'sectionid' => $sectionid,
'return' => $returntomod,
'beforemod' => $beforemod,
];
+10 -4
View File
@@ -56,11 +56,17 @@ if (!empty($showonly)) {
}
if (!empty($add)) {
$section = required_param('section', PARAM_INT);
$course = required_param('course', PARAM_INT);
$sectionid = optional_param('sectionid', null, PARAM_INT);
if (empty($sectionid)) {
$sectionnum = required_param('section', PARAM_INT);
} else {
$sectionnum = get_fast_modinfo($course)->get_section_info_by_id($sectionid, MUST_EXIST)->sectionnum;
}
$url->param('add', $add);
$url->param('section', $section);
$url->param('section', $sectionnum);
$url->param('course', $course);
$PAGE->set_url($url);
@@ -70,9 +76,9 @@ if (!empty($add)) {
// There is no page for this in the navigation. The closest we'll have is the course section.
// If the course section isn't displayed on the navigation this will fall back to the course which
// will be the closest match we have.
navigation_node::override_active_url(course_get_url($course, $section));
navigation_node::override_active_url(course_get_url($course, $sectionnum));
list($module, $context, $cw, $cm, $data) = prepare_new_moduleinfo_data($course, $add, $section);
[$module, $context, $cw, $cm, $data] = prepare_new_moduleinfo_data($course, $add, $sectionnum);
$data->return = 0;
if (!is_null($sectionreturn)) {
$data->sr = $sectionreturn;