MDL-71370 course: Make showcompletionconditions nullable

* When completion tracking is not enabled for the course, it does not
make sense for the course's showcompletionconditions setting to
be set according to the default value indicated by the
"moodlecourse | showcompletionconditions" admin setting. Setting
showcompletionconditions as enabled when completion tracking is disabled
makes even less sense. So in such a case, we should not be setting a
default value for showcompletionconditions and allow it to be null.

* When the course is edited and completion tracking is enabled, this
also would set the "Show completion conditions" field to default to the
value set in the "moodlecourse | showcompletionconditions" admin
setting.
This commit is contained in:
Jun Pataleta
2021-04-24 19:07:42 +08:00
parent 146a38dc45
commit fca42002f7
6 changed files with 67 additions and 16 deletions
@@ -50,20 +50,32 @@ Feature: Allow teachers to edit the visibility of completion conditions in a cou
And I follow "Test choice manual"
And the manual completion button for "Test choice manual" should be disabled
Scenario: Default show completion conditions value in course form when default show completion conditions admin setting is set to No
Scenario Outline: Default showcompletionconditions value in course form on course creation
Given I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
When I set the following fields to these values:
| Show completion conditions | No |
And I click on "Save changes" "button"
And I navigate to "Courses > Add a new course" in site administration
Then the field "showcompletionconditions" matches value "No"
And I set the field "Show completion conditions" to "<siteshowcompletion>"
And I press "Save changes"
When I navigate to "Courses > Add a new course" in site administration
Then the field "showcompletionconditions" matches value "<expected>"
Scenario: Default show completion conditions value in course form when default show completion conditions admin setting is set to Yes
Examples:
| siteshowcompletion | expected |
| Yes | Yes |
| No | No |
Scenario Outline: Default showcompletionconditions displayed when editing a course with disabled completion tracking
Given I log in as "admin"
And I navigate to "Courses > Course default settings" in site administration
When I set the following fields to these values:
| Show completion conditions | Yes |
And I click on "Save changes" "button"
And I navigate to "Courses > Add a new course" in site administration
Then the field "showcompletionconditions" matches value "Yes"
And I set the field "Show completion conditions" to "<siteshowcompletion>"
And I press "Save changes"
And I am on "Course 1" course homepage with editing mode on
And I navigate to "Edit settings" in current page administration
And I set the field "Enable completion tracking" to "No"
And I press "Save and display"
And I navigate to "Edit settings" in current page administration
Then the field "Show completion conditions" matches value "<expected>"
Examples:
| siteshowcompletion | expected |
| Yes | Yes |
| No | No |