Skip to content

Commit

Permalink
MDL-68746 core_badges: remove Issuer details from badges form
Browse files Browse the repository at this point in the history
When OBv2.0 support was added, the issuername and issuercontact
fields were changed to static.
In order to avoid confusion for the user, these fields shouldn't
be displayed for OBv2.0 or higher.
  • Loading branch information
sarjona committed May 20, 2020
1 parent 1afe68f commit 630a19e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
22 changes: 4 additions & 18 deletions badges/classes/form/badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ public function definition() {
$mform->setType('imagecaption', PARAM_TEXT);
$mform->addHelpButton('imagecaption', 'imagecaption', 'badges');

$mform->addElement('header', 'issuerdetails', get_string('issuerdetails', 'badges'));

if (badges_open_badges_backpack_api() != OPEN_BADGES_V2) {
if (badges_open_badges_backpack_api() == OPEN_BADGES_V1) {
$mform->addElement('header', 'issuerdetails', get_string('issuerdetails', 'badges'));

$mform->addElement('text', 'issuername', get_string('name'), array('size' => '70'));
$mform->setType('issuername', PARAM_NOTAGS);
$mform->addRule('issuername', null, 'required');
Expand All @@ -115,21 +116,6 @@ public function definition() {
$url = parse_url($CFG->wwwroot);
$mform->addElement('hidden', 'issuerurl', $url['scheme'] . '://' . $url['host']);
$mform->setType('issuerurl', PARAM_URL);

} else {
$name = $CFG->badges_defaultissuername;
$mform->addElement('static', 'issuernamelabel', get_string('name'), $name);
$mform->addElement('hidden', 'issuername', $name);
$mform->setType('issuername', PARAM_NOTAGS);

$contact = $CFG->badges_defaultissuercontact;
$mform->addElement('static', 'issuercontactlabel', get_string('contact', 'badges'), $contact);
$mform->addElement('hidden', 'issuercontact', $contact);
$mform->setType('issuercontact', PARAM_RAW);

$url = parse_url($CFG->wwwroot);
$mform->addElement('hidden', 'issuerurl', $url['scheme'] . '://' . $url['host']);
$mform->setType('issuerurl', PARAM_URL);
}

$mform->addElement('header', 'issuancedetails', get_string('issuancedetails', 'badges'));
Expand Down Expand Up @@ -212,7 +198,7 @@ public function validation($data, $files) {
global $DB;
$errors = parent::validation($data, $files);

if (badges_open_badges_backpack_api() != OPEN_BADGES_V2) {
if (badges_open_badges_backpack_api() == OPEN_BADGES_V1) {
if (!empty($data['issuercontact']) && !validate_email($data['issuercontact'])) {
$errors['issuercontact'] = get_string('invalidemail');
}
Expand Down
2 changes: 1 addition & 1 deletion badges/newbadge.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
$fordb->usercreated = $USER->id;
$fordb->usermodified = $USER->id;

if (badges_open_badges_backpack_api() != OPEN_BADGES_V2) {
if (badges_open_badges_backpack_api() == OPEN_BADGES_V1) {
$fordb->issuername = $data->issuername;
$fordb->issuerurl = $data->issuerurl;
$fordb->issuercontact = $data->issuercontact;
Expand Down
23 changes: 10 additions & 13 deletions badges/tests/behat/add_badge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ Feature: Add badges to the system
Given I am on homepage
And I log in as "admin"

@javascript
Scenario: Setting badges settings
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 "[email protected]"
And I press "Save changes"
And I follow "Badges"
When I follow "Add a new badge"
And I press "Issuer details"
Then I should see "[email protected]"
And I should see "Test Badge Site"

@javascript
Scenario: Accessing the badges
And I press "Customise this page"
Expand All @@ -31,7 +19,11 @@ Feature: Add badges to the system

@javascript @_file_upload
Scenario: Add a badge
Given I navigate to "Badges > Add a new badge" in site administration
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 "[email protected]"
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 |
Expand All @@ -47,6 +39,11 @@ Feature: Add badges to the system
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 follow "Overview"
And I should see "Issuer details"
And I should see "Test Badge Site"
And I should see "[email protected]"
And I follow "Manage badges"
And I should see "Number of badges available: 1"
And I should not see "There are no badges available."
Expand Down

0 comments on commit 630a19e

Please sign in to comment.