diff --git a/completion/tests/behat/site_default_activity_completion.feature b/completion/tests/behat/site_default_activity_completion.feature index ccb01119a357f..9c16275f25b49 100644 --- a/completion/tests/behat/site_default_activity_completion.feature +++ b/completion/tests/behat/site_default_activity_completion.feature @@ -10,70 +10,64 @@ Feature: Allow admins to edit the default activity completion rules at site leve | Course 1 | C1 | 0 | 1 | And I log in as "admin" - @javascript - Scenario: Default activity completion rules with no site or course default completion + Scenario: Default values don't affect existing activities when no site or course defaults are defined Given the following "activity" exists: - | activity | assign | - | course | C1 | - | name | Test assignment one | - | completion | 1 | - And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" - When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" - And I expand all fieldsets - # Completion tracking 0 = Do not indicate activity completion. + | activity | assign | + | course | C1 | + | name | Test assignment one | + | completion | 1 | + And I am on the "Test assignment one" Activity page + When I navigate to "Settings" in current page administration + Then the field "Completion tracking" matches value "1" + + Scenario: Default activity completion rules with no site or course default completion + When I am adding an assign to section 0 of the "Course 1" course Then the field "Completion tracking" matches value "0" - # Default values don't affect existing activities. - But I am on the "Test assignment one" Activity page - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And the field "Completion tracking" matches value "1" - @javascript - Scenario: Default activity completion rules with site default completion but with no course default completion + Scenario: Default values don't affect existing activities when site default completion are defined Given the following "activity" exists: - | activity | assign | - | course | C1 | - | name | Test assignment one | - | completion | 0 | + | activity | assign | + | course | C1 | + | name | Test assignment one | + | completion | 0 | And the following "core_completion > Course default" exist: | course | module | completion | completionview | completionusegrade | completionsubmit | | Acceptance test site | assign | 2 | 0 | 1 | 1 | - And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" - When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" - And I expand all fieldsets + And I am on the "Test assignment one" Activity page + When I navigate to "Settings" in current page administration + Then the field "Completion tracking" matches value "0" + + Scenario: Default activity completion rules with site default completion but with no course default completion + Given the following "core_completion > Course default" exist: + | course | module | completion | completionview | completionusegrade | completionsubmit | + | Acceptance test site | assign | 2 | 0 | 1 | 1 | + When I am adding an assign to section 0 of the "Course 1" course Then the field "Completion tracking" matches value "2" And the field "completionview" matches value "0" And the field "completionusegrade" matches value "1" And the field "completionsubmit" matches value "1" - # Default values don't affect existing activities. - But I am on the "Test assignment one" Activity page - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And the field "Completion tracking" matches value "0" - @javascript - Scenario: Default activity completion rules with site default completion and course default completion + Scenario: Default values don't affect existing activities when site and course defaults completion are defined Given the following "activity" exists: - | activity | assign | - | course | C1 | - | name | Test assignment one | - | completion | 0 | + | activity | assign | + | course | C1 | + | name | Test assignment one | + | completion | 0 | And the following "core_completion > Course defaults" exist: | course | module | completion | completionview | completionusegrade | completionsubmit | | Acceptance test site | assign | 2 | 0 | 1 | 1 | | C1 | assign | 2 | 1 | 0 | 1 | - And I am on "Course 1" course homepage with editing mode on - And I press "Add an activity or resource" - When I click on "Add a new Assignment" "link" in the "Add an activity or resource" "dialogue" - And I expand all fieldsets + And I am on the "Test assignment one" Activity page + When I navigate to "Settings" in current page administration + Then the field "Completion tracking" matches value "0" + + Scenario: Default activity completion rules with site default completion and course default completion + Given the following "core_completion > Course defaults" exist: + | course | module | completion | completionview | completionusegrade | completionsubmit | + | Acceptance test site | assign | 2 | 0 | 1 | 1 | + | C1 | assign | 2 | 1 | 0 | 1 | + When I am adding an assign to section 0 of the "Course 1" course Then the field "Completion tracking" matches value "2" And the field "completionview" matches value "1" And the field "completionusegrade" matches value "0" And the field "completionsubmit" matches value "1" - # Default values don't affect existing activities. - But I am on the "Test assignment one" Activity page - And I navigate to "Settings" in current page administration - And I expand all fieldsets - And the field "Completion tracking" matches value "0" diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index f14bcbf4cd09c..160f0071d608c 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -987,6 +987,25 @@ public function i_am_on_course_homepage_with_editing_mode_set_to(string $coursef $this->execute('behat_general::i_visit', [$editmodeurl]); } + /** + * Open a add activity form page. + * + * @Given I am adding a :activity to section :sectionnum of the :coursefullname course + * @Given I am adding an :activity to section :sectionnum of the :coursefullname course + * @throws coding_exception + * @param string $activity The activity name. + * @param int $sectionnum The section number. + * @param string $coursefullname The course full name of the course. + */ + public function i_am_adding_activity_to_section_of_the_course(string $activity, string $sectionnum, string $coursefullname): void { + $addurl = new moodle_url('/course/modedit.php', [ + 'add' => $activity, + 'course' => $this->get_course_id($coursefullname), + 'section' => intval($sectionnum), + ]); + $this->execute('behat_general::i_visit', [$addurl]); + } + /** * Opens the flat navigation drawer if it is not already open *