mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-62631 badges: Add manage/add badges buttons on Badges page
Direct access from the navigation Badges section to the "Manage badges" and "Add a new badge" buttons.
This commit is contained in:
parent
07203d34f1
commit
22348a3b96
@ -145,3 +145,41 @@ Feature: Add badges to the system
|
||||
| Description | Test Badge Competencies description |
|
||||
When I press "Save changes"
|
||||
And I should see "Competencies (1)"
|
||||
|
||||
@javascript @_file_upload
|
||||
Scenario: Add a badge from Site badges section
|
||||
Given I press "Customise this page"
|
||||
# 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 "Manage badges"
|
||||
And 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 |
|
||||
| issuername | Test Badge Site |
|
||||
| issuercontact | testuser@example.com |
|
||||
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 "Competencies (0)"
|
||||
And I should not see "Create badge"
|
||||
And I follow "Manage badges"
|
||||
And I should see "Number of badges available: 1"
|
||||
And I should not see "There are no badges available."
|
||||
# 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"
|
||||
|
@ -69,6 +69,31 @@ Feature: Award badges
|
||||
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 follow "Badges"
|
||||
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 press "Customise this page"
|
||||
# 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 badges available."
|
||||
And I should not see "Manage badges"
|
||||
And I should not see "Add a new badge"
|
||||
|
||||
@javascript
|
||||
Scenario: Award profile badge
|
||||
|
@ -106,6 +106,32 @@ if ($totalcount) {
|
||||
} else {
|
||||
echo $output->notification(get_string('nobadges', 'badges'));
|
||||
}
|
||||
|
||||
// Display "Manage badges" button to users with proper capabilities.
|
||||
$isfrontpage = (empty($courseid) || $courseid == $SITE->id);
|
||||
if ($isfrontpage) {
|
||||
$context = context_system::instance();
|
||||
} else {
|
||||
$context = context_course::instance($courseid);
|
||||
}
|
||||
$canmanage = has_any_capability(array('moodle/badges:viewawarded',
|
||||
'moodle/badges:createbadge',
|
||||
'moodle/badges:awardbadge',
|
||||
'moodle/badges:configurecriteria',
|
||||
'moodle/badges:configuremessages',
|
||||
'moodle/badges:configuredetails',
|
||||
'moodle/badges:deletebadge'), $context);
|
||||
if ($canmanage) {
|
||||
echo $output->single_button(new moodle_url('/badges/index.php', array('type' => $type, 'id' => $courseid)),
|
||||
get_string('managebadges', 'badges'));
|
||||
}
|
||||
|
||||
// Display "Add new badge" button to users with capability to create badges.
|
||||
if (has_capability('moodle/badges:createbadge', $PAGE->context)) {
|
||||
echo $output->single_button(new moodle_url('newbadge.php', array('type' => $type, 'id' => $courseid)),
|
||||
get_string('newbadge', 'badges'));
|
||||
}
|
||||
|
||||
// Trigger event, badge listing viewed.
|
||||
$eventparams = array('context' => $PAGE->context, 'other' => $eventotherparams);
|
||||
$event = \core\event\badge_listing_viewed::create($eventparams);
|
||||
|
Loading…
x
Reference in New Issue
Block a user