diff --git a/badges/classes/form/badge.php b/badges/classes/form/badge.php index faa64a651e9..523403bf9f9 100644 --- a/badges/classes/form/badge.php +++ b/badges/classes/form/badge.php @@ -93,9 +93,10 @@ class badge extends moodleform { $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'); @@ -115,21 +116,6 @@ class badge extends moodleform { $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')); @@ -212,7 +198,7 @@ class badge extends moodleform { 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'); } diff --git a/badges/newbadge.php b/badges/newbadge.php index 9087b2d85b7..07785f3efd0 100644 --- a/badges/newbadge.php +++ b/badges/newbadge.php @@ -87,7 +87,7 @@ if ($form->is_cancelled()) { $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; diff --git a/badges/tests/behat/add_badge.feature b/badges/tests/behat/add_badge.feature index 81ecdb70591..09db662b26e 100644 --- a/badges/tests/behat/add_badge.feature +++ b/badges/tests/behat/add_badge.feature @@ -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 "testuser@example.com" - 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 "testuser@example.com" - And I should see "Test Badge Site" - @javascript Scenario: Accessing the badges And I press "Customise this page" @@ -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 "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 | @@ -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 "testuser@example.com" And I follow "Manage badges" And I should see "Number of badges available: 1" And I should not see "There are no badges available."