first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,145 @@
@availability @availability_completion
Feature: availability_completion
In order to control student access to activities
As a teacher
I need to set completion conditions which prevent student access
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "users" exist:
| username |
| teacher1 |
| student1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | name | completion |
| page | C1 | Page 1 | 1 |
| page | C1 | Page 2 | |
| page | C1 | Page 3 | 1 |
| page | C1 | Page 4 | |
@javascript
Scenario: Test condition
# Basic setup.
Given I am on the "Page 2" "page activity editing" page logged in as "teacher1"
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "Activity or resource" to "Page 1"
And I press "Save and return to course"
# Log back in as student.
When I am on the "Course 1" "course" page logged in as "student1"
# Page 2 should not appear yet.
Then I should not see "Page 2" in the "region-main" "region"
# Mark page 1 complete
When I toggle the manual completion state of "Page 1"
Then I should see "Page 2" in the "region-main" "region"
@javascript
Scenario: Test completion and course cache rebuild
Given the following "activities" exist:
| activity | name | course | idnumber | completion | completionview | completionpostsenabled | completionposts |
| forum | forum 1 | C1 | forum1 | 2 | 1 | 1 | 2 |
And the following "mod_forum > discussions" exist:
| forum | subject | message |
| forum1 | Forum post 1 | This is the body |
And I am on the "Page 2" "page activity editing" page logged in as "teacher1"
And I expand all fieldsets
And I press "Add restriction..."
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the following fields to these values:
| Required completion status | must be marked complete |
| cm | forum 1 |
And I press "Save and return to course"
When I am on the "Course 1" "course" page logged in as "student1"
# Page 2 should not appear yet.
Then I should not see "Page 2" in the "region-main" "region"
And I click on "forum 1" "link" in the "region-main" "region"
# Page 2 should not appear yet.
And I should not see "Page 2" in the "region-main" "region"
And I am on the "forum 1" "forum activity editing" page logged in as "teacher1"
And I expand all fieldsets
And I set the following fields to these values:
| completionpostsenabled | 0 |
And I press "Save and display"
And I am on the "Course 1" "course" page logged in as "student1"
And I click on "forum 1" "link" in the "region-main" "region"
And I am on "Course 1" course homepage
And I should see "Page 2" in the "region-main" "region"
@javascript
Scenario Outline: Restrict access for activity completion should display correctly
Given the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the first question |
And the following "activities" exist:
| activity | name | course | idnumber | gradepass | completion | completionpassgrade | completionusegrade |
| quiz | Test quiz name | C1 | quiz1 | 5.00 | 2 | 1 | 1 |
And quiz "Test quiz name" contains the following questions:
| question | page |
| First question | 1 |
And I am on the "Page 2" "page activity editing" page logged in as "teacher1"
And I expand all fieldsets
And I press "Add restriction..."
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the following fields to these values:
| Required completion status | <condition> |
| cm | quiz |
And I press "Save and return to course"
And I am on the "Course 1" "course" page logged in as "student1"
And I <shouldornot> see "Page 2" in the "region-main" "region"
# Failed grade for quiz.
When user "student1" has attempted "Test quiz name" with responses:
| slot | response |
| 1 | <answer1> |
And I reload the page
And I <shouldornotanswer1> see "Page 2" in the "region-main" "region"
# Passing grade for quiz.
But user "student1" has attempted "Test quiz name" with responses:
| slot | response |
| 1 | <answer2> |
And I reload the page
And I <shouldornotanswer2> see "Page 2" in the "region-main" "region"
Examples:
| condition | answer1 | answer2 | shouldornot | shouldornotanswer1 | shouldornotanswer2 |
| must be marked complete | False | True | should not | should not | should |
| must not be marked complete | False | True | should | should | should not |
| must be complete with pass grade | False | True | should not | should not | should |
| must be complete with fail grade | False | True | should not | should | should not |
@javascript
Scenario: Edit dependent activity name should also change the access restriction message
Given I am on the "Page 2" "page activity editing" page logged in as "teacher1"
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "Activity or resource" to "Page 1"
And I press "Save and return to course"
And I am on the "Page 4" "page activity editing" page
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on ".availability-item .availability-eye img" "css_element"
And I set the field "Activity or resource" to "Page 3"
And I press "Save and return to course"
And I switch editing mode on
And I set the field "Edit title" in the "Page 1" "activity" to "Page X"
And I wait until the page is ready
Then I should see "Not available unless: The activity Page X is marked complete" in the "Page 2" "activity"
Then I should see "Not available unless: The activity Page 3 is marked complete" in the "Page 4" "activity"
@@ -0,0 +1,204 @@
@availability @availability_completion
Feature: Confirm that availability_completion works with previous activity setting
In order to control student access to activities
As a teacher
I need to set completion conditions which prevent student access
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion | numsections |
| Course 1 | C1 | topics | 1 | 5 |
And the following "users" exist:
| username |
| teacher1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
Given the following "activities" exist:
| activity | name | intro | course | idnumber | groupmode | completion | section |
| page | Page1 | Page 1 description | C1 | page1 | 1 | 1 | 1 |
| page | Page Ignored 1 | Page Ignored | C1 | pagei1 | 1 | 0 | 1 |
| page | Page2 | Page 2 description | C1 | page2 | 1 | 1 | 3 |
| page | Page3 | Page 3 description | C1 | page3 | 1 | 1 | 4 |
@javascript
Scenario: Test condition with previous activity on an activity
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Set Page3 restriction to Previous Activity with completion.
When I open "Page3" actions menu
And I click on "Edit settings" "link" in the "Page3" activity
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save and return to course"
Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
When I turn editing mode off
Then I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region"
# Remove Page 2 and check Page3 depends now on Page1.
When I turn editing mode on
And I change window size to "large"
And I delete "Page2" activity
And I turn editing mode off
Then I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region"
@javascript
Scenario: Test previous activity availability when duplicate an activity
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Set Page3 restriction to Previous Activity with completion.
When I open "Page3" actions menu
And I click on "Edit settings" "link" in the "Page3" activity
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save and return to course"
Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
When I turn editing mode off
Then I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region"
# Duplicate Page3.
When I turn editing mode on
And I duplicate "Page3" activity
And I turn editing mode off
Then I should see "Not available unless: The activity Page3 is marked complete" in the "region-main" "region"
@javascript
Scenario: Test previous activity availability when modify completion tacking
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Set Page3 restriction to Previous Activity with completion.
When I open "Page3" actions menu
And I click on "Edit settings" "link" in the "Page3" activity
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save and return to course"
Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
When I turn editing mode off
Then I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region"
# Test if I disable completion tracking on Page2 section 5 depends on Page2.
When I turn editing mode on
And I change window size to "large"
When I open "Page2" actions menu
And I click on "Edit settings" "link" in the "Page2" activity
And I set the following fields to these values:
| None | 1 |
And I press "Save and return to course"
When I turn editing mode off
Then I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region"
@javascript
Scenario: Test condition with previous activity on a section
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Set section 4 restriction to Previous Activity with completion.
When I edit the section "4"
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save changes"
Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
When I turn editing mode off
Then I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region"
# Remove Page 2 and check Section 4 depends now on Page1.
When I am on "Course 1" course homepage with editing mode on
And I change window size to "large"
And I delete "Page2" activity
And I turn editing mode off
Then I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region"
@javascript
Scenario: Test condition with previous activity on the first activity of the course
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
# Try to set Page1 restriction to Previous Activity with completion.
When I open "Page1" actions menu
And I click on "Edit settings" "link" in the "Page1" activity
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
Then the "Activity or resource" select box should not contain "Previous activity with completion"
# Set Page2 restriction to Previous Activity with completion and delete Page1.
When I am on "Course 1" course homepage
When I open "Page2" actions menu
And I click on "Edit settings" "link" in the "Page2" activity
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save and return to course"
Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
# Delete Page 1 and check than Page2 now depends on a missing activity (no previous activity found).
When I am on "Course 1" course homepage
And I delete "Page1" activity
And I turn editing mode off
Then I should see "Not available unless: The activity (Missing activity)" in the "region-main" "region"
@javascript
Scenario: Test previous activities on empty sections
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I change window size to "large"
# Set section 2 restriction to Previous Activity with completion.
When I edit the section "2"
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save changes"
Then I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
And I turn editing mode off
And I should see "Not available unless: The activity Page1 is marked complete" in the "region-main" "region"
# Set section 5 restriction to Previous Activity with completion.
And I am on "Course 1" course homepage with editing mode on
And I edit the section "5"
And I expand all fieldsets
And I click on "Add restriction..." "button"
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I click on "Displayed if student doesn't meet this condition Click to hide" "link"
And I set the field "Activity or resource" to "Previous activity with completion"
And I press "Save changes"
And I should see "Not available unless: The previous activity with completion" in the "region-main" "region"
And I turn editing mode off
Then I should see "Not available unless: The activity Page3 is marked complete" in the "region-main" "region"
# Test if I disable completion tracking on Page3 section 5 depends on Page2.
And I am on "Course 1" course homepage with editing mode on
And I open "Page3" actions menu
And I click on "Edit settings" "link" in the "Page3" activity
And I set the following fields to these values:
| None | 1 |
And I press "Save and return to course"
And I turn editing mode off
And I should see "Not available unless: The activity Page2 is marked complete" in the "region-main" "region"
@@ -0,0 +1,47 @@
@availability @availability_completion
Feature: Confirm that conditions on completion no longer cause a bug
In order to use completion conditions
As a teacher
I need it to not break when I set up certain conditions on some modules
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "users" exist:
| username |
| teacher1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
@javascript
Scenario: Multiple completion conditions on glossary
# Add a couple of Pages with manual completion.
And the following "activities" exist:
| activity | course | name | completion |
| page | C1 | Page1 | 1 |
| page | C1 | Page2 | 1 |
And I log in as "teacher1"
# Add a Glossary.
When I add a glossary activity to course "Course 1" section "1"
And I set the following fields to these values:
| Name | TestGlossary |
And I expand all fieldsets
# Add restrictions to the previous Pages being complete.
And I press "Add restriction..."
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I set the field "Activity or resource" to "Page1"
And I press "Add restriction..."
And I click on "Activity completion" "button" in the "Add restriction..." "dialogue"
And I set the field with xpath "//div[contains(concat(' ', normalize-space(@class), ' '), ' availability-item ')][preceding-sibling::div]//select[@name='cm']" to "Page2"
And I press "Save and return to course"
And I click on "Show more" "button" in the "TestGlossary" "core_availability > Activity availability"
Then I should see "Not available unless:" in the ".activity.glossary" "css_element"
And I should see "The activity Page1 is marked complete" in the ".activity.glossary" "css_element"
And I should see "The activity Page2 is marked complete" in the ".activity.glossary" "css_element"
# Behat will automatically check there is no error on this page.
And I am on the TestGlossary "glossary activity" page
And I should see "TestGlossary"