diff --git a/.upgradenotes/MDL-80556-2025070802320223.yml b/.upgradenotes/MDL-80556-2025070802320223.yml new file mode 100644 index 00000000000..e6deee740d2 --- /dev/null +++ b/.upgradenotes/MDL-80556-2025070802320223.yml @@ -0,0 +1,5 @@ +issueNumber: MDL-80556 +notes: + core_block: + - message: Removed block_section_links from Moodle 5.1. + type: removed diff --git a/lib/plugins.json b/lib/plugins.json index 171660e0931..d68f8cf76b8 100644 --- a/lib/plugins.json +++ b/lib/plugins.json @@ -75,7 +75,6 @@ "recentlyaccesseditems", "rss_client", "search_forums", - "section_links", "selfcompletion", "settings", "site_main_menu", @@ -590,7 +589,8 @@ "messages", "mnet_hosts", "participants", - "quiz_results" + "quiz_results", + "section_links" ], "cachestore": [ "memcache", diff --git a/public/admin/presets/classes/helper.php b/public/admin/presets/classes/helper.php index 2c8c8f4e390..252c5f48c66 100644 --- a/public/admin/presets/classes/helper.php +++ b/public/admin/presets/classes/helper.php @@ -206,7 +206,7 @@ class helper { // Blocks: Hide Blog menu, Blog tags, Comments, Course completion status, Courses, Flickr, // Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Online users, - // Private files, Recent blog entries, Recently accessed courses, Search forums, Section links, Social activities, + // Private files, Recent blog entries, Recently accessed courses, Search forums, Social activities, // Starred courses, Tags, YouTube. // Hidden by default: Course/site summary, RSS feeds, Self completion, Feedback. static::add_plugin($presetid, 'block', 'blog_menu', false); @@ -227,7 +227,6 @@ class helper { static::add_plugin($presetid, 'block', 'blog_recent', false); static::add_plugin($presetid, 'block', 'rss_client', false); static::add_plugin($presetid, 'block', 'search_forums', false); - static::add_plugin($presetid, 'block', 'section_links', false); static::add_plugin($presetid, 'block', 'selfcompletion', false); static::add_plugin($presetid, 'block', 'social_activities', false); static::add_plugin($presetid, 'block', 'tags', false); @@ -308,7 +307,7 @@ class helper { // Blocks: Enable Blog menu, Blog tags, Comments, Course completion status, Courses, Flickr, // Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Online users, - // Private files, Recent blog entries, Recently accessed courses, Search forums, Section links, Social activities, + // Private files, Recent blog entries, Recently accessed courses, Search forums, Social activities, // Starred courses, Tags, YouTube. // Hidden by default: Course/site summary, RSS feeds, Self completion, Feedback. static::add_plugin($presetid, 'block', 'blog_menu', true); @@ -327,7 +326,6 @@ class helper { static::add_plugin($presetid, 'block', 'private_files', true); static::add_plugin($presetid, 'block', 'blog_recent', true); static::add_plugin($presetid, 'block', 'search_forums', true); - static::add_plugin($presetid, 'block', 'section_links', true); static::add_plugin($presetid, 'block', 'social_activities', true); static::add_plugin($presetid, 'block', 'tags', true); static::add_plugin($presetid, 'block', 'online_users', true); diff --git a/public/admin/tool/admin_presets/tests/behat/apply_presets.feature b/public/admin/tool/admin_presets/tests/behat/apply_presets.feature index 424f296348e..d1d38ddecf9 100644 --- a/public/admin/tool/admin_presets/tests/behat/apply_presets.feature +++ b/public/admin/tool/admin_presets/tests/behat/apply_presets.feature @@ -80,7 +80,6 @@ Feature: I can apply presets And I should see "Restriction by profile" in the "Setting changes" "table" And I should see "SCORM package" in the "Setting changes" "table" And I should see "Search forums" in the "Setting changes" "table" - And I should see "Section links" in the "Setting changes" "table" And I should see "Server files" in the "Setting changes" "table" And I should see "Show data retention summary" in the "Setting changes" "table" And I should see "Social activities" in the "Setting changes" "table" diff --git a/public/blocks/section_links/block_section_links.php b/public/blocks/section_links/block_section_links.php deleted file mode 100644 index 6ebef5f1234..00000000000 --- a/public/blocks/section_links/block_section_links.php +++ /dev/null @@ -1,187 +0,0 @@ -. - -/** - * This file contains the main class for the section links block. - * - * @package block_section_links - * @copyright Jason Hardin - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Section links block class. - * - * @package block_section_links - * @copyright Jason Hardin - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class block_section_links extends block_base { - - /** - * Initialises the block instance. - */ - public function init() { - $this->title = get_string('pluginname', 'block_section_links'); - } - - /** - * Returns an array of formats for which this block can be used. - * - * @return array - */ - public function applicable_formats() { - return [ - 'course-view-weeks' => true, - 'course-view-topics' => true, - 'course-view-section-weeks' => true, - 'course-view-section-topics' => true, - ]; - } - - /** - * Generates the content of the block and returns it. - * - * If the content has already been generated then the previously generated content is returned. - * - * @return stdClass - */ - public function get_content() { - - // The config should be loaded by now. - // If its empty then we will use the global config for the section links block. - if (isset($this->config)){ - $config = $this->config; - } else{ - $config = get_config('block_section_links'); - } - - if ($this->content !== null) { - return $this->content; - } - - $this->content = new stdClass; - $this->content->footer = ''; - $this->content->text = ''; - - if (empty($this->instance)) { - return $this->content; - } - - $course = $this->page->course; - $courseformat = course_get_format($course); - $numsections = $courseformat->get_last_section_number(); - $context = context_course::instance($course->id); - - // Course format options 'numsections' is required to display the block. - if (empty($numsections)) { - return $this->content; - } - - // Prepare the increment value. - if (!empty($config->numsections1) and ($numsections > $config->numsections1)) { - $inc = $config->incby1; - } else if ($numsections > 22) { - $inc = 2; - } else { - $inc = 1; - } - if (!empty($config->numsections2) and ($numsections > $config->numsections2)) { - $inc = $config->incby2; - } else { - if ($numsections > 40) { - $inc = 5; - } - } - - // Whether or not section name should be displayed. - $showsectionname = !empty($config->showsectionname) ? true : false; - - // Prepare an array of sections to create links for. - $sections = []; - $canviewhidden = has_capability('moodle/course:update', $context); - $coursesections = $courseformat->get_sections(); - $coursesectionscount = count($coursesections); - $sectiontojumpto = false; - for ($i = $inc; $i <= $coursesectionscount; $i += $inc) { - if ($i > $numsections || !isset($coursesections[$i])) { - continue; - } - $section = $coursesections[$i]; - // Delegated sections (like subsections) are not listed in the block. - if ($section->get_component_instance() !== null) { - continue; - } - if ($section->section && ($section->visible || $canviewhidden)) { - $sections[$i] = (object) [ - 'section' => $section->section, - 'visible' => $section->visible, - 'highlight' => false - ]; - if ($courseformat->is_section_current($section)) { - $sections[$i]->highlight = true; - $sectiontojumpto = $section->section; - } - if ($showsectionname) { - $sections[$i]->name = $courseformat->get_section_name($i); - } - } - } - - if (!empty($sections)) { - // Render the sections. - $renderer = $this->page->get_renderer('block_section_links'); - $this->content->text = $renderer->render_section_links($this->page->course, $sections, - $sectiontojumpto, $showsectionname); - } - - return $this->content; - } - /** - * Returns true if this block has instance config. - * - * @return bool - **/ - public function instance_allow_config() { - return true; - } - - /** - * Returns true if this block has global config. - * - * @return bool - */ - public function has_config() { - return true; - } - - /** - * Return the plugin config settings for external functions. - * - * @return stdClass the configs for both the block instance and plugin - * @since Moodle 3.8 - */ - public function get_config_for_external() { - // Return all settings for all users since it is safe (no private keys, etc..). - $instanceconfigs = !empty($this->config) ? $this->config : new stdClass(); - $pluginconfigs = get_config('block_section_links'); - - return (object) [ - 'instance' => $instanceconfigs, - 'plugin' => $pluginconfigs, - ]; - } -} diff --git a/public/blocks/section_links/classes/privacy/provider.php b/public/blocks/section_links/classes/privacy/provider.php deleted file mode 100644 index f5a1d044296..00000000000 --- a/public/blocks/section_links/classes/privacy/provider.php +++ /dev/null @@ -1,46 +0,0 @@ -. - -/** - * Privacy Subsystem implementation for block_section_links. - * - * @package block_section_links - * @copyright 2018 Zig Tan - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace block_section_links\privacy; - -defined('MOODLE_INTERNAL') || die(); - -/** - * Privacy Subsystem for block_section_links implementing null_provider. - * - * @copyright 2018 Zig Tan - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class provider implements \core_privacy\local\metadata\null_provider { - - /** - * Get the language string identifier with the component's language - * file to explain why this plugin stores no data. - * - * @return string - */ - public static function get_reason(): string { - return 'privacy:metadata'; - } -} diff --git a/public/blocks/section_links/db/access.php b/public/blocks/section_links/db/access.php deleted file mode 100644 index 7a96c63194c..00000000000 --- a/public/blocks/section_links/db/access.php +++ /dev/null @@ -1,41 +0,0 @@ -. - -/** - * Section links block caps. - * - * @package block_section_links - * @copyright Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$capabilities = array( - - 'block/section_links:addinstance' => array( - 'riskbitmask' => RISK_SPAM | RISK_XSS, - - 'captype' => 'write', - 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array( - 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ), - - 'clonepermissionsfrom' => 'moodle/site:manageblocks' - ), -); diff --git a/public/blocks/section_links/db/upgrade.php b/public/blocks/section_links/db/upgrade.php deleted file mode 100644 index 62339ad3966..00000000000 --- a/public/blocks/section_links/db/upgrade.php +++ /dev/null @@ -1,64 +0,0 @@ -. - -/** - * This file keeps track of upgrades to the section links block - * - * Sometimes, changes between versions involve alterations to database structures - * and other major things that may break installations. - * - * The upgrade function in this file will attempt to perform all the necessary - * actions to upgrade your older installation to the current version. - * - * If there's something it cannot do itself, it will tell you what you need to do. - * - * The commands in here will all be database-neutral, using the methods of - * database_manager class - * - * Please do not forget to use upgrade_set_timeout() - * before any action that may take longer time to finish. - * - * @since Moodle 2.5 - * @package block_section_links - * @copyright 2013 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Upgrade code for the section links block. - * - * @global moodle_database $DB - * @param int $oldversion - * @param object $block - */ -function xmldb_block_section_links_upgrade($oldversion, $block) { - // Automatically generated Moodle v4.2.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v4.3.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v4.4.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v4.5.0 release upgrade line. - // Put any upgrade step following this. - - // Automatically generated Moodle v5.0.0 release upgrade line. - // Put any upgrade step following this. - - return true; -} diff --git a/public/blocks/section_links/edit_form.php b/public/blocks/section_links/edit_form.php deleted file mode 100644 index 3cedaf078cb..00000000000 --- a/public/blocks/section_links/edit_form.php +++ /dev/null @@ -1,89 +0,0 @@ -. - -/** - * Instance configuration for the section links block. - * - * @package block_section_links - * @copyright 2013 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Instance configuration form. - * - * @package block_section_links - * @copyright 2013 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class block_section_links_edit_form extends block_edit_form { - - /** - * The definition of the fields to use. - * - * @param MoodleQuickForm $mform - */ - protected function specific_definition($mform) { - $mform->addElement('header', 'configheader', get_string('blocksettings', 'block')); - - $numberofsections = array(); - for ($i = 1; $i < 53; $i++){ - $numberofsections[$i] = $i; - } - - $increments = array(); - - for ($i = 1; $i < 11; $i++){ - $increments[$i] = $i; - } - - $config = get_config('block_section_links'); - - $selected = array( - 1 => array(22, 2), - 2 => array(40, 5), - ); - if (!empty($config->numsections1)) { - if (empty($config->incby1)) { - $config->incby1 = $selected[1][1]; - } - $selected[1] = array($config->numsections1, $config->incby1); - } - - if (!empty($config->numsections2)) { - if (empty($config->incby1)) { - $config->incby1 = $selected[2][1]; - } - $selected[2] = array($config->numsections2, $config->incby2); - } - - for ($i = 1; $i < 3; $i++) { - $mform->addElement('select', 'config_numsections'.$i, get_string('numsections'.$i, 'block_section_links'), $numberofsections); - $mform->setDefault('config_numsections'.$i, $selected[$i][0]); - $mform->setType('config_numsections'.$i, PARAM_INT); - $mform->addHelpButton('config_numsections'.$i, 'numsections'.$i, 'block_section_links'); - - $mform->addElement('select', 'config_incby'.$i, get_string('incby'.$i, 'block_section_links'), $increments); - $mform->setDefault('config_incby'.$i, $selected[$i][1]); - $mform->setType('config_incby'.$i, PARAM_INT); - $mform->addHelpButton('config_incby'.$i, 'incby'.$i, 'block_section_links'); - } - - $mform->addElement('selectyesno', 'config_showsectionname', get_string('showsectionname', 'block_section_links')); - $mform->setDefault('config_showsectionname', !empty($config->showsectionname) ? 1 : 0); - $mform->addHelpButton('config_showsectionname', 'showsectionname', 'block_section_links'); - } -} \ No newline at end of file diff --git a/public/blocks/section_links/lang/en/block_section_links.php b/public/blocks/section_links/lang/en/block_section_links.php deleted file mode 100644 index b4f012017c3..00000000000 --- a/public/blocks/section_links/lang/en/block_section_links.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Strings for component 'block_section_links', language 'en', branch 'MOODLE_20_STABLE' - * - * @package block_section_links - * @copyright Jason Hardin - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['incby1'] = 'Increase by'; -$string['incby1_help'] = 'This is the value the section is incremented each time a section link is displayed starting at 1.'; -$string['incby2'] = 'Alternative increase by'; -$string['incby2_help'] = 'This is the value the section is incremented each time a section link is displayed starting at 1.'; -$string['jumptocurrenttopic'] = 'Jump to highlighted section'; -$string['jumptocurrentweek'] = 'Jump to current week'; -$string['numsections1'] = 'Number of sections'; -$string['numsections1_help'] = 'Once the number of sections in the course reaches this number then the increment by value is used.'; -$string['numsections2'] = 'Alternative number of sections'; -$string['numsections2_help'] = 'Once the number of sections in the course reaches this number then the Alternative increment by value is used.'; -$string['pluginname'] = 'Section links'; -$string['section_links:addinstance'] = 'Add a new section links block'; -$string['showsectionname'] = 'Display section name'; -$string['showsectionname_help'] = 'If set to Yes, section names are used as links. Otherwise, numbers are used.'; -$string['privacy:metadata'] = 'The Section links block only shows data stored in other locations.'; diff --git a/public/blocks/section_links/renderer.php b/public/blocks/section_links/renderer.php deleted file mode 100644 index 4b625a0851a..00000000000 --- a/public/blocks/section_links/renderer.php +++ /dev/null @@ -1,86 +0,0 @@ -. - -/** - * Renderer for the section links block. - * - * @since Moodle 2.5 - * @package block_section_links - * @copyright 2013 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -/** - * Renderer for the section links block. - * - * @package block_section_links - * @copyright 2013 Sam Hemelryk - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class block_section_links_renderer extends plugin_renderer_base { - - /** - * Render a series of section links. - * - * @param stdClass $course The course we are rendering for. - * @param array $sections An array of section objects to render. - * @param bool|int The section to provide a jump to link for. - * @param bool $showsectionname Whether or not section name should be displayed. - * @return string The HTML to display. - */ - public function render_section_links(stdClass $course, array $sections, $jumptosection = false, $showsectionname = false) { - $olparams = $showsectionname ? ['class' => 'unlist'] : ['class' => 'inline-list']; - $liparams = $showsectionname ? ['class' => 'mb-2'] : []; - $html = html_writer::start_tag('ol', $olparams); - foreach ($sections as $section) { - $attributes = array(); - if (!$section->visible) { - $attributes['class'] = 'dimmed'; - } - $html .= html_writer::start_tag('li', $liparams); - $sectiontext = $section->section; - if ($showsectionname) { - $sectiontext = $section->name; - } - if ($section->highlight) { - $sectiontext = html_writer::tag('strong', $sectiontext); - } - $html .= html_writer::link( - course_get_url($course, $section->section, ['navigation' => true]), - $sectiontext, - $attributes - ); - $html .= html_writer::end_tag('li').' '; - } - $html .= html_writer::end_tag('ol'); - if ($jumptosection && isset($sections[$jumptosection])) { - - if ($course->format == 'weeks') { - $linktext = new lang_string('jumptocurrentweek', 'block_section_links'); - } else if ($course->format == 'topics') { - $linktext = new lang_string('jumptocurrenttopic', 'block_section_links'); - } - - $attributes = array(); - if (!$sections[$jumptosection]->visible) { - $attributes['class'] = 'dimmed'; - } - $html .= html_writer::link(course_get_url($course, $jumptosection, ['navigation' => true]), $linktext, $attributes); - } - - return $html; - } -} diff --git a/public/blocks/section_links/settings.php b/public/blocks/section_links/settings.php deleted file mode 100644 index cf7f5bf223b..00000000000 --- a/public/blocks/section_links/settings.php +++ /dev/null @@ -1,58 +0,0 @@ -. - -/** - * Section links block - * - * @package block_section_links - * @copyright Jason Hardin - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die; - -if ($ADMIN->fulltree) { - $numberofsections = array(); - - for ($i = 1; $i < 53; $i++){ - $numberofsections[$i] = $i; - } - $increments = array(); - - for ($i = 1; $i < 11; $i++){ - $increments[$i] = $i; - } - - $selected = array(1 => array(22,2), - 2 => array(40,5)); - - for($i = 1; $i < 3; $i++){ - $settings->add(new admin_setting_configselect('block_section_links/numsections'.$i, get_string('numsections'.$i, 'block_section_links'), - get_string('numsections'.$i.'_help', 'block_section_links'), - $selected[$i][0], $numberofsections)); - - $settings->add(new admin_setting_configselect('block_section_links/incby'.$i, get_string('incby'.$i, 'block_section_links'), - get_string('incby'.$i.'_help', 'block_section_links'), - $selected[$i][1], $increments)); - } - - $settings->add( - new admin_setting_configcheckbox('block_section_links/showsectionname', - get_string('showsectionname', 'block_section_links'), - get_string('showsectionname_help', 'block_section_links'), - 1), - ); -} diff --git a/public/blocks/section_links/tests/behat/block_section_links_course.feature b/public/blocks/section_links/tests/behat/block_section_links_course.feature deleted file mode 100644 index 76cad1c464b..00000000000 --- a/public/blocks/section_links/tests/behat/block_section_links_course.feature +++ /dev/null @@ -1,72 +0,0 @@ -@block @block_section_links -Feature: The section links block allows users to quickly navigate around a moodle course - In order to navigate a moodle course - As a teacher - I can use the section links block - - Background: - Given the following "courses" exist: - | fullname | shortname | category | numsections | coursedisplay | - | Course 1 | C1 | 0 | 20 | 1 | - And the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And the following "activities" exist: - | activity | name | intro | course | section | idnumber | assignsubmission_file_enabled | - | assign | Test assignment 1 | Offline text | C1 | 5 | assign1 | 0 | - And the following config values are set as admin: - | showsectionname | 0 | block_section_links | - | unaddableblocks | | theme_boost | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - - Scenario: Add the section links block to a course. - Given I add the "Section links" block - And I turn editing mode off - And I should see "5" in the "Section links" "block" - When I follow "5" - Then I should see "Test assignment 1" - - Scenario: Add the section links block to a course and limit the sections displayed. - Given I add the "Section links" block - And I configure the "Section links" block - And I set the following fields to these values: - | config_numsections1 | 5 | - | config_incby1 | 5 | - | config_numsections2 | 40 | - | config_incby2 | 10 | - And I press "Save changes" - And I turn editing mode off - And I should see "5" in the "Section links" "block" - When I follow "5" - Then I should see "Test assignment 1" - - Scenario: Add the section links block to a course and limit the sections displayed using the alternative number of sections. - Given I add the "Section links" block - And I configure the "Section links" block - And I set the following fields to these values: - | config_numsections1 | 5 | - | config_incby1 | 1 | - | config_numsections2 | 10 | - | config_incby2 | 5 | - And I press "Save changes" - And I turn editing mode off - And I should see "5" in the "Section links" "block" - When I follow "5" - Then I should see "Test assignment 1" - - Scenario: Subsections numbers are not displayed in the Section links block - Given the following "activity" exists: - | activity | subsection | - | name | Subsection1 | - | course | C1 | - | idnumber | subsection1 | - | section | 1 | - And the following "blocks" exist: - | blockname | contextlevel | reference | pagetypepattern | defaultregion | - | section_links | Course | C1 | course-view-* | side-pre | - When I am on "Course 1" course homepage - Then "21" "link" should not exist in the "Section links" "block" diff --git a/public/blocks/section_links/tests/behat/show_section_name.feature b/public/blocks/section_links/tests/behat/show_section_name.feature deleted file mode 100644 index de80fdbbceb..00000000000 --- a/public/blocks/section_links/tests/behat/show_section_name.feature +++ /dev/null @@ -1,58 +0,0 @@ -@block @block_section_links -Feature: The Section links block can be configured to display section name in addition to section number - - Background: - Given the following "course" exists: - | fullname | Course 1 | - | shortname | C1 | - | category | 0 | - | numsections | 10 | - | coursedisplay | 1 | - | initsections | 1 | - And the following "activities" exist: - | activity | name | course | idnumber | section | - | assign | First assignment | C1 | assign1 | 7 | - And the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | - | student1 | Student | 1 | student1@example.com | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - | student1 | C1 | student | - And the following config values are set as admin: - | showsectionname | 1 | block_section_links | - | unaddableblocks | | theme_boost| - And the following "blocks" exist: - | blockname | contextlevel | reference | pagetypepattern | defaultregion | - | section_links | Course | C1 | course-view-* | side-pre | - - Scenario: Student can see section name under the Section links block - When I am on the "Course 1" course page logged in as student1 - Then I should see "Section 7" in the "Section links" "block" - And I should not see "7: Section 7" in the "Section links" "block" - And I follow "Section 7" - And I should see "First assignment" - - Scenario: Teacher can configure existing Section links block to display section number or section name - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - When I configure the "Section links" block - And I set the following fields to these values: - | Display section name | No | - And I click on "Save changes" "button" - Then I should not see "7: Section 7" in the "Section links" "block" - And I should not see "Section 7" in the "Section links" "block" - And I should see "7" in the "Section links" "block" - And I follow "7" - And I should see "First assignment" - - Scenario: Subsections names are not displayed in the Section links block - Given the following "activity" exists: - | activity | subsection | - | name | Subsection1 | - | course | C1 | - | idnumber | subsection1 | - | section | 1 | - When I am on the "Course 1" course page logged in as student1 - Then I should not see "Subsection1" in the "Section links" "block" diff --git a/public/blocks/section_links/upgrade.txt b/public/blocks/section_links/upgrade.txt deleted file mode 100644 index 33b3b0e53f9..00000000000 --- a/public/blocks/section_links/upgrade.txt +++ /dev/null @@ -1,11 +0,0 @@ -=== 4.5 Onwards === - -This file has been replaced by UPGRADING.md. See MDL-81125 for further information. - -=== -This file describes API changes in the section_links block code. - -=== 3.11 === - -* New optional parameter $showsectionname has been added to render_section_links(). Setting this to true will display - section name in addition to section number. diff --git a/public/blocks/section_links/version.php b/public/blocks/section_links/version.php deleted file mode 100644 index 9dff931ddfe..00000000000 --- a/public/blocks/section_links/version.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Version details - * - * @package block_section_links - * @copyright Jason Hardin - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2025041400; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2025040800; // Requires this Moodle version. -$plugin->component = 'block_section_links'; // Full name of the plugin (used for diagnostics) diff --git a/public/course/tests/behat/course_controls.feature b/public/course/tests/behat/course_controls.feature index 9fe14b83f39..f712d2120dd 100644 --- a/public/course/tests/behat/course_controls.feature +++ b/public/course/tests/behat/course_controls.feature @@ -69,14 +69,6 @@ Feature: Course activity controls works as expected And section "1" should be visible And I am on the "C1 > Section 1" "course > section" page And "section" should not exist - And the following config values are set as admin: - | showsectionname | 0 | block_section_links | - | unaddableblocks | | theme_boost | - And I add the "Section links" block - And "section" should not exist - And I should see "1 2 3 4 5" in the "Section links" "block" - And I click on "2" "link" in the "Section links" "block" - And I should not see "Test forum name 2" Examples: | courseformat | coursedisplay | initsections | targetsectionnum | targetpage | belowpage | @@ -135,13 +127,6 @@ Feature: Course activity controls works as expected And all activities in section "1" should be hidden And I show section "1" And section "1" should be visible - And the following config values are set as admin: - | showsectionname | 0 | block_section_links | - | unaddableblocks | | theme_boost | - And I add the "Section links" block - And I should see "1 2 3 4 5" in the "Section links" "block" - And I click on "2" "link" in the "Section links" "block" - And I should not see "Test forum name 2" Examples: | courseformat | coursedisplay | initsections | targetsectionnum | targetpage | belowpage | diff --git a/public/lib/db/upgrade.php b/public/lib/db/upgrade.php index f0277f2d21c..9cf4faf1d4e 100644 --- a/public/lib/db/upgrade.php +++ b/public/lib/db/upgrade.php @@ -2009,5 +2009,33 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2025081900.02); } + if ($oldversion < 2025081900.03) { + // Remove section_links block. + + if (!file_exists($CFG->dirroot . "/blocks/section_links/version.php")) { + uninstall_plugin('block', 'section_links'); + // Delete all the admin preset plugin references to section_links. + $DB->delete_records('adminpresets_plug', ['plugin' => 'block', 'name' => 'section_links']); + // Remove the section_links block from the unaddableblocks setting. + $settings = $DB->get_records('config_plugins', ['name' => 'unaddableblocks'], '', 'plugin, value'); + foreach ($settings as $setting) { + // Split the value into an array of items and remove 'section_links'. + // Using PREG_SPLIT_NO_EMPTY will remove any empty strings resulting from multiple commas. + $items = preg_split('/,/', $setting->value, -1, PREG_SPLIT_NO_EMPTY); + $newvalue = array_filter($items, function($item) { + return trim($item) !== 'section_links'; + }); + set_config( + 'unaddableblocks', + implode(',', $newvalue), + $setting->plugin, + ); + } + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2025081900.03); + } + return true; } diff --git a/public/lib/tests/blocklib_test.php b/public/lib/tests/blocklib_test.php index 1d82b715a40..332f5821d49 100644 --- a/public/lib/tests/blocklib_test.php +++ b/public/lib/tests/blocklib_test.php @@ -846,11 +846,10 @@ final class blocklib_test extends \advanced_testcase { $blockmanager->load_blocks(); $blocks = $blockmanager->get_unaddable_by_theme_block_types(); // Assert that a few blocks are excluded for boost theme. - $this->assertCount(4, $blocks); + $this->assertCount(3, $blocks); $this->assertContains('navigation', $blocks); $this->assertContains('settings', $blocks); $this->assertContains('course_list', $blocks); - $this->assertContains('section_links', $blocks); // Change to a theme without unaddable blocks. $PAGE->reset_theme_and_output(); diff --git a/public/theme/boost/settings.php b/public/theme/boost/settings.php index 5fa481f60c5..82676a3a690 100644 --- a/public/theme/boost/settings.php +++ b/public/theme/boost/settings.php @@ -27,9 +27,8 @@ if ($ADMIN->fulltree) { $page = new admin_settingpage('theme_boost_general', get_string('generalsettings', 'theme_boost')); // Unaddable blocks. - // Blocks to be excluded when this theme is enabled in the "Add a block" list: Administration, Navigation, Courses and - // Section links. - $default = 'navigation,settings,course_list,section_links'; + // Blocks to be excluded when this theme is enabled in the "Add a block" list: Administration, Navigation and Courses. + $default = 'navigation,settings,course_list'; $setting = new admin_setting_configtext('theme_boost/unaddableblocks', get_string('unaddableblocks', 'theme_boost'), get_string('unaddableblocks_desc', 'theme_boost'), $default, PARAM_TEXT); $page->add($setting); diff --git a/public/theme/boost/tests/behat/addblock.feature b/public/theme/boost/tests/behat/addblock.feature index d786b887ef1..beb12c302fd 100644 --- a/public/theme/boost/tests/behat/addblock.feature +++ b/public/theme/boost/tests/behat/addblock.feature @@ -16,7 +16,6 @@ Feature: Add a block using boost theme Then I should not see "Administration" And I should not see "Navigation" And I should not see "Courses" - And I should not see "Section links" And I should see "Online users" Scenario: Admins can change unaddable blocks using the unaddableblocks setting @@ -28,7 +27,6 @@ Feature: Add a block using boost theme And I should not see "Private files" And I should see "Navigation" And I should see "Courses" - And I should see "Section links" Scenario: If unaddableblocks settting is empty, no block is excluded from the Add a block list Given the following config values are set as admin: @@ -38,4 +36,3 @@ Feature: Add a block using boost theme Then I should see "Administration" And I should see "Navigation" And I should see "Courses" - And I should see "Section links" diff --git a/public/theme/classic/tests/behat/addblock.feature b/public/theme/classic/tests/behat/addblock.feature index 01ef799510a..55f1c64e4e4 100644 --- a/public/theme/classic/tests/behat/addblock.feature +++ b/public/theme/classic/tests/behat/addblock.feature @@ -16,7 +16,6 @@ Feature: Add a block using classic theme Then I should see "Administration" And I should see "Navigation" And I should see "Courses" - And I should see "Section links" Scenario: Admins can change unaddable blocks using the unaddableblocks setting for classic Given the following config values are set as admin: @@ -29,4 +28,3 @@ Feature: Add a block using classic theme And I should see "Administration" And I should see "Navigation" And I should see "Courses" - And I should see "Section links" diff --git a/public/version.php b/public/version.php index 87b0bcbe2a6..d4044aa6c5e 100644 --- a/public/version.php +++ b/public/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2025081900.02; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2025081900.03; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '5.1dev (Build: 20250819)'; // Human-friendly version name