Merge branch 'MDL-84577-main' of https://github.com/sarjona/moodle

This commit is contained in:
Huong Nguyen 2025-03-03 09:56:39 +07:00
commit 21e84790a2
7 changed files with 48 additions and 38 deletions

View file

@ -62,13 +62,16 @@ class badge extends moodleform {
$mform->addElement('text', 'version', get_string('version', 'badges'), ['size' => '70']);
$mform->setType('version', PARAM_TEXT);
$mform->addHelpButton('version', 'version', 'badges');
$languages = get_string_manager()->get_list_of_languages();
$mform->addElement('select', 'language', get_string('language'), $languages);
$mform->addHelpButton('language', 'language', 'badges');
$mform->addElement('textarea', 'description', get_string('description', 'badges'), 'wrap="virtual" rows="8" cols="70"');
$mform->addElement(
'textarea',
'description',
get_string('description', 'badges'),
'wrap="virtual" rows="8" cols="70" placeholder="' . s(get_string('descriptioninfo', 'badges')) . '"',
);
$mform->setType('description', PARAM_NOTAGS);
$mform->addRule('description', null, 'required');
@ -82,10 +85,11 @@ class badge extends moodleform {
$currentimage = $mform->createElement('static', 'currentimage', get_string('currentimage', 'badges'));
$mform->insertElementBefore($currentimage, 'image');
}
$mform->addHelpButton('image', 'badgeimage', 'badges');
$mform->addElement('static', 'imageinfo', null, get_string('badgeimageinfo', 'badges'));
$mform->addElement('text', 'imagecaption', get_string('imagecaption', 'badges'), ['size' => '70']);
$mform->setType('imagecaption', PARAM_TEXT);
$mform->addHelpButton('imagecaption', 'imagecaption', 'badges');
$mform->addElement('tags', 'tags', get_string('tags', 'badges'), ['itemtype' => 'badge', 'component' => 'core_badges']);
$mform->addElement('header', 'issuerdetails', get_string('issuerdetails', 'badges'));
@ -96,7 +100,6 @@ class badge extends moodleform {
$site = get_site();
$issuername = $CFG->badges_defaultissuername ?: $site->fullname;
$mform->setDefault('issuername', $issuername);
$mform->addHelpButton('issuername', 'issuername', 'badges');
$mform->addElement('text', 'issuercontact', get_string('contact', 'badges'), ['size' => '70']);
if (isset($CFG->badges_defaultissuercontact)) {
@ -104,7 +107,7 @@ class badge extends moodleform {
}
$mform->setType('issuercontact', PARAM_RAW);
$mform->addRule('issuercontact', null, 'email');
$mform->addHelpButton('issuercontact', 'contact', 'badges');
// Set issuer URL.
// Have to parse URL because badge issuer origin cannot be a subfolder in wwwroot.
$url = parse_url($CFG->wwwroot);
@ -124,7 +127,6 @@ class badge extends moodleform {
$issuancedetails[] = $mform->createElement('static', 'expiryperiods_break', null, get_string('after', 'badges'));
$mform->addGroup($issuancedetails, 'expirydategr', get_string('expirydate', 'badges'), [' '], false);
$mform->addHelpButton('expirydategr', 'expirydate', 'badges');
$mform->setDefault('expiry', 0);
$mform->setDefault('expiredate', strtotime('+1 year'));
$mform->disabledIf('expiredate[day]', 'expiry', 'neq', 1);

View file

@ -25,8 +25,8 @@ Feature: Add badges to the system
| badges_defaultissuername | Test Badge Site |
| badges_defaultissuercontact | testuser@example.com |
And I navigate to "Badges > Add a new badge" in site administration
And the field "Issuer name" matches value "Test Badge Site"
And the field "Issuer contact" matches value "testuser@example.com"
And the field "issuername" matches value "Test Badge Site"
And the field "Email" matches value "testuser@example.com"
And I set the following fields to these values:
| Name | Test badge with 'apostrophe' and other friends (<>&@#) |
| Version | v1 |
@ -34,7 +34,7 @@ Feature: Add badges to the system
| Description | Test badge description |
| Image caption | Test caption image |
| Tags | Math, Physics |
| Issuer contact | issuer@example.com |
| Email | issuer@example.com |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
When I press "Create badge"
Then I should see "Edit details"
@ -100,11 +100,11 @@ Feature: Add badges to the system
And I should see "Endorsement"
And I select "Endorsement" from the "jump" singleselect
And I set the following fields to these values:
| Endorser name | Endorser |
| Email | endorsement@example.com |
| Issuer URL | http://example.com |
| Claim URL | http://claimurl.example.com |
| Endorsement comment | Test Endorsement comment |
| Endorser name | Endorser |
| Email | endorsement@example.com |
| URL | http://example.com |
| Claim URL | http://claimurl.example.com |
| Endorsement comment | Test Endorsement comment |
And I press "Save changes"
Then I should see "Changes saved"
@ -182,7 +182,7 @@ Feature: Add badges to the system
And I navigate to "Badges > Manage badges" in site administration
When I press "Edit" action in the "Testing site badge" report row
And I should see "Testing site badge"
And the field "Issuer contact" matches value "testuser@example.com"
And the field "Email" matches value "testuser@example.com"
And I set the following fields to these values:
| Name | Test badge with 'apostrophe' and other friends (<>&@#) |
| Version | secondversion |
@ -190,7 +190,7 @@ Feature: Add badges to the system
| Description | Modified test badge description |
| Image caption | Test caption image |
| Tags | Math, History |
| Issuer contact | issuer@invalid.cat |
| Email | issuer@invalid.cat |
And I press "Save changes"
And I select "Overview" from the "jump" singleselect
And I expand all fieldsets
@ -205,8 +205,8 @@ Feature: Add badges to the system
Scenario: Default value for issuer name
When I navigate to "Badges > Add a new badge" in site administration
Then the field "Issuer name" matches value "Acceptance test site"
Then the field "issuername" matches value "Acceptance test site"
But the following config values are set as admin:
| badges_defaultissuername | Test Badge Site |
And I navigate to "Badges > Add a new badge" in site administration
And the field "Issuer name" matches value "Test Badge Site"
And the field "issuername" matches value "Test Badge Site"

View file

@ -100,7 +100,7 @@ Feature: Display badges
# Set expired date to badge (future date).
Given I press "Edit" action in the "Testing system badge" report row
And I expand all fieldsets
When I click on "Relative date" "radio"
When I click on "Relative date: this badge expires after a period of time:" "radio"
And I set the field "expireperiod[number]" to "1"
And I press "Save changes"
And I should see "Changes saved"
@ -124,7 +124,7 @@ Feature: Display badges
# Set expired date to badge (relative date 1 seconds after the date of issue it).
Given I press "Edit" action in the "Testing system badge" report row
And I expand all fieldsets
When I click on "Relative date" "radio"
When I click on "Relative date: this badge expires after a period of time:" "radio"
And I set the field "expireperiod[timeunit]" to "1"
And I set the field "expireperiod[number]" to "1"
And I press "Save changes"

View file

@ -193,7 +193,7 @@ final class badges_test extends core_reportbuilder_testcase {
$this->assertEquals('English', $language);
$this->assertEquals(2, $version);
$this->assertEquals('Available', $status);
$this->assertEquals('Never', $expiry);
$this->assertEquals('Never: this badge does not expire.', $expiry);
$this->assertEmpty($tag);
$this->assertEmpty($expires);
$this->assertEmpty($visible);

View file

@ -197,7 +197,7 @@ final class users_test extends core_reportbuilder_testcase {
$this->assertEquals('English', $language);
$this->assertEquals(2, $version);
$this->assertEquals('Available (criteria locked)', $status);
$this->assertEquals('Never', $expiry);
$this->assertEquals('Never: this badge does not expire.', $expiry);
$this->assertEmpty($tag);
$this->assertEmpty($expires);
$this->assertEquals('Yes', $visible);

View file

@ -146,7 +146,7 @@ $string['backpackprovider'] = 'Backpack provider';
$string['badges'] = 'Badges';
$string['badgedetails'] = 'Badge details';
$string['badgeimage'] = 'Image';
$string['badgeimage_help'] = 'The image should be at least 300 x 300 pixels in size. It will be displayed as 300 x 300 pixels on the badge page and 100 x 100 pixels on the user\'s profile page.';
$string['badgeimageinfo'] = 'For best results, upload a square image with a minimum size of 300 x 300 pixels.';
$string['badgeissued'] = 'Badge issued';
$string['badgeprivacysetting'] = 'Badge privacy settings';
$string['badgeprivacysetting_help'] = 'Badges you earn can be displayed on your account profile page. This setting allows you to automatically set the visibility of the newly earned badges.
@ -179,7 +179,6 @@ $string['brelated'] = 'Related badges ({$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.';
$string['claim'] = 'Claim';
$string['claimcomment'] = 'Endorsement comment';
$string['claimid'] = 'Claim URL';
@ -191,8 +190,7 @@ $string['configuremessage'] = 'Badge message';
$string['connect'] = 'Connect';
$string['connected'] = 'Connected';
$string['connecting'] = 'Connecting...';
$string['contact'] = 'Issuer contact';
$string['contact_help'] = 'An email address associated with the badge issuer.';
$string['contact'] = 'Email';
$string['copy'] = 'Copy';
$string['copyof'] = 'Copy of {$a}';
$string['course'] = 'Course: {$a}';
@ -288,6 +286,7 @@ $string['deletehelp'] = '<p>Fully deleting a badge means that all its informatio
$string['delcritconfirm'] = 'Are you sure that you want to delete this criterion?';
$string['delparamconfirm'] = 'Are you sure that you want to delete this parameter?';
$string['description'] = 'Description';
$string['descriptioninfo'] = 'What does this badge represent?';
$string['disconnect'] = 'Disconnect';
$string['donotaward'] = 'Currently, this badge is not active, so it cannot be awarded to users. If you would like to award this badge, please set its status to active.';
$string['enablebadges'] = 'Enable badges';
@ -310,7 +309,6 @@ $string['error:invalidparambadge'] = 'Badge does not exist. ';
$string['error:noactivities'] = 'There are no activities with completion criteria enabled in this course.';
$string['error:nobadges'] = 'There are currently no badges with access enabled to be added as criteria. A site badge can only have other site badges as criteria. A course badge can have other course badges or site badges as criteria.';
$string['error:invalidparamcohort'] = 'Cohort does not exist. ';
$string['error:noactivities'] = 'There are no activities with completion criteria enabled in this course.';
$string['error:nocohorts'] = 'No cohorts';
$string['error:nocourses'] = 'Course completion is not enabled for any of the courses in this site, so none can be displayed. Course completion may be enabled in the course settings.';
$string['error:nogroupssummary'] = '<p>There are no public collections of badges available in your backpack. </p>';
@ -355,14 +353,13 @@ $string['expireperiodh'] = 'This badge expires {$a} hour(s) after being issued.'
$string['expireperiodm'] = 'This badge expires {$a} minute(s) after being issued.';
$string['expireperiods'] = 'This badge expires {$a} second(s) after being issued.';
$string['expirydate'] = 'Expiry date';
$string['expirydate_help'] = 'Optionally, badges can expire on a specific date, or the date can be calculated based on the date when the badge was issued to a user. ';
$string['existsinbackpack'] = 'Badge already exists in backpack';
$string['externalconnectto'] = 'To display external badges you need to <a href="{$a}">connect to a backpack</a>.';
$string['externalbackpack_required'] = 'Backpack provider can\'t be blank';
$string['externalbadges'] = 'My badges from other web sites';
$string['externalbadgesp'] = 'Badges from other web sites:';
$string['externalbadges_help'] = 'This area displays badges from your external backpack.';
$string['fixed'] = 'Fixed date';
$string['fixed'] = 'Fixed date: this badge expires on the following date:';
$string['hidden'] = 'Hidden';
$string['hiddenbadge'] = 'Unfortunately, the badge owner has not made this information available.';
$string['hostedurl'] = 'External URL';
@ -375,14 +372,12 @@ $string['issuedon'] = 'Issued {$a}';
$string['issuerdetails'] = 'Issuer details';
$string['issueremail'] = 'Email';
$string['issueremail_help'] = 'A contact email address of the organisation issuing the endorsement.';
$string['issuername'] = 'Issuer name';
$string['issuername_help'] = 'Name of the issuing agent or authority.';
$string['issuername'] = 'Name';
$string['issuername_endorsement'] = 'Endorser name';
$string['issuername_endorsement_help'] = 'The name of the endorser.';
$string['issuerurl'] = 'Issuer URL';
$string['issuerurl'] = 'URL';
$string['issuerurl_help'] = 'The website of the organisation issuing the endorsement. The URL should have a prefix http:// or https://.';
$string['language'] = 'Language';
$string['language_help'] = 'The language used on the badge page.';
$string['listbackpacks'] = 'List of backpacks';
$string['localconnectto'] = 'To share these badges outside this web site you need to <a href="{$a}">connect to a backpack</a>.';
$string['localbadges'] = 'My badges from {$a} web site';
@ -410,7 +405,7 @@ $string['moredetails'] = 'More details';
$string['mybadges'] = 'My badges';
$string['mybackpack'] = 'My backpack settings';
$string['namewithlink'] = 'Name with link';
$string['never'] = 'Never';
$string['never'] = 'Never: this badge does not expire.';
$string['newbackpack'] = 'Add a new backpack';
$string['newbadge'] = 'Add a new badge';
$string['newbadgedeprecated'] = 'You have been redirected from badges/newbadge.php. Please note that badges/newbadge.php will be removed in the near future.
@ -504,7 +499,7 @@ $string['privacy:metadata:manualaward:recipientid'] = 'The ID of the user who is
$string['recipient'] = 'Badge recipient';
$string['recipients'] = 'Badge recipients';
$string['recipientvalidationproblem'] = 'This user cannot be verified as a recipient of this badge.';
$string['relative'] = 'Relative date';
$string['relative'] = 'Relative date: this badge expires after a period of time:';
$string['relatedbages'] = 'Related badges';
$string['revoke'] = 'Revoke badge';
$string['requiredcohort'] = 'At least one cohort should be added to the cohort criterion.';
@ -582,7 +577,6 @@ $string['verifyemail'] = 'Verify email';
$string['viewbadge'] = 'View issued badge';
$string['visible'] = 'Visible';
$string['version'] = 'Version';
$string['version_help'] = 'The version field may be used to keep track of the badge\'s development. If specified, the version is displayed on the badge page.';
$string['warnexpired'] = ' (This badge has expired!)';
$string['year'] = 'Year(s)';
$string['includeauthdetails'] = "Include authentication details with the backpack";
@ -597,9 +591,16 @@ $string['error:duplicatename'] = 'Badge with such name already exists in the sys
$string['reviewbadge'] = 'Changes in badge access';
// Deprecated since Moodle 5.0.
$string['badgeimage_help'] = 'The image should be at least 300 x 300 pixels in size. It will be displayed as 300 x 300 pixels on the badge page and 100 x 100 pixels on the user\'s profile page.';
$string['contact_help'] = 'An email address associated with the badge issuer.';
$string['expirydate_help'] = 'Optionally, badges can expire on a specific date, or the date can be calculated based on the date when the badge was issued to a user. ';
$string['imageauthoremail'] = 'Image author\'s email';
$string['imageauthoremail_help'] = 'If specified, the email address of the badge image author is displayed on the badge page.';
$string['imageauthorname'] = 'Image author\'s name';
$string['imageauthorname_help'] = 'If specified, the name of the badge image author is displayed on the badge page.';
$string['imageauthorurl'] = 'Image author\'s URL';
$string['imageauthorurl_help'] = 'If specified, a link to the badge image author\'s website is displayed on the badge page. The URL should have a prefix http:// or https://.';
$string['imagecaption_help'] = 'If specified, an image caption is displayed on the badge page.';
$string['issuername_help'] = 'Name of the issuing agent or authority.';
$string['language_help'] = 'The language used on the badge page.';
$string['version_help'] = 'The version field may be used to keep track of the badge\'s development. If specified, the version is displayed on the badge page.';

View file

@ -156,3 +156,10 @@ imageauthorname,core_badges
imageauthorname_help,core_badges
imageauthorurl,core_badges
imageauthorurl_help,core_badges
badgeimage_help,core_badges
contact_help,core_badges
expirydate_help,core_badges
imagecaption_help,core_badges
issuername_help,core_badges
language_help,core_badges
version_help,core_badges