MDL-57020 scales: Allow deletion of unused scales in forum
Allow deletion of unused scales used in a forum for the course. Signed-off-by: Sujith Haridasan <[email protected]>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 ///////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user