From aa4d7e1391c1d63856b75f35440b41f6bba7fcf3 Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Wed, 26 Feb 2020 14:01:47 +0800 Subject: [PATCH 1/2] MDL-68056 core_course: improve render performance when editing Only generate the non-ajax controls in cases where we know we need them. Otherwise, only generate the new link style control. This patch includes a behat check as many of our tests use the 'I add "Page" to section "1"' syntax, which runs without JS. --- course/renderer.php | 190 ++++++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 84 deletions(-) diff --git a/course/renderer.php b/course/renderer.php index 53cfd08b012..9782c0b52da 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -268,107 +268,129 @@ class core_course_renderer extends plugin_renderer_base { * @return string */ function course_section_add_cm_control($course, $section, $sectionreturn = null, $displayoptions = array()) { - global $CFG, $PAGE, $USER; + global $CFG, $USER; - $vertical = !empty($displayoptions['inblock']); + // The returned control HTML can be one of the following: + // - Only the non-ajax control (select menus of activities and resources) with a noscript fallback for non js clients. + // - Only the ajax control (the link which when clicked produces the activity chooser modal). No noscript fallback. + // - [Behat only]: The non-ajax control and optionally the ajax control (depending on site settings). If included, the link + // takes priority and the non-ajax control is wrapped in a