mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-68746 core_badges: remove Issuer details from badges form
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.
This commit is contained in:
parent
1afe68f382
commit
630a19ebd5
3 changed files with 15 additions and 32 deletions
|
@ -93,9 +93,10 @@ class badge extends moodleform {
|
||||||
$mform->setType('imagecaption', PARAM_TEXT);
|
$mform->setType('imagecaption', PARAM_TEXT);
|
||||||
$mform->addHelpButton('imagecaption', 'imagecaption', 'badges');
|
$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->addElement('text', 'issuername', get_string('name'), array('size' => '70'));
|
||||||
$mform->setType('issuername', PARAM_NOTAGS);
|
$mform->setType('issuername', PARAM_NOTAGS);
|
||||||
$mform->addRule('issuername', null, 'required');
|
$mform->addRule('issuername', null, 'required');
|
||||||
|
@ -115,21 +116,6 @@ class badge extends moodleform {
|
||||||
$url = parse_url($CFG->wwwroot);
|
$url = parse_url($CFG->wwwroot);
|
||||||
$mform->addElement('hidden', 'issuerurl', $url['scheme'] . '://' . $url['host']);
|
$mform->addElement('hidden', 'issuerurl', $url['scheme'] . '://' . $url['host']);
|
||||||
$mform->setType('issuerurl', PARAM_URL);
|
$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'));
|
$mform->addElement('header', 'issuancedetails', get_string('issuancedetails', 'badges'));
|
||||||
|
@ -212,7 +198,7 @@ class badge extends moodleform {
|
||||||
global $DB;
|
global $DB;
|
||||||
$errors = parent::validation($data, $files);
|
$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'])) {
|
if (!empty($data['issuercontact']) && !validate_email($data['issuercontact'])) {
|
||||||
$errors['issuercontact'] = get_string('invalidemail');
|
$errors['issuercontact'] = get_string('invalidemail');
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ if ($form->is_cancelled()) {
|
||||||
$fordb->usercreated = $USER->id;
|
$fordb->usercreated = $USER->id;
|
||||||
$fordb->usermodified = $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->issuername = $data->issuername;
|
||||||
$fordb->issuerurl = $data->issuerurl;
|
$fordb->issuerurl = $data->issuerurl;
|
||||||
$fordb->issuercontact = $data->issuercontact;
|
$fordb->issuercontact = $data->issuercontact;
|
||||||
|
|
|
@ -8,18 +8,6 @@ Feature: Add badges to the system
|
||||||
Given I am on homepage
|
Given I am on homepage
|
||||||
And I log in as "admin"
|
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
|
@javascript
|
||||||
Scenario: Accessing the badges
|
Scenario: Accessing the badges
|
||||||
And I press "Customise this page"
|
And I press "Customise this page"
|
||||||
|
@ -31,7 +19,11 @@ Feature: Add badges to the system
|
||||||
|
|
||||||
@javascript @_file_upload
|
@javascript @_file_upload
|
||||||
Scenario: Add a badge
|
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:
|
And I set the following fields to these values:
|
||||||
| Name | Test badge with 'apostrophe' and other friends (<>&@#) |
|
| Name | Test badge with 'apostrophe' and other friends (<>&@#) |
|
||||||
| Version | v1 |
|
| Version | v1 |
|
||||||
|
@ -47,6 +39,11 @@ Feature: Add badges to the system
|
||||||
And I should see "Related badges (0)"
|
And I should see "Related badges (0)"
|
||||||
And I should see "Alignments (0)"
|
And I should see "Alignments (0)"
|
||||||
And I should not see "Create badge"
|
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 follow "Manage badges"
|
||||||
And I should see "Number of badges available: 1"
|
And I should see "Number of badges available: 1"
|
||||||
And I should not see "There are no badges available."
|
And I should not see "There are no badges available."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue