MDL-82351 courseformat: allow blocks to use the course editor

Some formats like the social need the blocks and drawers to access the
course editor. However, the include_course_ajax was called after the
main page structure is created and produces some errors, especially in
behat. Now include_course_ajax is called before the page header.
This commit is contained in:
ferranrecio 2024-10-09 13:42:43 +02:00 committed by ferran
parent 4053bd2139
commit fa1296a7a4

View File

@ -304,6 +304,23 @@ if (!empty($bulkbutton)) {
}
$PAGE->set_heading($course->fullname);
// Make sure that section 0 exists (this function will create one if it is missing).
course_create_sections_if_missing($course, 0);
// Get information about course modules and existing module types.
// format.php in course formats may rely on presence of these variables.
$modinfo = get_fast_modinfo($course);
$modnames = get_module_types_names();
$modnamesplural = get_module_types_names(true);
$modnamesused = $modinfo->get_used_module_names();
$mods = $modinfo->get_cms();
$sections = $modinfo->get_section_info_all();
// Include course AJAX. This should be done before starting the UI
// to allow page header, blocks, or drawers use the course editor.
include_course_ajax($course, $modnamesused);
echo $OUTPUT->header();
// Show communication room status notification.
@ -324,26 +341,11 @@ if ($USER->editing == 1) {
// Course wrapper start.
echo html_writer::start_tag('div', ['class' => 'course-content']);
// Make sure that section 0 exists (this function will create one if it is missing).
course_create_sections_if_missing($course, 0);
// Get information about course modules and existing module types.
// format.php in course formats may rely on presence of these variables.
$modinfo = get_fast_modinfo($course);
$modnames = get_module_types_names();
$modnamesplural = get_module_types_names(true);
$modnamesused = $modinfo->get_used_module_names();
$mods = $modinfo->get_cms();
$sections = $modinfo->get_section_info_all();
// CAUTION, hacky fundamental variable defintion to follow!
// Note that because of the way course fromats are constructed though
// inclusion we pass parameters around this way.
$displaysection = $section;
// Include course AJAX.
include_course_ajax($course, $modnamesused);
// Include the actual course format.
require($CFG->dirroot .'/course/format/'. $course->format .'/format.php');
// Content wrapper end.