award_badge.feature 4.36 KB
Newer Older
1
@core @core_badges @_only_local
2
3
4
5
6
7
8
9
10
11
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 I am on homepage
    And I log in as "admin"

  @javascript
12
  Scenario: Award profile badge
13
14
15
16
    Given I expand "Site administration" node
    And I expand "Badges" node
    And I follow "Add a new badge"
    And I fill the moodle form with:
17
      | Name | Profile Badge |
18
19
20
21
22
23
24
25
      | Description | Test badge description |
      | issuername | Test Badge Site |
      | issuercontact | testuser@test-badge-site.com |
    And I upload "badges/tests/behat/badge.png" file to "Image" filepicker
    And I press "Create badge"
    And I select "Profile completion" from "type"
    And I check "First name"
    And I check "Email address"
26
    And I check "Phone"
27
28
29
30
31
    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 not see "Criteria for this badge have not been set up yet."
32
33
34
35
36
37
38
39
40
41
    And I press "Enable access"
    And I press "Continue"
    And I expand "My profile settings" node
    And I follow "Edit profile"
    And I expand all fieldsets
    And I fill in "Phone" with "123456789"
    And I press "Update profile"
    And I follow "My badges"
    Then I should see "Profile Badge"
    And I should not see "There are no badges available."
42
43

  @javascript
44
45
46
47
48
49
  Scenario: Award site badge
    Given the following "users" exists:
      | username | firstname | lastname | email |
      | teacher | teacher | 1 | teacher1@asd.com |
      | student | student | 1 | student1@asd.com |
    And I expand "Site administration" node
50
51
52
    And I expand "Badges" node
    And I follow "Add a new badge"
    And I fill the moodle form with:
53
54
55
      | Name | Site Badge |
      | Description | Site badge description |
      | issuername | Tester of site badge |
56
57
    And I upload "badges/tests/behat/badge.png" file to "Image" filepicker
    And I press "Create badge"
58
59
    And I select "Manual issue by role" from "type"
    And I check "Teacher"
60
61
62
    And I press "Save"
    And I press "Enable access"
    And I press "Continue"
63
64
65
66
67
68
69
70
71
72
73
74
75
    And I follow "Recipients (0)"
    And I press "Award badge"
    And I select "teacher 1 (teacher1@asd.com)" from "potentialrecipients[]"
    And I press "Award badge"
    And I select "student 1 (student1@asd.com)" from "potentialrecipients[]"
    And I press "Award badge"
    When I follow "Site Badge"
    Then I should see "Recipients (2)"
    And I log out
    And I log in as "student"
    And I expand "My profile" node
    And I follow "My badges"
    Then I should see "Site Badge"
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

  @javascript
  Scenario: Award course badge
    Given the following "users" exists:
      | username | firstname | lastname | email |
      | teacher1 | Teacher | 1 | teacher1@asd.com |
      | student1 | Student | 1 | student1@asd.com |
      | student2 | Student | 2 | student2@asd.com |
    And the following "courses" exists:
      | fullname | shortname | category | groupmode |
      | Course 1 | C1 | 0 | 1 |
    And the following "course enrolments" exists:
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
      | student2 | C1 | student |
    And I log out
    And I log in as "teacher1"
    And I follow "Course 1"
    And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
    And I follow "Add a new badge"
    And I fill the moodle form with:
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
    And I upload "badges/tests/behat/badge.png" file to "Image" filepicker
    And I press "Create badge"
    And I select "Manual issue by role" from "type"
    And I check "Teacher"
    And I press "Save"
    And I press "Enable access"
    And I press "Continue"
    And I follow "Recipients (0)"
    And I press "Award badge"
    And I select "Student 2 (student2@asd.com)" from "potentialrecipients[]"
    And I press "Award badge"
    And I select "Student 1 (student1@asd.com)" from "potentialrecipients[]"
    When I press "Award badge"
    And I follow "Course Badge"
    Then I should see "Recipients (2)"
    And I log out
    And I log in as "student1"
    And I follow "Course 1"
    And I expand "My profile" node
    And I follow "My badges"
    Then I should see "Course Badge"