diff --git a/lib/grade/tests/grade_scale_test.php b/lib/grade/tests/grade_scale_test.php index 722f7680f04..e1040f08139 100644 --- a/lib/grade/tests/grade_scale_test.php +++ b/lib/grade/tests/grade_scale_test.php @@ -167,5 +167,9 @@ class core_grade_scale_testcase extends grade_base_testcase { $this->assertNotEmpty($grade_item->id); $this->assertEquals(1, $grade_item->grademin); $this->assertEquals(1, $grade_item->grademax); + + $status = $scale->is_used(); + + $this->assertTrue($status); } } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 79cc80fc5fb..e9089555fd1 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -954,7 +954,7 @@ function forum_scale_used_anywhere(int $scaleid): bool { return false; } - return $DB->record_exists('forum', ['scale' => $scaleid * -1]); + return $DB->record_exists_select('forum', "scale = ? and assessed > 0", [$scaleid * -1]); } // SQL FUNCTIONS /////////////////////////////////////////////////////////// diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index afae7fe5159..ab662bb3a0f 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -877,7 +877,7 @@ function glossary_scale_used() { function glossary_scale_used_anywhere($scaleid) { global $DB; - if ($scaleid and $DB->record_exists('glossary', array('scale'=>-$scaleid))) { + if ($scaleid and $DB->record_exists_select('glossary', "scale = ? and assessed > 0", [-$scaleid])) { return true; } else { return false;