diff --git a/.upgradenotes/MDL-83008-2024090514122136.yml b/.upgradenotes/MDL-83008-2024090514122136.yml new file mode 100644 index 00000000000..1ee3ea3372b --- /dev/null +++ b/.upgradenotes/MDL-83008-2024090514122136.yml @@ -0,0 +1,8 @@ +issueNumber: MDL-83008 +notes: + core_completion: + - message: > + A new FEATURE_COMPLETION plugin support constant has been added. In the + future, this constant will be used to indicate when a plugin does not + allow completion and it is enabled by default. + type: improved diff --git a/completion/classes/manager.php b/completion/classes/manager.php index f77a543d0f3..bb71b3cd4df 100644 --- a/completion/classes/manager.php +++ b/completion/classes/manager.php @@ -276,6 +276,9 @@ class manager { */ public static function can_edit_bulk_completion($courseorid, $cm = null) { if ($cm) { + if (!plugin_supports('mod', $cm->modname, FEATURE_COMPLETION, true)) { + return false; + } return $cm->uservisible && has_capability('moodle/course:manageactivities', $cm->context); } $coursecontext = context_course::instance(is_object($courseorid) ? $courseorid->id : $courseorid); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index e55c6adbab2..24074c9a062 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -425,6 +425,8 @@ define('FEATURE_CONTROLS_GRADE_VISIBILITY', 'controlsgradevisbility'); /** True if module supports plagiarism plugins */ define('FEATURE_PLAGIARISM', 'plagiarism'); +/** True if module supports completion (true by default) */ +define('FEATURE_COMPLETION', 'completion_enabled'); /** True if module has code to track whether somebody viewed it */ define('FEATURE_COMPLETION_TRACKS_VIEWS', 'completion_tracks_views'); /** True if module has custom completion rules */ diff --git a/mod/subsection/lib.php b/mod/subsection/lib.php index 9c91b035184..ef0fbf162a0 100644 --- a/mod/subsection/lib.php +++ b/mod/subsection/lib.php @@ -37,6 +37,7 @@ function subsection_supports($feature) { FEATURE_GROUPS => false, FEATURE_GROUPINGS => false, FEATURE_MOD_INTRO => false, + FEATURE_COMPLETION => false, FEATURE_COMPLETION_TRACKS_VIEWS => false, FEATURE_GRADE_HAS_GRADE => false, FEATURE_GRADE_OUTCOMES => false, diff --git a/mod/subsection/tests/behat/subsection_no_completion.feature b/mod/subsection/tests/behat/subsection_no_completion.feature index d0efef7dcb8..d8a926f7195 100644 --- a/mod/subsection/tests/behat/subsection_no_completion.feature +++ b/mod/subsection/tests/behat/subsection_no_completion.feature @@ -16,9 +16,10 @@ Feature: Subsection does not have completion. | user | course | role | | teacher1 | C1 | editingteacher | And the following "activities" exist: - | activity | name | course | idnumber | section | - | subsection | Subsection 1 | C1 | subsection1 | 1 | - | page | Page in Subsection 1 | C1 | page1 | 2 | + | activity | name | course | idnumber | section | + | wiki | Wiki activity | C1 | subsection1 | 1 | + | subsection | Subsection 1 | C1 | subsection1 | 1 | + | page | Page in Subsection | C1 | page1 | 2 | Scenario: Subsection does not appear in the site default completion form Given I log in as "admin" @@ -35,3 +36,15 @@ Feature: Subsection does not have completion. And I should see "Default activity completion" Then I should see "Forum" in the "region-main" "region" And I should not see "Subsection" in the "region-main" "region" + + @javascript + Scenario: Subsection completion should not be editable in the completion bulk edit + Given I am on the "C1" "Course" page logged in as "teacher1" + When I navigate to "Course completion" in current page administration + And I set the field "Course completion tertiary navigation" to "Bulk edit activity completion" + And I should see "Bulk edit activity completion" + Then I should see "Wiki activity" in the "region-main" "region" + Then I should see "Page in Subsection" in the "region-main" "region" + # It appears as a subsection but not as an editable element. + Then I should see "Subsection 1" in the "region-main" "region" + And "Subsection 1" "link" in the "region-main" "region" should not be visible