From 9c4e1d7706ece5bec6f0f71c4c49146fdf092e0d Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 9 Jul 2025 13:23:01 +0200 Subject: [PATCH 1/2] MDL-85660 format: Disable social course format The social course format is now disabled by default for all new and upgraded installations. Existing courses using this format will continue to function, but administrators must re-enable it to create new social courses. --- .upgradenotes/MDL-85660-2025070903232232.yml | 9 ++++++ course/format/social/db/install.php | 32 ++++++++++++++++++++ public/admin/presets/classes/helper.php | 6 ---- public/lib/db/upgrade.php | 15 +++++++++ public/version.php | 2 +- 5 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 .upgradenotes/MDL-85660-2025070903232232.yml create mode 100644 course/format/social/db/install.php diff --git a/.upgradenotes/MDL-85660-2025070903232232.yml b/.upgradenotes/MDL-85660-2025070903232232.yml new file mode 100644 index 00000000000..8b78d382cca --- /dev/null +++ b/.upgradenotes/MDL-85660-2025070903232232.yml @@ -0,0 +1,9 @@ +issueNumber: MDL-85660 +notes: + format_social: + - message: >- + The social course format is now disabled by default for all new and + upgraded installations. Existing courses using this format will continue + to function, but administrators must re-enable it to create new social + courses. + type: deprecated diff --git a/course/format/social/db/install.php b/course/format/social/db/install.php new file mode 100644 index 00000000000..1025351f890 --- /dev/null +++ b/course/format/social/db/install.php @@ -0,0 +1,32 @@ +. + +/** + * Install script for format_social. + * + * @package format_social + * @copyright 2025 Sara Arjona + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Perform the post-install procedures. + */ +function xmldb_format_social_install() { + // Disable the Social course format on new installs by default. + $manager = \core_plugin_manager::resolve_plugininfo_class('format'); + $manager::enable_plugin('social', 0); +} diff --git a/public/admin/presets/classes/helper.php b/public/admin/presets/classes/helper.php index 252c5f48c66..6d124c29bdd 100644 --- a/public/admin/presets/classes/helper.php +++ b/public/admin/presets/classes/helper.php @@ -236,9 +236,6 @@ class helper { static::add_plugin($presetid, 'block', 'recentlyaccessedcourses', false); static::add_plugin($presetid, 'block', 'starredcourses', false); - // Course formats: Disable Social format. - static::add_plugin($presetid, 'format', 'social', false); - // Data formats: Disable Javascript Object Notation (.json). static::add_plugin($presetid, 'dataformat', 'json', false); @@ -332,9 +329,6 @@ class helper { static::add_plugin($presetid, 'block', 'recentlyaccessedcourses', true); static::add_plugin($presetid, 'block', 'starredcourses', true); - // Course formats: Enable Social format. - static::add_plugin($presetid, 'format', 'social', true); - // Data formats: Enable Javascript Object Notation (.json). static::add_plugin($presetid, 'dataformat', 'json', true); diff --git a/public/lib/db/upgrade.php b/public/lib/db/upgrade.php index c615725915c..0fbad8bb7dd 100644 --- a/public/lib/db/upgrade.php +++ b/public/lib/db/upgrade.php @@ -2067,5 +2067,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2025081900.04); } + if ($oldversion < 2025082600.01) { + if (get_config('moodlecourse', 'format') === 'social') { + // If the social course format is set as default, change it to topics. + set_config('format', 'topics', 'moodlecourse'); + } + $DB->delete_records('adminpresets_plug', ['plugin' => 'format', 'name' => 'social']); + + // Disable Social course format. + $manager = \core_plugin_manager::resolve_plugininfo_class('format'); + $manager::enable_plugin('social', 0); + + // Main savepoint reached. + upgrade_main_savepoint(true, 2025082600.01); + } + return true; } diff --git a/public/version.php b/public/version.php index 947d9d7c2e3..c0d6a50caf6 100644 --- a/public/version.php +++ b/public/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2025082600.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2025082600.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '5.1dev+ (Build: 20250826)'; // Human-friendly version name From 4c2f378a05f324f02a4a8f33772bdaf869b498a3 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 9 Jul 2025 18:43:49 +0200 Subject: [PATCH 2/2] MDL-85660 format: Fix tests after disabling Social --- .../tests/behat/apply_presets.feature | 5 ----- .../tests/behat/revert_changes.feature | 8 ++------ .../behat/restore_moodle2_courses.feature | 6 +++--- .../tests/behat/edit_activities.feature | 3 ++- public/course/format/singleactivity/lib.php | 12 +++++++----- .../social_adjust_discussion_count.feature | 3 ++- .../course/tests/behat/course_format.feature | 18 ++++++++++++------ 7 files changed, 28 insertions(+), 27 deletions(-) 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 d1d38ddecf9..ba601b345de 100644 --- a/public/admin/tool/admin_presets/tests/behat/apply_presets.feature +++ b/public/admin/tool/admin_presets/tests/behat/apply_presets.feature @@ -17,8 +17,6 @@ Feature: I can apply presets And I should see "Disable Restriction by grouping" And I navigate to "Plugins > Blocks > Manage blocks" in site administration And I should see "Disable Logged in user" - And I navigate to "Plugins > Course formats > Manage course formats" in site administration - And "Disable" "icon" should exist in the "Social" "table_row" And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration And "Enabled" "icon" should exist in the "Immediate feedback with CBM" "table_row" And I navigate to "Plugins > Question types > Manage question types" in site administration @@ -83,7 +81,6 @@ Feature: I can apply presets 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" - And I should see "Social" in the "Setting changes" "table" And I should see "Starred courses" in the "Setting changes" "table" And I should see "Lesson" in the "Setting changes" "table" And I should see "Tags" in the "Setting changes" "table" @@ -105,8 +102,6 @@ Feature: I can apply presets And I should see "Enable Restriction by grouping" And I navigate to "Plugins > Blocks > Manage blocks" in site administration And I should see "Enable Logged in user" - And I navigate to "Plugins > Course formats > Manage course formats" in site administration - And "Disable" "icon" should not exist in the "Social" "table_row" And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration And "Enabled" "icon" should not exist in the "Immediate feedback with CBM" "table_row" And I navigate to "Plugins > Question types > Manage question types" in site administration diff --git a/public/admin/tool/admin_presets/tests/behat/revert_changes.feature b/public/admin/tool/admin_presets/tests/behat/revert_changes.feature index a3da9a4c301..1e2f1535b57 100644 --- a/public/admin/tool/admin_presets/tests/behat/revert_changes.feature +++ b/public/admin/tool/admin_presets/tests/behat/revert_changes.feature @@ -4,7 +4,7 @@ Feature: I can revert changes after a load Background: Apply Starter Moodle to revert it Given I log in as "admin" And I navigate to "Site admin presets" in site administration - And I press "Review settings and apply" action in the "Starter" report row + And I press "Review settings and apply" action in the "Moodle with all of the most popular features" report row And I should see "Setting changes" And I click on "Apply" "button" And I click on "Continue" "button" @@ -24,14 +24,12 @@ Feature: I can revert changes after a load And I should see "Enable Restriction by grouping" And I navigate to "Plugins > Blocks > Manage blocks" in site administration And "Disable Logged in user" "icon" should not exist in the "Logged in user" "table_row" - And I navigate to "Plugins > Course formats > Manage course formats" in site administration - And "Disable" "icon" should not exist in the "Social" "table_row" And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration And "Enabled" "icon" should not exist in the "Immediate feedback with CBM" "table_row" And I navigate to "Plugins > Question types > Manage question types" in site administration And "Enabled" "icon" should not exist in the "Calculated multichoice" "table_row" And I navigate to "Site admin presets" in site administration - And I press "Show version history" action in the "Starter" report row + And I press "Show version history" action in the "Moodle with all of the most popular features" report row When I click on "Restore this version" "link" And I navigate to "Advanced features" in site administration Then the field "Enable badges" matches value "1" @@ -42,8 +40,6 @@ Feature: I can revert changes after a load And I should see "Disable Restriction by grouping" And I navigate to "Plugins > Blocks > Manage blocks" in site administration And I should see "Disable Logged in user" - And I navigate to "Plugins > Course formats > Manage course formats" in site administration - And "Disable" "icon" should exist in the "Social" "table_row" And I navigate to "Plugins > Question behaviours > Manage question behaviours" in site administration And "Enabled" "icon" should exist in the "Immediate feedback with CBM" "table_row" And I navigate to "Plugins > Question types > Manage question types" in site administration diff --git a/public/backup/util/ui/tests/behat/restore_moodle2_courses.feature b/public/backup/util/ui/tests/behat/restore_moodle2_courses.feature index ae1d1c729cd..8fc44cd55b9 100644 --- a/public/backup/util/ui/tests/behat/restore_moodle2_courses.feature +++ b/public/backup/util/ui/tests/behat/restore_moodle2_courses.feature @@ -106,12 +106,12 @@ Feature: Restore Moodle 2 course backups And I expand all fieldsets And the field "id_format" matches value "Weekly sections" And I set the following fields to these values: - | id_format | Social | + | id_format | Single activity | And I press "Save and display" - And I should see "An open forum for chatting about anything you want to" + And I should see "New Forum" And I navigate to "Settings" in current page administration And I expand all fieldsets - And the field "id_format" matches value "Social" + And the field "id_format" matches value "Single activity" And I press "Cancel" @javascript diff --git a/public/blocks/social_activities/tests/behat/edit_activities.feature b/public/blocks/social_activities/tests/behat/edit_activities.feature index 613d9fb8118..158ea241b46 100644 --- a/public/blocks/social_activities/tests/behat/edit_activities.feature +++ b/public/blocks/social_activities/tests/behat/edit_activities.feature @@ -5,7 +5,8 @@ Feature: Edit activities in social activities block I need to add and edit activities there Background: - Given the following "course" exists: + Given I enable "social" "format" plugin + And the following "course" exists: | fullname | Course 1 | | shortname | C1 | | format | social | diff --git a/public/course/format/singleactivity/lib.php b/public/course/format/singleactivity/lib.php index ae5f1c2f08d..8d831b749f7 100644 --- a/public/course/format/singleactivity/lib.php +++ b/public/course/format/singleactivity/lib.php @@ -189,11 +189,13 @@ class format_singleactivity extends core_courseformat\base implements core_cours $activitytype = $this->get_activitytype(); if (!empty($activitytype) && !empty($modinfo->sections)) { // Get the first activity of the specified type, but only if it is in the 0-section. - $cmlist = $modinfo->sections[0]; - foreach ($cmlist as $cmid) { - if ($modinfo->cms[$cmid]->modname === $activitytype) { - $this->activity = $modinfo->cms[$cmid]; - break; + if (isset($modinfo->sections[0])) { + $cmlist = $modinfo->sections[0]; + foreach ($cmlist as $cmid) { + if ($modinfo->cms[$cmid]->modname === $activitytype) { + $this->activity = $modinfo->cms[$cmid]; + break; + } } } } diff --git a/public/course/format/social/tests/behat/social_adjust_discussion_count.feature b/public/course/format/social/tests/behat/social_adjust_discussion_count.feature index b15c48e78ee..cd73a461dec 100644 --- a/public/course/format/social/tests/behat/social_adjust_discussion_count.feature +++ b/public/course/format/social/tests/behat/social_adjust_discussion_count.feature @@ -5,7 +5,8 @@ Feature: Change number of discussions displayed I need to edit the course and change the number of sections displayed. Background: - Given the following "users" exist: + Given I enable "social" "format" plugin + And the following "users" exist: | username | firstname | lastname | email | | teacher1 | Teacher | 1 | teacher1@example.com | And the following "courses" exist: diff --git a/public/course/tests/behat/course_format.feature b/public/course/tests/behat/course_format.feature index de23c387fb9..c888408bb62 100644 --- a/public/course/tests/behat/course_format.feature +++ b/public/course/tests/behat/course_format.feature @@ -19,6 +19,12 @@ Feature: Teacher can change the course format And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And the following "activity" exists: + | activity | forum | + | course | C1 | + | name | My forum name | + | summary | Test forum 1 | + | section | 0 | # Confirm that course format is Custom sections. When I am on the "Course 1" course page logged in as teacher1 Then I should see "Section 1" @@ -71,13 +77,13 @@ Feature: Teacher can change the course format And I should not see "Browse the glossary using this index" And I am on the "Course 1" "course editing" page And I expand all fieldsets - # Set course format to Social format - And I set the field "Format" to "Social" - # Confirm that fields that appear for Social format appears + # Set course format to Single activity format + And I set the field "Format" to "Single activity" + # Confirm that fields that appear for Single activity format appears And I expand all fieldsets - And I should see "Number of discussions" - And the field "Number of discussions" matches value "10" + And I should see "Type of activity" + And the field "Type of activity" matches value "Forum" And I press "Save and display" # Confirm that course page displays a forum - And I should see "There are no discussion topics yet in this forum" + And I should see "Test forum 1" And I should not see "Current week"