diff --git a/badges/edit.php b/badges/edit.php index 2307d0d1e76..d52a7c810cd 100644 --- a/badges/edit.php +++ b/badges/edit.php @@ -100,9 +100,11 @@ if ($form->is_cancelled()) { $badge->imageauthorurl = $data->imageauthorurl; $badge->imagecaption = $data->imagecaption; $badge->usermodified = $USER->id; - $badge->issuername = $data->issuername; - $badge->issuerurl = $data->issuerurl; - $badge->issuercontact = $data->issuercontact; + if (badges_open_badges_backpack_api() == OPEN_BADGES_V1) { + $badge->issuername = $data->issuername; + $badge->issuerurl = $data->issuerurl; + $badge->issuercontact = $data->issuercontact; + } $badge->expiredate = ($data->expiry == 1) ? $data->expiredate : null; $badge->expireperiod = ($data->expiry == 2) ? $data->expireperiod : null; diff --git a/badges/tests/behat/add_badge.feature b/badges/tests/behat/add_badge.feature index 09db662b26e..bc7695df440 100644 --- a/badges/tests/behat/add_badge.feature +++ b/badges/tests/behat/add_badge.feature @@ -166,3 +166,32 @@ Feature: Add badges to the system 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" + + @javascript @_file_upload + Scenario: Edit a badge + 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 | firstversion | + | Language | English | + | Description | Test badge description | + | Image author | http://author.example.com | + | Image caption | Test caption image | + And I upload "badges/tests/behat/badge.png" file to "Image" filemanager + And I press "Create badge" + When I follow "Edit details" + And I should see "Test badge with 'apostrophe' and other friends (&@#)" + And I should not see "Issuer details" + And I set the following fields to these values: + | Name | Test badge renamed | + | Version | secondversion | + And I press "Save changes" + And I follow "Overview" + Then I should not see "Test badge with 'apostrophe' and other friends (&@#)" + And I should not see "firstversion" + And I should see "Test badge renamed" + And I should see "secondversion"