This commit is contained in:
Huong Nguyen 2024-10-29 09:01:07 +07:00
commit 88c39c1766
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
5 changed files with 14 additions and 12 deletions

View File

@ -74,6 +74,6 @@ Feature: Import course's contents into another course
And I should see "Unpublished course badge"
And I should see "Unpublished without criteria course badge"
# Badges exist and the criteria have been restored too.
And I should not see "Criteria for this badge have not been set up yet" in the "Published course badge" "table_row"
And I should not see "Criteria for this badge have not been set up yet" in the "Unpublished course badge" "table_row"
And I should see "Criteria for this badge have not been set up yet" in the "Unpublished without criteria course badge" "table_row"
And ".no-criteria-set" "css_element" should not exist in the "Published course badge" "table_row"
And ".no-criteria-set" "css_element" should not exist in the "Unpublished course badge" "table_row"
And ".no-criteria-set" "css_element" should exist in the "Unpublished without criteria course badge" "table_row"

View File

@ -290,11 +290,11 @@ Feature: Restore Moodle 2 course backups
And I should see "Unpublished course badge"
And I should see "Unpublished without criteria course badge"
# If activities were included, the criteria have been restored too; otherwise no criteria have been set up for badges.
And I <shouldornotsee> "Criteria for this badge have not been set up yet" in the "Published course badge" "table_row"
And I <shouldornotsee> "Criteria for this badge have not been set up yet" in the "Unpublished course badge" "table_row"
And I should see "Criteria for this badge have not been set up yet" in the "Unpublished without criteria course badge" "table_row"
And ".no-criteria-set" "css_element" <shouldornotexist> in the "Published course badge" "table_row"
And ".no-criteria-set" "css_element" <shouldornotexist> in the "Unpublished course badge" "table_row"
And ".no-criteria-set" "css_element" should exist in the "Unpublished without criteria course badge" "table_row"
Examples:
| includeactivities | shouldornotsee |
| 0 | should see |
| 1 | should not see |
| includeactivities | shouldornotexist |
| 0 | should exist |
| 1 | should not exist |

View File

@ -160,7 +160,9 @@ class badge extends base {
return '';
}
$badge = new \core_badges\badge($badgeid);
if (empty($badge->criteria)) {
return '<span class="no-criteria-set d-none"></span>';
}
$renderer = $PAGE->get_renderer('core_badges');
return $renderer->print_badge_criteria($badge, 'short');
});

View File

@ -189,7 +189,7 @@ final class badges_test extends core_reportbuilder_testcase {
$this->assertEquals($badgetwo->name, $badgename);
$this->assertEmpty($fullname);
$this->assertEquals($expectedbadgetwolink, $namewithlink);
$this->assertEquals('Criteria for this badge have not been set up yet.', $criteria);
$this->assertStringContainsString('no-criteria-set', $criteria);
$this->assertStringContainsString('Image caption', $image);
$this->assertEquals('English', $language);
$this->assertEquals(2, $version);

View File

@ -193,7 +193,7 @@ class users_test extends core_reportbuilder_testcase {
$this->assertEquals(fullname($user), $fullname);
$this->assertEquals($badgecourse->name, $badgename);
$this->assertEquals($expectedbadgecourselink, $namewithlink);
$this->assertEquals('Criteria for this badge have not been set up yet.', $criteria);
$this->assertStringContainsString('no-criteria-set', $criteria);
$this->assertStringContainsString('Image caption', $image);
$this->assertEquals('English', $language);
$this->assertEquals(2, $version);