Skip to content

Commit

Permalink
MDL-82351 courseformat: allow blocks to use the course editor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ferranrecio committed Oct 23, 2024
1 parent db8c8b1 commit 4394c38
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@
}

$PAGE->set_heading($course->fullname);

// 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.
Expand All @@ -327,23 +341,11 @@
// 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.
Expand Down

0 comments on commit 4394c38

Please sign in to comment.