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
+208
View File
@@ -0,0 +1,208 @@
@core @core_badges
Feature: Add badges to the system
In order to give badges to users for their achievements
As an admin
I need to manage badges in the system
Background:
Given I am on homepage
And I log in as "admin"
@javascript
Scenario: Accessing the badges
And I turn editing mode on
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
# TODO MDL-57120 site "Badges" link not accessible without navigation block.
And I add the "Navigation" block if not present
And I click on "Site pages" "list_item" in the "Navigation" "block"
Given I click on "Site badges" "link" in the "Navigation" "block"
Then I should see "There are no matching badges available for users to earn"
@javascript @_file_upload
Scenario: Add a badge
Given I navigate to "Badges > Badges settings" in site administration
And I set the field "Badge issuer name" to "Test Badge Site"
And I set the field "Badge issuer email address" to "testuser@example.com"
And I press "Save changes"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test badge with 'apostrophe' and other friends (<>&@#) |
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| Tags | Math, Physics |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Edit details"
And I should see "Test badge with 'apostrophe' and other friends (&@#)"
And I should see "Endorsement"
And I should see "Related badges (0)"
And I should see "Alignments (0)"
And I should not see "Create badge"
And I should not see "Issuer details"
And I select "Overview" from the "jump" singleselect
And I should see "Issuer details"
And I should see "Test Badge Site"
And I should see "testuser@example.com"
And I should see "Tags"
And I should see "Math"
And I should see "Physics"
And I navigate to "Badges > Manage badges" in site administration
And I should not see "There are no matching badges available for users to earn"
@javascript @_file_upload
Scenario: Add a badge related
Given I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test Badge 1 |
| Version | v1 |
| Language | French |
| Description | Test badge related description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I wait until the page is ready
And I navigate to "Badges > Manage badges" in site administration
And I press "Add a new badge"
And I set the following fields to these values:
| Name | Test Badge 2 |
| Version | v2 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I select "Related badges (0)" from the "jump" singleselect
And I should see "This badge does not have any related badges."
And I press "Add related badge"
And I follow "Related badges"
And I wait until the page is ready
And I follow "Related badges"
And I set the field "relatedbadgeids[]" to "Test Badge 1 (version: v1, language: French, Site badges)"
When I press "Save changes"
Then I should see "Related badges (1)"
@javascript @_file_upload
Scenario: Endorsement for Badge
Given I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test Badge Enrolment |
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Edit details"
And I should see "Endorsement"
And I select "Endorsement" from the "jump" singleselect
And I set the following fields to these values:
| Endorser name | Endorser |
| Email | endorsement@example.com |
| Issuer URL | http://example.com |
| Claim URL | http://claimurl.example.com |
| Endorsement comment | Test Endorsement comment |
And I press "Save changes"
Then I should see "Changes saved"
@javascript @_file_upload
Scenario: Alignments for Badge
Given I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test Badge |
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Test Badge"
And I should see "Endorsement"
And I select "Alignments (0)" from the "jump" singleselect
And I should see "This badge does not have any external skills or standards specified."
And I press "Add external skill or standard"
And I set the following fields to these values:
| Name | Test Badge Alignments |
| URL | https://alignments.example.com |
| Description | Test Badge Alignments description |
When I press "Save changes"
And I should see "Alignments (1)"
@javascript @_file_upload
Scenario: Add a badge from Site badges section
Given I turn editing mode on
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
# TODO MDL-57120 site "Badges" link not accessible without navigation block.
And I add the "Navigation" block if not present
When I click on "Site pages" "list_item" in the "Navigation" "block"
And I click on "Site badges" "link" in the "Navigation" "block"
Then I should see "Add a new badge"
# Add a badge.
When I press "Add a new badge"
And I set the following fields to these values:
| Name | Test badge with 'apostrophe' and other friends (<>&@#) 2 |
| Version | v1 |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
Then I should see "Edit details"
And I should see "Test badge with 'apostrophe' and other friends (&@#) 2"
And I should see "Endorsement"
And I should see "Related badges (0)"
And I should see "Alignments (0)"
And I should not see "Create badge"
And I navigate to "Badges > Manage badges" in site administration
And I should not see "There are no matching badges available for users to earn"
# See buttons from the "Site badges" page.
And I am on homepage
When I click on "Site pages" "list_item" in the "Navigation" "block"
And I click on "Site badges" "link" in the "Navigation" "block"
Then I should see "Manage badges"
And I should see "Add a new badge"
@javascript @_file_upload
Scenario: Edit a badge
Given I navigate to "Badges > Badges settings" in site administration
And I set the field "Badge issuer name" to "Test Badge Site"
And I set the field "Badge issuer email address" to "testuser@example.com"
And I press "Save changes"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Test badge with 'apostrophe' and other friends (<>&@#) |
| Version | firstversion |
| Language | English |
| Description | Test badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
| Tags | Math, Physics |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
When I select "Edit details" from the "jump" singleselect
And I should see "Test badge with 'apostrophe' and other friends (&@#)"
And I should not see "Issuer details"
And I should see "Math"
And I should see "Physics"
And I set the following fields to these values:
| Name | Test badge renamed |
| Version | secondversion |
| Tags | Math, History |
And I press "Save changes"
And I select "Overview" from the "jump" singleselect
Then I should not see "Test badge with 'apostrophe' and other friends (&@#)"
And I should not see "firstversion"
And I should not see "Math, Physics"
And I should see "Test badge renamed"
And I should see "secondversion"
And I should see "Math"
And I should see "History"
+381
View File
@@ -0,0 +1,381 @@
@core @core_badges @_file_upload
Feature: Award badges
In order to award badges to users for their achievements
As an admin
I need to add criteria to badges in the system
Background:
Given the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "activity" exists:
| activity | assign |
| course | C1 |
| section | 1 |
| name | Test assignment name |
| intro | Submit your online text |
| completion | 1 |
| assignsubmission_onlinetext_enabled | 1 |
@javascript
Scenario: Award badge on other badges as criteria
Given I log in as "teacher1"
And I am on "Course 1" course homepage
# Create course badge 1.
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge 1 |
| Description | Course badge 1 description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
# Set to ANY of the roles awards badge.
And I set the field "Teacher" to "1"
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
# Badge #2
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge 2 |
| Description | Course badge 2 description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
# Set "course badge 1" as criteria
And I set the field "type" to "Awarded badges"
And I set the field "id_badge_badges" to "Course Badge 1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
# Award course badge 1 to student 1.
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I select "Recipients (1)" from the "jump" singleselect
Then I should see "Recipients (1)"
And I log out
# Student 1 should have both badges.
And I log in as "student1"
And I follow "Profile" in the user menu
When I click on "Course 1" "link" in the "region-main" "region"
Then I should see "Course Badge 1"
And I should see "Course Badge 2"
# Student 1 should have both badges also in the Badges navigation section.
When I follow "Badges"
Then I should see "Course Badge 1"
And I should see "Course Badge 2"
And I should not see "Manage badges"
And I should not see "Add a new badge"
And I log out
# Teacher 1 should have access to manage/create badges in the Badges navigation section.
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
Then I should see "Course Badge 1"
And I should see "Course Badge 2"
And I should see "Manage badges"
And I should see "Add a new badge"
# Teacher 1 should NOT have access to manage/create site badges in the Site badges section.
When I am on homepage
And I turn editing mode on
And the following config values are set as admin:
| unaddableblocks | | theme_boost|
# TODO MDL-57120 site "Badges" link not accessible without navigation block.
And I add the "Navigation" block if not present
And I click on "Site pages" "list_item" in the "Navigation" "block"
And I click on "Site badges" "link" in the "Navigation" "block"
Then I should see "There are no matching badges available for users to earn"
And I should not see "Manage badges"
And I should not see "Add a new badge"
@javascript
Scenario: Award profile badge
Given I log in as "admin"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Profile Badge |
| Description | Test badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Profile completion"
And I expand all fieldsets
And I set the field "First name" to "1"
And I set the field "Email address" to "1"
And I set the field "Phone" to "1"
And I set the field "id_description" to "Criterion description"
When I press "Save"
Then I should see "Profile completion"
And I should see "First name"
And I should see "Email address"
And I should see "Phone"
And I should see "Criterion description"
And I should not see "Criteria for this badge have not been set up yet."
And I press "Enable access"
And I press "Continue"
And I open my profile in edit mode
And I expand all fieldsets
And I set the field "Phone" to "123456789"
And I press "Update profile"
And I follow "Profile" in the user menu
Then I should see "Profile Badge"
@javascript
Scenario: Award site badge
Given I log in as "admin"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Site Badge |
| Description | Site badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I set the field "Teacher" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
And I navigate to "Badges > Manage badges" in site administration
When I follow "Site Badge"
Then I should see "Recipients (2)"
And I log out
And I log in as "student1"
And I follow "Profile" in the user menu
Then I should see "Site Badge"
@javascript
Scenario: Award course badge
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I set the field "Teacher" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (2)"
And I log out
And I log in as "student1"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
And I click on "Course Badge" "link"
And I should see "Course: Course 1"
@javascript
Scenario: Award badge on activity completion
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I change window size to "large"
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Activity completion"
And I set the field "Test assignment name" to "1"
And I press "Save"
And I press "Enable access"
When I press "Continue"
And I log out
And I log in as "student1"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
Then I should not see "badges"
And I am on "Course 1" course homepage
And I toggle the manual completion state of "Test assignment name"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
Then I should see "Course Badge"
@javascript
Scenario: Award badge on course completion
Given the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Music history |
| section | 1 |
| completion | 2 |
| completionview | 1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Course completion" in current page administration
And I set the field "id_overall_aggregation" to "2"
And I click on "Condition: Activity completion" "link"
And I set the field "Assignment - Music history" to "1"
And I press "Save changes"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Course completion"
And I set the field with xpath ".//*[contains(., 'Minimum grade required')]/ancestor::*[contains(concat(' ', @class, ' '), ' fitem ')]//input[1]" to "0"
And I press "Save"
And I press "Enable access"
When I press "Continue"
And I log out
And I log in as "student1"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
Then I should not see "badges"
When I am on the "Music history" "assign activity" page
And I log out
# Completion cron won't mark the whole course completed unless the
# individual criteria was marked completed more than a second ago. So
# run it twice, first to mark the criteria and second for the course.
And I run the scheduled task "core\task\completion_regular_task"
And I wait "1" seconds
And I run the scheduled task "core\task\completion_regular_task"
# The student should now see their badge.
And I log in as "student1"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
Then I should see "Course Badge"
@javascript
Scenario: All of the selected roles can award badges
Given I log in as "teacher1"
And I am on "Course 1" course homepage
# Create course badge 1.
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge 1 |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
# Set to ANY of the roles awards badge.
And I set the field "Teacher" to "1"
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
# Award course badge 1 to student 1.
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I select "Recipients (1)" from the "jump" singleselect
Then I should see "Recipients (1)"
# Add course badge 2.
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge 2 |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
# Set to ALL of the selected roles award badge.
And I set the field "Teacher" to "1"
And I set the field "All of the selected roles award the badge" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
# Award course badge 2 to student 2.
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 2"
And I select "Recipients (1)" from the "jump" singleselect
Then I should see "Recipients (1)"
And I log out
And I trigger cron
# Student 1 should have just course badge 1.
And I log in as "student1"
And I follow "Profile" in the user menu
When I click on "Course 1" "link" in the "region-main" "region"
Then I should see "Course Badge 1"
And I should not see "Course Badge 2"
And I log out
# Student 2 should have just course badge 2.
And I log in as "student2"
And I follow "Profile" in the user menu
When I click on "Course 1" "link" in the "region-main" "region"
Then I should see "Course Badge 2"
Then I should not see "Course Badge 1"
@javascript
Scenario: Revoke badge
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I set the field "Teacher" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (2)"
And I select "Recipients (2)" from the "jump" singleselect
And I press "Award badge"
And I set the field "existingrecipients[]" to "Student 2 (student2@example.com)"
And I press "Revoke badge"
And I set the field "existingrecipients[]" to "Student 1 (student1@example.com)"
When I press "Revoke badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (0)"
@@ -0,0 +1,215 @@
@core @core_badges @_file_upload
Feature: Award badges with separate groups
In order to award badges to users for their achievements
As a teacher
I need to award badges only to users in the groups I have access
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| teacher2 | Teacher | 2 | teacher2@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname | category | groupmode |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| teacher2 | C1 | teacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following "groups" exist:
| name | course | idnumber |
| Class A | C1 | CA |
| Class B | C1 | CB |
And the following "group members" exist:
| user | group |
| student1 | CB |
| teacher1 | CB |
| student2 | CA |
| teacher2 | CA |
And I am on the "Course 1" "course editing" page logged in as "teacher1"
And I expand all fieldsets
And I set the field "Group mode" to "Separate groups"
And I press "Save and display"
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Teacher" to "1"
And I set the field "Non-editing teacher" to "1"
# Set to ANY of the roles awards badge.
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I log out
@javascript
Scenario: Award course badge as non-editing teacher with only one group
When I log in as "teacher2"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I press "Award badge"
And I set the field "role" to "Non-editing teacher"
# Teacher 2 should see a "Separate groups" label with the group he is in
Then I should see "Separate groups: Class A"
# Teacher 2 should only see the users who belong to the same group as he does
And I should see "Student 2"
And I should not see "Student 1"
# Non-editing teacher can award the badge
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
And I press "Award badge"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I should see "Recipients (1)"
And I log out
And I log in as "student2"
And I follow "Profile" in the user menu
And I click on "Course 1" "link" in the "region-main" "region"
And I should see "Course Badge"
And I log out
@javascript
Scenario: Award course badge as non-editing teacher with more than one group
Given I log in as "teacher1"
And I am on the "Course 1" "groups" page
And I set the field "groups" to "Class B (2)"
And I press "Add/remove users"
And I set the field "addselect" to "Teacher 2 (teacher2@example.com)"
And I press "Add"
And I log out
When I log in as "teacher2"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I press "Award badge"
And I set the field "role" to "Non-editing teacher"
# Teacher 2 should see a "Separate groups" label and a dropdown menu with the groups he belongs to
And I set the field "Separate groups" to "Class A"
Then I should see "Student 2"
And I should not see "Student 1"
And I set the field "Separate groups" to "Class B"
And I should see "Student 1"
And I should not see "Student 2"
And I log out
@javascript
Scenario: Award course badge as non-editing teacher without any group
Given I log in as "teacher1"
And I am on the "Course 1" "groups" page
And I set the field "groups" to "Class A (2)"
And I press "Add/remove users"
And I set the field "removeselect" to "Teacher 2 (teacher2@example.com)"
And I press "Remove"
And I press "Back to groups"
And I log out
When I log in as "teacher2"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I press "Award badge"
# Teacher 2 shouldn't be able to go further
Then I should see "Sorry, but you need to be part of a group to see this page."
@javascript
Scenario: Editing teacher can award badge to members of separate groups
Given I am on the "Course 1" course page logged in as teacher1
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I press "Award badge"
When I set the field "role" to "Teacher"
# Confirm that editing teacher sees a separate groups dropdown menu.
Then "Separate groups" "select" should exist
And I should see "All participants" in the "Separate groups" "select"
# Confirm that all participants are displayed when All participants is selected.
And I should see "Student 1" in the "potentialrecipients[]" "select"
And I should see "Student 2" in the "potentialrecipients[]" "select"
And I should see "Teacher 1" in the "potentialrecipients[]" "select"
And I should see "Teacher 2" in the "potentialrecipients[]" "select"
And I set the field "Separate groups" to "Class A"
# Confirm that only members of selected group are displayed
And I should not see "Student 1" in the "potentialrecipients[]" "select"
And I should not see "Teacher 1" in the "potentialrecipients[]" "select"
And I should see "Student 2" in the "potentialrecipients[]" "select"
And I should see "Teacher 2" in the "potentialrecipients[]" "select"
And I set the field "Separate groups" to "Class B"
And I should not see "Student 2" in the "potentialrecipients[]" "select"
And I should not see "Teacher 2" in the "potentialrecipients[]" "select"
And I should see "Student 1" in the "potentialrecipients[]" "select"
And I should see "Teacher 1" in the "potentialrecipients[]" "select"
@javascript
Scenario Outline: Teacher can award badge to members of visible groups
Given I am on the "Course 1" "course editing" page logged in as teacher1
And I expand all fieldsets
# Set the group mode to visible groups.
And I set the field "Group mode" to "Visible groups"
And I press "Save and display"
When I am on the "Course 1" course page logged in as <loggedinuser>
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I press "Award badge"
And I set the field "role" to "<awarder>"
# Confirm that teachers see a visible groups dropdown menu.
Then "Visible groups" "select" should exist
# Confirm that My groups option group exists.
And "optgroup[label='My groups']" "css_element" should exist in the "select[name='group']" "css_element"
# Confirm that Other groups option group exists.
And "optgroup[label='Other groups']" "css_element" should exist in the "select[name='group']" "css_element"
# Confirm that all participants are displayed when All participants is selected.
And I set the field "Visible groups" to "All participants"
And I should see "Student 1" in the "potentialrecipients[]" "select"
And I should see "Student 2" in the "potentialrecipients[]" "select"
And I should see "Teacher 1" in the "potentialrecipients[]" "select"
And I should see "Teacher 2" in the "potentialrecipients[]" "select"
# Confirm that only members of selected group are displayed.
And I set the field "Visible groups" to "Class A"
And I should not see "Student 1" in the "potentialrecipients[]" "select"
And I should not see "Teacher 1" in the "potentialrecipients[]" "select"
And I should see "Student 2" in the "potentialrecipients[]" "select"
And I should see "Teacher 2" in the "potentialrecipients[]" "select"
And I set the field "Visible groups" to "Class B"
And I should not see "Student 2" in the "potentialrecipients[]" "select"
And I should not see "Teacher 2" in the "potentialrecipients[]" "select"
And I should see "Student 1" in the "potentialrecipients[]" "select"
And I should see "Teacher 1" in the "potentialrecipients[]" "select"
Examples:
| loggedinuser | awarder |
| teacher1 | Teacher |
| teacher2 | Non-editing teacher |
@javascript
Scenario Outline: Teacher can award badge to members when group mode is set to no groups
Given I am on the "Course 1" "course editing" page logged in as teacher1
And I expand all fieldsets
# Set the group mode to no groups.
And I set the field "Group mode" to "No groups"
And I press "Save and display"
When I am on the "Course 1" course page logged in as <loggedinuser>
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I press "Award badge"
And I set the field "role" to "<awarder>"
# Confirm that no group dropdowns don't exist.
Then "Separate groups" "select" should not exist
And "Visible groups" "select" should not exist
# Confirm all participants are displayed.
And I should see "Student 1" in the "potentialrecipients[]" "select"
And I should see "Student 2" in the "potentialrecipients[]" "select"
And I should see "Teacher 1" in the "potentialrecipients[]" "select"
And I should see "Teacher 2" in the "potentialrecipients[]" "select"
Examples:
| loggedinuser | awarder |
| teacher1 | Teacher |
| teacher2 | Non-editing teacher |
+204
View File
@@ -0,0 +1,204 @@
@core @core_badges
Feature: Backpack badges
Test the settings to add/update a backpack for a site and user.
I need to verify display backpack in the my profile
Background:
Given the following "badge external backpacks" exist:
| backpackapiurl | backpackweburl | apiversion | sortorder |
| https://dc.imsglobal.org/obchost/ims/ob/v2p1 | https://dc.imsglobal.org | 2.1 | 2 |
| https://test.com/ | https://test.com/ | 2 | 3 |
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
And I log in as "admin"
And I navigate to "Badges > Badges settings" in site administration
And I set the field "Badge issuer name" to "Test Badge Site"
And I set the field "Badge issuer email address" to "testuser@example.com"
And I log out
@javascript
Scenario: If external backpack connection is disabled, backpack settings should not be displayed
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Badges settings" in site administration
And I set the following fields to these values:
| External backpack connection | 0 |
And I press "Save changes"
When I navigate to "Badges" in site administration
Then I should not see "Manage backpacks"
And I navigate to "Badges > Badges settings" in site administration
And I set the following fields to these values:
| External backpack connection | 1 |
And I press "Save changes"
And I am on homepage
And I navigate to "Badges" in site administration
And I should see "Manage backpacks"
@javascript
Scenario: Verify backback settings
Given the following "core_badges > Badge" exists:
| name | Test badge verify backpack |
| version | 1 |
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criteria" exists:
| badge | Test badge verify backpack |
| role | editingteacher |
And the following "core_badges > Issued badge" exists:
| badge | Test badge verify backpack |
| user | student1 |
When I log in as "student1"
And I follow "Preferences" in the user menu
And I follow "Backpack settings"
Then I should see "Choose..." in the "Backpack provider" "select"
@javascript
Scenario: User has been connected backpack
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Badges settings" in site administration
And I set the following fields to these values:
| External backpack connection | 1 |
And I press "Save changes"
And I navigate to "Badges > Manage backpacks" in site administration
And I click on "Move up" "link" in the "https://dc.imsglobal.org" "table_row"
And the following "core_badges > Badge" exists:
| name | Test badge verify backpack |
| version | 1 |
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criteria" exists:
| badge | Test badge verify backpack |
| role | editingteacher |
And the following "core_badges > Issued badge" exists:
| badge | Test badge verify backpack |
| user | student1 |
And the following "setup backpack connected" exist:
| user | externalbackpack |
| student1 | https://dc.imsglobal.org |
When I log in as "student1"
And I follow "Preferences" in the user menu
And I follow "Backpack settings"
Then I should see "Connected"
And I follow "Preferences" in the user menu
And I follow "Manage badges"
And I should see "Test badge verify backpack"
And "Add to backpack" "link" should exist
@javascript
Scenario: Add a new site backpack
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Manage backpacks" in site administration
When I press "Add a new backpack"
And I set the field "apiversion" to "2"
And I set the field "backpackweburl" to "aaa"
And I press "Save changes"
And I should see "Invalid URL"
And I set the field "backpackweburl" to "http://backpackweburl.cat"
And I press "Save changes"
And I should see "You must supply a value here"
And I set the field "backpackapiurl" to "http://backpackapiurl.cat"
And I press "Save changes"
Then I should see "http://backpackweburl.cat"
And "Delete" "icon" should exist in the "http://backpackweburl.cat" "table_row"
And "Edit settings" "icon" should exist in the "http://backpackweburl.cat" "table_row"
@javascript
Scenario: Remove a site backpack
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Manage backpacks" in site administration
When I click on "Delete" "link" in the "https://dc.imsglobal.org" "table_row"
And I should see "Delete site backpack 'https://dc.imsglobal.org'?"
And I click on "Delete" "button" in the "Delete site backpack" "dialogue"
Then I should see "The site backpack has been deleted."
And I should not see "https://dc.imsglobal.org"
And "Delete" "button" should not be visible
@javascript
Scenario: Move up and down site backpack
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Manage backpacks" in site administration
And "Move up" "icon" should exist in the "https://dc.imsglobal.org" "table_row"
And "Move down" "icon" should exist in the "https://dc.imsglobal.org" "table_row"
When I click on "Move up" "link" in the "https://dc.imsglobal.org" "table_row"
Then "Move up" "icon" should not exist in the "https://dc.imsglobal.org" "table_row"
And "Move down" "icon" should exist in the "https://dc.imsglobal.org" "table_row"
And I click on "Move down" "link" in the "https://dc.imsglobal.org" "table_row"
And I click on "Move down" "link" in the "https://dc.imsglobal.org" "table_row"
And "Move up" "icon" should exist in the "https://dc.imsglobal.org" "table_row"
And "Move down" "icon" should not exist in the "https://dc.imsglobal.org" "table_row"
@javascript
Scenario: Add a new site backpack with authentication details checkbox
Given I am on homepage
And I log in as "admin"
And I navigate to "Badges > Manage backpacks" in site administration
When I press "Add a new backpack"
And I set the field "apiversion" to "2.1"
And I set the field "backpackweburl" to "http://backpackweburl.cat"
And I should not see "Backpack API URL"
Then "Include authentication details with the backpack" "checkbox" should not be visible
And I should not see "Badge issuer email address"
And I should not see "Badge issuer password"
And I set the field "apiversion" to "1"
And "Include authentication details with the backpack" "checkbox" should be visible
And I click on "includeauthdetails" "checkbox"
And I should see "Badge issuer email address"
And I should not see "Badge issuer password"
And I set the field "apiversion" to "2"
And "Include authentication details with the backpack" "checkbox" should be visible
And I should see "Badge issuer email address"
And I should see "Badge issuer password"
And I set the field "backpackemail" to "test@test.com"
And I set the field "password" to "123456"
And I set the field "backpackapiurl" to "http://backpackapiurl.cat"
And I press "Save changes"
And I click on "Edit" "link" in the "http://backpackweburl.cat" "table_row"
And the field "Include authentication details with the backpack" matches value "1"
And I click on "includeauthdetails" "checkbox"
And I press "Save changes"
And I click on "Edit" "link" in the "http://backpackweburl.cat" "table_row"
And the field "Include authentication details with the backpack" matches value "0"
And I click on "includeauthdetails" "checkbox"
And I should not see "test@test.com"
@javascript
Scenario: View backpack form as a student
Given I log in as "student1"
And I follow "Preferences" in the user menu
And I follow "Backpack settings"
When I set the field "externalbackpackid" to "https://dc.imsglobal.org"
Then I should not see "Log in to your backpack"
And I should not see "Email address"
And I should not see "Password"
But I set the field "externalbackpackid" to "https://test.com/"
And I should see "Log in to your backpack"
And I should see "Email address"
And I should see "Password"
@javascript
Scenario: Check backpack form validation as a student
Given I log in as "student1"
And I follow "Preferences" in the user menu
And I follow "Backpack settings"
When I click on "Connect to backpack" "button"
Then I should see "Backpack provider can't be blank"
And I set the field "externalbackpackid" to "https://test.com/"
And I set the field "password" to ""
When I click on "Connect to backpack" "button"
Then I should see "Password can't be blank"
And I should not see "Email address can't be blank"
And I set the field "backpackemail" to ""
And I click on "Connect to backpack" "button"
And I should see "Email address can't be blank"
And I should see "Password can't be blank"
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

+152
View File
@@ -0,0 +1,152 @@
@core @core_badges @javascript
Feature: Test tertiary navigation as various users
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| teacher | Teacher | 1 | teacher@example.com |
| nonediting | Nonediting | 1 | nonediting@example.com |
And the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
| student1 | C1 | student |
| nonediting | C1 | teacher |
# Create a course badge in our test course.
And the following "core_badges > Badge" exists:
| name | Testing course badge |
| status | inactive |
| type | 2 |
| course | C1 |
| version | 1.1 |
| language | ca |
| description | Testing course badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
# Create a site badge.
And the following "core_badges > Badge" exists:
| name | Testing site badge |
| status | inactive |
| version | 1.1 |
| language | ca |
| description | Testing site badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
And the following "core_badges > Criterias" exist:
| badge | role |
| Testing course badge | editingteacher |
| Testing site badge | editingteacher |
Scenario Outline: Check navigation as different users in a course context
Given I log in as "<user>"
And I am on "Course 1" course homepage
When I navigate to "Badges" in current page administration
Then "Manage badges" "button" should exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
And I click on "Manage badges" "button"
And "Manage badges" "button" should not exist
And "Back" "button" should exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
And I click on "Back" "button"
And "Back" "button" should not exist
And "Manage badges" "button" should exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
And I click on "Manage badges" "button"
And I click on "Testing course badge" "link"
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And "Back" "button" should exist
And I should see "<activetab>" is active in secondary navigation
And I click on "Back" "button"
And "Back" "button" should exist
And "Manage badges" "button" should not exist
And "Add a new badge" "button" <createbutton>
And I should see "<activetab>" is active in secondary navigation
Examples:
| user | createbutton | activetab |
| admin | should exist | More |
| teacher | should exist | More |
| nonediting | should not exist | Badges |
Scenario: Check navigation as a student
Given I am on the "C1" "Course" page logged in as "student1"
And "Badges" "link" should not exist in current page administration
And I log out
# Enable one badge.
When I am on the "C1" "Course" page logged in as "admin"
And I navigate to "Badges" in current page administration
And I click on "Manage badges" "button"
And I press "Enable access" action in the "Testing course badge" report row
And I press "Continue"
And I log out
# Now student should see the Badges link.
And I am on the "C1" "Course" page logged in as "student1"
Then "Badges" "link" should exist in current page administration
And I navigate to "Badges" in current page administration
And "Back" "button" should not exist
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And I should see "Badges" is active in secondary navigation
Scenario: Check navigation as an admin in a site context
Given I log in as "admin"
When I navigate to "Badges > Manage badges" in site administration
Then "Manage badges" "button" should not exist
And "Add a new badge" "button" should exist
And I should see "General" is active in secondary navigation
And I click on "Testing site badge" "link"
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And "Back" "button" should exist
And I should see "General" is active in secondary navigation
And I click on "Back" "button"
And "Back" "button" should not exist
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should exist
Scenario Outline: Check secondary navigation highlights after tertiary nav jumps in site admin
Given I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I click on "Testing site badge" "link"
When I select "<option>" from the "jump" singleselect
Then I should see "General" is active in secondary navigation
Examples:
| option |
| Overview |
| Edit details |
| Criteria |
| Message |
| Recipients (0) |
| Endorsement |
| Related badges (0) |
| Alignments (0) |
Scenario Outline: Check secondary navigation highlights after tertiary nav jumps in course as admin
Given I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Badges" in current page administration
And I click on "Manage badges" "button"
And I click on "Testing course badge" "link"
When I select "<option>" from the "jump" singleselect
Then I should see "More" is active in secondary navigation
Examples:
| option |
| Overview |
| Edit details |
| Criteria |
| Message |
| Recipients (0) |
| Endorsement |
| Related badges (0) |
| Alignments (0) |
@@ -0,0 +1,127 @@
@mod @mod_quiz @core @core_badges @core_completion @javascript
Feature: Award badges based on activity completion
In order to ensure a student has learned the material before being marked complete
As a teacher
I need to configure an activity to grant a badge only when the student achieves a passing grade upon completion.
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category | enablecompletion |
| Course 1 | C1 | 0 | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And 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 | attempts | gradepass | completion | completionpassgrade | completionusegrade |
| quiz | Test quiz name 1 | C1 | quiz1 | 2 | 5.00 | 2 | 1 | 1 |
| quiz | Test quiz name 2 | C1 | quiz2 | 2 | 5.00 | 2 | 0 | 1 |
And quiz "Test quiz name 1" contains the following questions:
| question | page |
| First question | 1 |
And quiz "Test quiz name 2" contains the following questions:
| question | page |
| First question | 1 |
And the following "core_badges > Badge" exists:
| name | Course Badge 1 |
| status | 0 |
| type | 2 |
| course | C1 |
| description | Course badge 1 description |
| image | badges/tests/behat/badge.png |
And the following "core_badges > Badge" exists:
| name | Course Badge 2 |
| status | 0 |
| type | 2 |
| course | C1 |
| description | Course badge 2 description |
| image | badges/tests/behat/badge.png |
And I am on the "Course 1" course page logged in as teacher1
Scenario: Student does not earn a badge using activity completion when does not get passing grade
Given I navigate to "Badges" in current page administration
And I press "Manage badges"
And I follow "Course Badge 1"
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Activity completion"
And I set the field "Quiz - Test quiz name 1" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I should see "Recipients (0)"
# Pass grade for student1. Activity is considered complete because student1 got a passing grade.
And user "student1" has attempted "Test quiz name 1" with responses:
| slot | response |
| 1 | True |
# Fail grade for student2. Activity is considered incomplete because student2 got a failing grade.
And user "student2" has attempted "Test quiz name 1" with responses:
| slot | response |
| 1 | False |
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
Then I should see "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
And I should see "Student 1"
And I should not see "Student 2"
Scenario: Students with any grades in an activity will receive a badge if the completion condition is set to receive any grade
Given I navigate to "Badges" in current page administration
And I press "Manage badges"
And I follow "Course Badge 2"
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Activity completion"
And I set the field "Quiz - Test quiz name 2" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
# Pass grade for student1.
And user "student1" has attempted "Test quiz name 2" with responses:
| slot | response |
| 1 | True |
# Fail grade for student2. Activity is considered complete even if student2 got a failing grade.
And user "student2" has attempted "Test quiz name 2" with responses:
| slot | response |
| 1 | False |
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 2"
Then I should see "Recipients (2)"
And I select "Recipients (2)" from the "jump" singleselect
And I should see "Student 1"
And I should see "Student 2"
Scenario: Previously graded pass/fail students should earn a badge after enabling a badge
# Pass grade for student1.
Given user "student1" has attempted "Test quiz name 1" with responses:
| slot | response |
| 1 | True |
# Fail grade for student2.
And user "student2" has attempted "Test quiz name 1" with responses:
| slot | response |
| 1 | False |
And I navigate to "Badges" in current page administration
And I press "Manage badges"
And I follow "Course Badge 1"
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Activity completion"
And I set the field "Quiz - Test quiz name 1" to "1"
And I press "Save"
# Enable badge access once students have completed the activity.
When I press "Enable access"
And I press "Continue"
# Only student1 should earn the badge because student2 did not pass the quiz.
Then I should see "Recipients (1)"
And I select "Recipients (1)" from the "jump" singleselect
And I should see "Student 1"
And I should not see "Student 2"
+467
View File
@@ -0,0 +1,467 @@
@core @core_badges
Feature: Award badges based on cohort
In order to award badges to users based on their cohort membership
As an admin
I need to add cohort criteria to badges in the system
@javascript
Scenario: Award cohort membership badge for a member of a single cohort.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user2 | CH2 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "One Cohort"
And I press "Save"
And I press "Enable access"
When I press "Continue"
Then I should see "Recipients (1)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
@javascript
Scenario: Award cohort membership badge for a member of all required cohorts.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
| Three Cohort | CH3 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH1 |
| user2 | CH3 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I expand all fieldsets
And I set the field "id_cohort_cohorts" to "One Cohort,Two Cohort"
And I set the field "id_agg_1" to "1"
And I press "Save"
When I press "Enable access"
And I press "Continue"
Then I should see "Recipients (1)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
@javascript
Scenario: Award cohort membership badge for a member of any required cohorts.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
| Three Cohort | CH3 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH1 |
| user2 | CH3 |
| user3 | CH2 |
| user3 | CH3 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "One Cohort"
And I press "Save"
When I press "Enable access"
And I press "Continue"
Then I should see "Recipients (2)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should see "Site Badge"
@javascript
Scenario: Award badge based on a single cohort membership and other criteria.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user2 | CH2 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "One Cohort"
And I press "Save"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Manager" to "1"
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
When I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Second User (second@example.com)"
And I press "Award badge"
And I navigate to "Badges > Manage badges" in site administration
And I follow "Site Badge"
Then I should see "Recipients (1)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should not see "Site Badge"
@javascript
Scenario: Award badge based on a single cohort membership or other criteria.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | Third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user2 | CH2 |
| user3 | CH2 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "One Cohort"
And I press "Save"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Manager" to "1"
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
And I set the field "update" to "Any"
When I press "Enable access"
And I press "Continue"
And I select "Recipients (1)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Second User (second@example.com)"
And I press "Award badge"
And I navigate to "Badges > Manage badges" in site administration
And I follow "Site Badge"
Then I should see "Recipients (2)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user3"
And I follow "Profile" in the user menu
And I should not see "Site Badge"
@javascript
Scenario: Award badge based on a multiple cohort membership or other criteria.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH2 |
| user2 | CH2 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "One Cohort"
And I press "Save"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Manager" to "1"
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
And I set the field "update" to "Any"
When I press "Enable access"
And I press "Continue"
And I select "Recipients (1)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Second User (second@example.com)"
And I press "Award badge"
And I navigate to "Badges > Manage badges" in site administration
And I follow "Site Badge"
Then I should see "Recipients (2)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user3"
And I follow "Profile" in the user menu
And I should not see "Site Badge"
@javascript
Scenario: Award badge based on a multiple cohort membership and other criteria.
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | Third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH1 |
| user3 | CH2 |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I expand all fieldsets
And I set the field "id_cohort_cohorts" to "One Cohort,Two Cohort"
And I set the field "id_agg_1" to "1"
And I press "Save"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Manager" to "1"
And I set the field "Any of the selected roles awards the badge" to "1"
And I press "Save"
And I set the field "update" to "All"
When I press "Enable access"
And I press "Continue"
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "First User (first@example.com)"
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Second User (second@example.com)"
And I press "Award badge"
And I navigate to "Badges > Manage badges" in site administration
And I follow "Site Badge"
Then I should see "Recipients (1)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should not see "Site Badge"
And I log out
And I log in as "user3"
And I follow "Profile" in the user menu
And I should not see "Site Badge"
@javascript
Scenario: Award multiple badges based on single cohort membership
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | Third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH2 |
And the following "core_badges > Badges" exist:
| name | status | description | image |
| Site Badge 1 | 0 | Site badge description | badges/tests/behat/badge.png |
| Site Badge 2 | 0 | Site badge description | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "One Cohort"
And I press "Save"
And I press "Enable access"
When I press "Continue"
And I should see "Recipients (1)"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge 2" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I set the field "id_cohort_cohorts" to "Two Cohort"
And I press "Save"
And I press "Enable access"
And I press "Continue"
Then I should see "Recipients (2)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge 1"
And I should see "Site Badge 2"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should not see "Site Badge 1"
And I should see "Site Badge 2"
And I log out
And I log in as "user3"
And I follow "Profile" in the user menu
And I should not see "Site Badge 1"
And I should not see "Site Badge 2"
@javascript
Scenario: Award multiple badges based on multiple cohort memberships
Given the following "cohorts" exist:
| name | idnumber |
| One Cohort | CH1 |
| Two Cohort | CH2 |
| Three Cohort | CH3 |
And the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | Third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH2 |
| user2 | CH3 |
And the following "core_badges > Badges" exist:
| name | status | description | image |
| Site Badge 1 | 0 | Site badge description | badges/tests/behat/badge.png |
| Site Badge 2 | 0 | Site badge description | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I expand all fieldsets
And I set the field "id_cohort_cohorts" to "One Cohort,Two Cohort"
And I set the field "id_agg_1" to "1"
And I press "Save"
And I press "Enable access"
When I press "Continue"
And I should see "Recipients (1)"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge 2" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Cohort membership"
And I expand all fieldsets
And I set the field "id_cohort_cohorts" to "Three Cohort,Two Cohort"
And I set the field "id_agg_1" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I should see "Recipients (1)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge 1"
And I should not see "Site Badge 2"
And I log out
And I log in as "user2"
And I follow "Profile" in the user menu
And I should not see "Site Badge 1"
And I should see "Site Badge 2"
And I log out
And I log in as "user3"
And I follow "Profile" in the user menu
And I should not see "Site Badge 1"
And I should not see "Site Badge 2"
@@ -0,0 +1,200 @@
@core @core_badges
Feature: Award badges based on competency completion
In order to award badges to users based on competency completion
As an admin
I need to add competency completion criteria to badges in the system
Background: Setup the competency framework and the course
Given the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| user1 | C1 | student |
And the following lp "frameworks" exist:
| shortname | idnumber |
| Framework 1 | sc-y-2 |
And the following lp "competencies" exist:
| shortname | framework |
| comp1 | sc-y-2 |
| comp2 | sc-y-2 |
And I log in as "admin"
@javascript
Scenario: Award badge for completing a competency in a course
Given the following "core_badges > Badge" exists:
| name | Course Badge |
| status | 0 |
| type | 2 |
| course | C1 |
| description | Course badge description |
| image | badges/tests/behat/badge.png |
# Add a competency to the course
When I am on "Course 1" course homepage
And I navigate to "Competencies > Add competencies to course" in current page administration
And "Competency picker" "dialogue" should be visible
And I select "comp1" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I wait until the page is ready
And I click on "Edit" "link" in the "[data-region='configurecoursecompetencies']" "css_element"
And I wait until the page is ready
And I click on "Rating a competency only updates the competency in this course" "text"
And I click on "Save changes" "button" in the "Configure course competencies" "dialogue"
# Add a badge to the course
And I am on "Course 1" course homepage
And I change window size to "large"
And I navigate to "Badges" in current page administration
And I press "Manage badges"
And I follow "Course Badge"
And I select "Criteria" from the "jump" singleselect
# Set the competency as a criteria for the badge
And I set the field "type" to "Competencies"
When I open the autocomplete suggestions list
And I click on "ul[class='form-autocomplete-suggestions'] li" "css_element"
And I wait until the page is ready
And I press "Save"
And I wait until the page is ready
# Enable the badge
And I press "Enable access"
And I press "Continue"
# Rate the competency in the course
And I am on "Course 1" course homepage
And I navigate to "Competencies" in current page administration
And I click on "comp1" "link" in the "[data-region='coursecompetencies']" "css_element"
And I press "Rate"
And I set the following fields to these values:
| Rating | C |
And I click on "Rate" "button" in the "Rate" "dialogue"
And I should see "The competency rating was manually set in the course"
And I log out
# See if we got the badge
Then I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Course Badge"
@javascript
Scenario: Award badge for completing a competency in the site
Given the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
# Add a competency to the course
When I am on "Course 1" course homepage
And I navigate to "Competencies > Add competencies to course" in current page administration
And "Competency picker" "dialogue" should be visible
And I select "comp1" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I press "Add competencies to course"
And "Competency picker" "dialogue" should be visible
And I select "comp2" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
# Add a badge to the site
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
# Set the competency as a criteria for the badge
And I set the field "type" to "Competencies"
And I press "Add competency"
And "Competency picker" "dialogue" should be visible
And I select "comp1" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I wait until the page is ready
And I press "Add competency"
And "Competency picker" "dialogue" should be visible
And I select "comp2" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I wait until the page is ready
And I press "Save"
# Enable the badge
And I wait until the page is ready
And I press "Enable access"
And I press "Continue"
# Rate the competency in the course
And I am on "Course 1" course homepage
And I navigate to "Competencies" in current page administration
And I click on "comp1" "link" in the "[data-region='coursecompetencies']" "css_element"
And I press "Rate"
And I set the following fields to these values:
| Rating | C |
And I click on "Rate" "button" in the "Rate" "dialogue"
And I should see "The competency rating was manually set in the course"
And I log out
# See if we got the badge
Then I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
@javascript
Scenario: Award badge for completing all competencies in the site
Given the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
# Add a competency to the course
When I am on "Course 1" course homepage
And I navigate to "Competencies > Add competencies to course" in current page administration
And "Competency picker" "dialogue" should be visible
And I select "comp1" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I press "Add competencies to course"
And "Competency picker" "dialogue" should be visible
And I select "comp2" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
# Add a badge to the site
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
# Set the competency as a criteria for the badge
And I set the field "type" to "Competencies"
And I press "Add competency"
And "Competency picker" "dialogue" should be visible
And I select "comp1" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I wait until the page is ready
And I press "Add competency"
And "Competency picker" "dialogue" should be visible
And I select "comp2" of the competency tree
And I click on "Add" "button" in the "Competency picker" "dialogue"
And I wait until the page is ready
And I click on "This criterion is complete when" "link"
And I click on "All of the selected competencies have been completed" "radio"
And I press "Save"
# Enable the badge
And I wait until the page is ready
And I press "Enable access"
And I press "Continue"
# Rate the competency in the course
And I am on "Course 1" course homepage
And I navigate to "Competencies" in current page administration
And I click on "comp1" "link" in the "[data-region='coursecompetencies']" "css_element"
And I press "Rate"
And I set the following fields to these values:
| Rating | C |
And I click on "Rate" "button" in the "Rate" "dialogue"
And I should see "The competency rating was manually set in the course"
And I log out
# We should not get the badge yet.
Then I log in as "user1"
And I follow "Profile" in the user menu
And I should not see "Site Badge"
And I log out
# Rate the other competency.
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Competencies" in current page administration
And I click on "comp2" "link" in the "[data-region='coursecompetencies']" "css_element"
And I press "Rate"
And I set the following fields to these values:
| Rating | C |
And I click on "Rate" "button" in the "Rate" "dialogue"
And I should see "The competency rating was manually set in the course"
And I log out
# See if we got the badge now.
Then I log in as "user1"
And I follow "Profile" in the user menu
And I should see "Site Badge"
@@ -0,0 +1,32 @@
@core @core_badges @_file_upload
Feature: Award badges based on user profile field
In order to award badges to users based on completion of their user profile
As an admin
I need to add profile completion criteria to badges in the system
@javascript
Scenario: Award badge for a uploading a profile picture.
Given the following "users" exist:
| username | firstname | lastname | email |
| user1 | First | User | first@example.com |
And the following "core_badges > Badge" exists:
| name | Site Badge |
| status | 0 |
| description | Site badge description |
| image | badges/tests/behat/badge.png |
And I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Site Badge" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Profile completion"
And I set the field "id_field_picture" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I log out
When I log in as "user1"
And I follow "Profile" in the user menu
And I click on "Edit profile" "link" in the "region-main" "region"
And I upload "badges/tests/behat/badge.png" file to "New picture" filemanager
And I press "Update profile"
Then I should see "Site Badge"
@@ -0,0 +1,51 @@
@core @core_badges
Feature: Delete course badge already awarded
As a teacher
I can delete awarded course badge
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
@javascript
Scenario Outline: Delete course badge already awarded to student
Given the following "core_badges > Badges" exist:
| name | course | description | image | status | type |
| <badgename> | C1 | <badgename> description | badges/tests/behat/badge.png | active | 2 |
And the following "core_badges > Criterias" exist:
| badge | role |
| <badgename> | editingteacher |
And the following "core_badges > Issued badges" exist:
| badge | user |
| <badgename> | student1 |
When I am on the "Course 1" "enrolled users" page logged in as "teacher1"
And I click on "Student 1" "link"
Then I should see "<badgename>"
And I am on the "Course 1" course page
# Navigate to Manage Badges page in order to delete the badge
And I navigate to "Badges > Manage badges" in current page administration
# Delete the badge
And I press "Delete" action in the "<badgename>" report row
And I press "<deleteoption>"
And I am on the "Course 1" "enrolled users" page
And I click on "Student 1" "link"
# Confirm that Badge 1 is retained as awarded badge but Badge 2 is not
And I <visibility> see "<badgename>"
And I am on the "Course 1" course page
# Navigate to Badges page to confirm that no badges exist, hence, Manage badges would not exist
And I navigate to "Badges" in current page administration
# Confirm that badges are sucessfully deleted
And I should see "There are no matching badges available for users to earn"
Examples:
| badgename | deleteoption | visibility |
| Badge 1 | Delete and keep existing issued badges | should |
| Badge 2 | Delete and remove existing issued badges | should not |
+117
View File
@@ -0,0 +1,117 @@
@core @core_badges @javascript
Feature: Manage badges
In order to manage badges in the system
As an admin
I need to be able to edit, copy, enable/disable access, delete and award badges
Background:
Given the following "core_badges > Badge" exists:
| name | Badge #1 |
| status | 0 |
| version | 1.0 |
| language | en |
| description | Test badge description |
| image | badges/tests/behat/badge.png |
| imageauthorurl | http://author.example.com |
| imagecaption | Test caption image |
Scenario: Copy a badge
Given I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Copy" action in the "Badge #1" report row
And I should see "Copy of Badge #1"
And I press "Save changes"
And I click on "Back" "button"
Then the following should exist in the "reportbuilder-table" table:
| Name | Version | Badge status |
| Badge #1 | 1.0 | Not available |
| Copy of Badge #1 | 1.0 | Not available |
Scenario: Edit a badge
Given I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Badge #1" report row
And I set the following fields to these values:
| Name | New Badge #1 |
| Version | 1.1 |
And I press "Save changes"
And I click on "Back" "button"
Then the following should exist in the "reportbuilder-table" table:
| Name | Version | Badge status |
| New Badge #1 | 1.1 | Not available |
Scenario: Delete a badge
Given I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Delete" action in the "Badge #1" report row
And I press "Delete and remove existing issued badges"
Then I should see "There are no matching badges available for users to earn"
Scenario Outline: Filter managed badges
Given the following "core_badges > Badges" exist:
| name | status | version | image |
| Badge #2 | 1 | 2.0 | badges/tests/behat/badge.png |
And I log in as "admin"
When I navigate to "Badges > Manage badges" in site administration
And I click on "Filters" "button"
And I set the following fields in the "<filter>" "core_reportbuilder > Filter" to these values:
| <filter> operator | Is equal to |
| <filter> value | <value> |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
Then I should see "Filters applied"
And I should see "Badge #1" in the "Badges" "table"
And I should not see "Badge #2" in the "Badges" "table"
Examples:
| filter | value |
| Name | Badge #1 |
| Version | 1.0 |
| Badge status | Not available |
Scenario: Enable and disable access to a badge
Given I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Badge #1" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Manual issue by role"
And I set the field "Manager" to "1"
And I press "Save"
And I navigate to "Badges > Manage badges" in site administration
And I press "Enable access" action in the "Badge #1" report row
And I should see "Changes in badge access"
And I press "Continue"
And I should see "Access to the badges was successfully enabled"
Then the following should exist in the "reportbuilder-table" table:
| Name | Badge status |
| Badge #1 | Available |
And I press "Disable access" action in the "Badge #1" report row
And I should see "Access to the badges was successfully disabled"
And the following should exist in the "reportbuilder-table" table:
| Name | Badge status |
| Badge #1 | Not available |
Scenario: Award a badge
Given the following "users" exist:
| username | firstname | lastname | email |
| user1 | User | One | user1@example.com |
When I log in as "admin"
And I navigate to "Badges > Manage badges" in site administration
And I press "Edit" action in the "Badge #1" report row
And I select "Criteria" from the "jump" singleselect
And I set the field "type" to "Manual issue by role"
And I set the field "Manager" to "1"
And I press "Save"
And I navigate to "Badges > Manage badges" in site administration
And I press "Enable access" action in the "Badge #1" report row
And I press "Continue"
And I press "Award badge" action in the "Badge #1" report row
And I set the field "potentialrecipients[]" to "Admin User (moodle@example.com),User One (user1@example.com)"
And I press "Award badge"
And I navigate to "Badges > Manage badges" in site administration
Then the following should exist in the "Badges" table:
| Name | Badge status | Recipients |
| Badge #1 | Available | 2 |
And I click on "2" "link" in the "Badge #1" "table_row"
And the following should exist in the "Recipients" table:
| -1- |
| Admin User |
| User One |
@@ -0,0 +1,105 @@
@core @core_badges @_file_upload @javascript
Feature: Manage badges is not shown when there are no existing badges.
Scenario: Check navigation at site level with no badges
Given I log in as "admin"
When I navigate to "Badges > Manage badges" in site administration
And I should see "There are no matching badges available for users to earn"
Then "Manage badges" "button" should not exist
Scenario: Check navigation at course level with no badges
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher | Teacher | 1 | teacher@example.com |
And the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And I log in as "teacher"
And I am on "Course 1" course homepage
When I navigate to "Badges" in current page administration
Then "Manage badges" "button" should not exist
And I click on "Add a new badge" "button"
And I set the following fields to these values:
| Name | Testing course badge |
| Version | 1.1 |
| Language | Basque |
| Description | Testing course badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I click on "Create badge" "button"
And I click on "Back" "button"
And I should see "Testing course badge"
And I click on "Back" "button"
And "Manage badges" "button" should exist
# Badge is not enabled so is not listed.
And I should not see "Testing course badge"
And I click on "Manage badges" "button"
And I press "Edit" action in the "Testing course badge" report row
And I click on "Add criteria" "button"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Teacher" to "1"
And I click on "Save" "button"
And I click on "Back" "button"
And I should see "Testing course badge"
And I click on "Back" "button"
And "Manage badges" "button" should exist
# Badge is not enabled yet so is not listed.
And I should not see "Testing course badge"
And I click on "Manage badges" "button"
And I press "Enable access" action in the "Testing course badge" report row
And I click on "Continue" "button"
And I should see "Testing course badge"
And I click on "Back" "button"
And "Manage badges" "button" should exist
# Badge is already enabled so is listed.
And I should see "Testing course badge"
Scenario: Check navigation at course level with no badges as a student
# Create a badge, but leave it not enabled for now.
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname | format | enablecompletion |
| Course 1 | C1 | topics | 1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
And I am on the "C1" "Course" page logged in as "admin"
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Testing course badge |
| Version | 1.0 |
| Language | Catalan |
| Description | Testing course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Teacher" to "1"
And I press "Save"
And I log out
When I am on the "C1" "Course" page logged in as "student1"
Then "Badges" "link" should not exist in current page administration
And I log out
# Enable the badge.
And I am on the "C1" "Course" page logged in as "admin"
And I navigate to "Badges" in current page administration
And I click on "Manage badges" "button"
And I press "Enable access" action in the "Testing course badge" report row
And I press "Continue"
And I log out
# Now student should see the Badges link.
And I am on the "C1" "Course" page logged in as "student1"
And I follow "Badges"
And "Manage badges" "button" should not exist
And "Add a new badge" "button" should not exist
And I should not see "There are no matching badges available for users to earn"
And the following should exist in the "Course badges" table:
| Name | Description | Criteria |
| Testing course badge | Testing course badge description | Awarded by: Teacher |
@@ -0,0 +1,47 @@
@core @core_badges
Feature: Test role visibility for the badge administration page
In order to control access
As an admin
I need to control which roles can see each other
Background: Add a bunch of users
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| manager1 | Manager | 1 | manager1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| manager1 | C1 | manager |
@javascript @_file_upload
Scenario: Check the default roles are visible
Given I log in as "manager1"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
Then I should see "Teacher"
And I should see "Manager"
@javascript @_file_upload
Scenario: Check hidden roles are not visible
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
And I set the following fields to these values:
| Name | Course Badge |
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the following fields to these values:
| Add badge criteria | Manual issue by role |
Then I should see "Teacher"
And I should not see "Manager"
+141
View File
@@ -0,0 +1,141 @@
@core @core_badges @_file_upload @javascript
Feature: Display badges
In order to access to badges information
As a user
I need to view badges data awarded to users
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
# Create system badge and define a criterion.
And I log in as "admin"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Testing system badge |
| Version | 1.1 |
| Language | Catalan |
| Description | Testing system badge description |
| Image author | http://author.example.com |
| Image caption | Test caption image |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
And I set the field "type" to "Manual issue by role"
And I expand all fieldsets
And I set the field "Teacher" to "1"
And I press "Save"
Scenario: Display badge without expired date
# Enable the badge.
Given I press "Enable access"
And I press "Continue"
# Award badge to student1.
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
# Check badge details are displayed.
And I navigate to "Badges > Manage badges" in site administration
And I follow "Testing system badge"
And I select "Recipients (1)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
Then I should see "Awarded to Student 1"
And I should see "This badge has to be awarded by a user with the following role:"
And I should not see "Expired"
And I should not see "Expires"
And I follow "More details"
And I should see "Catalan"
And I should see "1.1"
Scenario: Display badge with ALL criteria
# Add another criterion and enable the badge.
Given I set the field "type" to "Profile completion"
And I set the field "id_field_firstname" to "1"
And I press "Save"
And I press "Enable access"
And I press "Continue"
# Award badge to student1.
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
# Check badge details are displayed.
And I navigate to "Badges > Manage badges" in site administration
And I follow "Testing system badge"
And I select "Recipients (1)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
Then I should see "Awarded to Student 1"
And I should see "Complete ALL of the listed requirements."
And I should see "This badge has to be awarded by a user with the following role:"
And I should see "The following user profile field has to be completed:"
And I should not see "Expired"
And I should not see "Expires"
And I follow "More details"
And I should see "Catalan"
And I should see "1.1"
Scenario: Display badge with ANY criteria
# Add another criterion and enable the badge.
Given I set the field "type" to "Profile completion"
And I set the field "id_field_firstname" to "1"
And I press "Save"
And I set the field "update" to "2"
And I press "Enable access"
And I press "Continue"
# Check badge details are displayed.
And I select "Recipients (2)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
Then I should see "Awarded to Student 1"
And I should see "Complete ANY of the listed requirements."
And I should see "This badge has to be awarded by a user with the following role:"
And I should see "The following user profile field has to be completed:"
And I should not see "Expired"
And I should not see "Expires"
And I follow "More details"
And I should see "Catalan"
And I should see "1.1"
Scenario: Display badge with expiration date but not expired yet
# Set expired date to badge (future date).
Given I select "Edit details" from the "jump" singleselect
When I click on "Relative date" "radio"
And I set the field "expireperiod[number]" to "1"
And I press "Save changes"
And I press "Enable access"
And I press "Continue"
# Award badge to student1.
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
# Check "Expires" date is displayed.
And I navigate to "Badges > Manage badges" in site administration
And I follow "Testing system badge"
And I select "Recipients (1)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
Then I should see "Expires"
And I should not see "Expired"
Scenario: Display expired badge
# Set expired date to badge (relative date 1 seconds after the date of issue it).
Given I select "Edit details" from the "jump" singleselect
When I click on "Relative date" "radio"
And I set the field "expireperiod[timeunit]" to "1"
And I set the field "expireperiod[number]" to "1"
And I press "Save changes"
And I press "Enable access"
And I press "Continue"
# Award badge to student1.
And I select "Recipients (0)" from the "jump" singleselect
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
And I press "Award badge"
# Wait 1 second to guarantee the badge is expired.
And I wait "1" seconds
# Check "Expired" date is displayed.
And I navigate to "Badges > Manage badges" in site administration
And I follow "Testing system badge"
And I select "Recipients (1)" from the "jump" singleselect
And I press "View issued badge" action in the "Student 1" report row
Then I should see "Expired"
And I should not see "Expires"