+
+{{^competencies}}
+ {{#str}}nocompetencies, core_badges{{/str}}
+{{/competencies}}
+
+{{#js}}
+require(['tool_lp/competencydialogue'], function(Compdialogue) {
+ Compdialogue.init();
+});
+{{/js}}
diff --git a/badges/tests/behat/add_badge.feature b/badges/tests/behat/add_badge.feature
index 235fdd0bfd374..c54b693655014 100644
--- a/badges/tests/behat/add_badge.feature
+++ b/badges/tests/behat/add_badge.feature
@@ -46,7 +46,7 @@ Feature: Add badges to the system
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 "External alignments (0)"
+ And I should see "Alignments (0)"
And I should not see "Create badge"
And I follow "Manage badges"
And I should see "Number of badges available: 1"
@@ -118,7 +118,7 @@ Feature: Add badges to the system
Then I should see "Changes saved"
@javascript @_file_upload
- Scenario: External alignments for Badge
+ 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 |
@@ -133,15 +133,15 @@ Feature: Add badges to the system
When I press "Create badge"
Then I should see "Test Badge"
And I should see "Endorsement"
- And I follow "External alignments (0)"
- And I should see "This badge does not have any external alignments specified."
- And I press "Add external alignment"
+ And I follow "Alignments (0)"
+ 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:
- | External alignment name | Test Badge Alignments |
+ | Name | Test Badge Alignments |
| URL | https://alignments.example.com |
| Description | Test Badge Alignments description |
When I press "Save changes"
- And I should see "External alignments (1)"
+ And I should see "Alignments (1)"
@javascript @_file_upload
Scenario: Add a badge from Site badges section
@@ -169,7 +169,7 @@ Feature: Add badges to the system
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 "Competencies (0)"
+ And I should see "Alignments (0)"
And I should not see "Create badge"
And I follow "Manage badges"
And I should see "Number of badges available: 1"
diff --git a/badges/tests/behat/criteria_competency.feature b/badges/tests/behat/criteria_competency.feature
new file mode 100644
index 0000000000000..17b4eb230eca9
--- /dev/null
+++ b/badges/tests/behat/criteria_competency.feature
@@ -0,0 +1,119 @@
+@core @core_badges @_file_upload
+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 |
+ And I log in as "admin"
+
+ @javascript
+ Scenario: Award badge for completing a competency in a course
+ # Add a competency to the course
+ When I am on "Course 1" course homepage
+ And I follow "Competencies"
+ And I press "Add competencies to course"
+ 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 click on "Edit" "link" in the "[data-region='configurecoursecompetencies']" "css_element"
+ 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 navigate to "Badges > Add a new badge" in current page administration
+ And I follow "Add a new badge"
+ And I set the following fields to these values:
+ | Name | Course Badge |
+ | Description | Course badge description |
+ | issuername | Tester of course badge |
+ And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
+ And I press "Create badge"
+ # 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 "1" seconds
+ And I wait until the page is ready
+ And I press "Save"
+ # And I wait "1" seconds
+ 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 follow "Competencies"
+ 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 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
+ # Add a competency to the course
+ When I am on "Course 1" course homepage
+ And I follow "Competencies"
+ And I press "Add competencies to course"
+ 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"
+ # Add a badge to the site
+ 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 |
+ | issuername | Tester of site badge |
+ And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
+ And I press "Create badge"
+ # 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 "1" seconds
+ And I wait until the page is ready
+ And I press "Save"
+ # Enable the badge
+ # And I wait "1" seconds
+ 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 follow "Competencies"
+ 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 wait until the page is ready
+ And I click on "Rate" "button" in the "Rate" "dialogue"
+ 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"
diff --git a/lang/en/badges.php b/lang/en/badges.php
index 435c7c8190dd8..a959a438f4e71 100644
--- a/lang/en/badges.php
+++ b/lang/en/badges.php
@@ -27,9 +27,11 @@
$string['actions'] = 'Actions';
$string['activate'] = 'Enable access';
$string['activatesuccess'] = 'Access to the badges was successfully enabled.';
-$string['addalignment'] = 'Add competency';
+$string['addalignment'] = 'Add external skill or standard';
$string['addbadge'] = 'Add badges';
$string['addbadge_help'] = 'Select all badges that should be added to this badge requirement. Hold CTRL key to select multiple items.';
+$string['addcompetency'] = 'Add competency';
+$string['addcompetency_help'] = 'Select all competencies that should be added to this badge requirement. Hold CTRL key to select multiple items.';
$string['addbadgecriteria'] = 'Add badge criteria';
$string['addcriteria'] = 'Add criteria';
$string['addcriteriatext'] = 'To start adding criteria, please select one of the options from the drop-down menu.';
@@ -42,12 +44,13 @@
$string['adminonly'] = 'This page is restricted to site administrators only.';
$string['after'] = 'after the date of issue.';
$string['aggregationmethod'] = 'Aggregation method';
-$string['alignment'] = 'Competency';
+$string['alignment'] = 'Alignment';
$string['all'] = 'All';
$string['allmethod'] = 'All of the selected conditions are met';
$string['allmethodactivity'] = 'All of the selected activities are complete';
$string['allmethodbadges'] = 'All of the selected badges have been earned';
$string['allmethodcohort'] = 'Membership in all the selected cohorts';
+$string['allmethodcompetencies'] = 'All of the selected competencies have been completed';
$string['allmethodcourseset'] = 'All of the selected courses are complete';
$string['allmethodmanual'] = 'All of the selected roles award the badge';
$string['allmethodprofile'] = 'All of the selected profile fields have been completed';
@@ -62,6 +65,7 @@
$string['anymethodactivity'] = 'Any of the selected activities is complete';
$string['anymethodbadges'] = 'Any of the selected badges have been earned';
$string['anymethodcohort'] = 'Membership in any of the selected cohorts';
+$string['anymethodcompetencies'] = 'Any of the selected competencies have been completed';
$string['anymethodcourseset'] = 'Any of the selected courses is complete';
$string['anymethodmanual'] = 'Any of the selected roles awards the badge';
$string['anymethodprofile'] = 'Any of the selected profile fields has been completed';
@@ -157,7 +161,7 @@
$string['bmessage'] = 'Message';
$string['boverview'] = 'Overview';
$string['brelated'] = 'Related badges ({$a})';
-$string['balignment'] = 'Competencies ({$a})';
+$string['balignment'] = 'Alignments ({$a})';
$string['bydate'] = ' complete by';
$string['imagecaption'] = 'Image caption';
$string['imagecaption_help'] = 'If specified, an image caption is displayed on the badge page.';
@@ -197,6 +201,7 @@
$string['criteria_descr_short6'] = 'Complete