diff --git a/backup/util/ui/tests/behat/import_course.feature b/backup/util/ui/tests/behat/import_course.feature index 5f849f5b711..8e9f31e62da 100644 --- a/backup/util/ui/tests/behat/import_course.feature +++ b/backup/util/ui/tests/behat/import_course.feature @@ -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" diff --git a/backup/util/ui/tests/behat/restore_moodle2_courses.feature b/backup/util/ui/tests/behat/restore_moodle2_courses.feature index 7da17b0abfc..bca95e15c4b 100644 --- a/backup/util/ui/tests/behat/restore_moodle2_courses.feature +++ b/backup/util/ui/tests/behat/restore_moodle2_courses.feature @@ -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 "Criteria for this badge have not been set up yet" in the "Published course badge" "table_row" - And I "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" in the "Published course badge" "table_row" + And ".no-criteria-set" "css_element" 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 | diff --git a/badges/classes/reportbuilder/local/entities/badge.php b/badges/classes/reportbuilder/local/entities/badge.php index 526c441382c..a205d5eed93 100644 --- a/badges/classes/reportbuilder/local/entities/badge.php +++ b/badges/classes/reportbuilder/local/entities/badge.php @@ -160,7 +160,9 @@ class badge extends base { return ''; } $badge = new \core_badges\badge($badgeid); - + if (empty($badge->criteria)) { + return ''; + } $renderer = $PAGE->get_renderer('core_badges'); return $renderer->print_badge_criteria($badge, 'short'); }); diff --git a/badges/tests/reportbuilder/datasource/badges_test.php b/badges/tests/reportbuilder/datasource/badges_test.php index 3644a16522d..fa8ab22ae34 100644 --- a/badges/tests/reportbuilder/datasource/badges_test.php +++ b/badges/tests/reportbuilder/datasource/badges_test.php @@ -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); diff --git a/badges/tests/reportbuilder/datasource/users_test.php b/badges/tests/reportbuilder/datasource/users_test.php index b83f36f60f1..65af92adfcd 100644 --- a/badges/tests/reportbuilder/datasource/users_test.php +++ b/badges/tests/reportbuilder/datasource/users_test.php @@ -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);