MDL-47253 core_grades: display scale in Natural setup

Part of: MDL-46576
This commit is contained in:
Marina Glancy
2014-10-03 13:55:24 +08:00
committed by Adrian Greeve
parent 313e975349
commit 290ddb7317
2 changed files with 10 additions and 4 deletions
+6 -3
View File
@@ -766,8 +766,6 @@ class grade_edit_tree_column_range extends grade_edit_tree_column {
$parent_cat = $item->get_parent_category();
if ($item->gradetype == GRADE_TYPE_TEXT) {
$grademax = ' - ';
} else if ($parent_cat->aggregation == GRADE_AGGREGATE_SUM) {
$grademax = format_float($item->grademax, $item->get_decimals());
} else if ($item->gradetype == GRADE_TYPE_SCALE) {
$scale = $DB->get_record('scale', array('id' => $item->scaleid));
$scale_items = null;
@@ -776,7 +774,12 @@ class grade_edit_tree_column_range extends grade_edit_tree_column {
} else {
$scale_items = explode(',', $scale->scale);
}
$grademax = end($scale_items) . ' (' . count($scale_items) . ')';
if ($parent_cat->aggregation == GRADE_AGGREGATE_SUM) {
$grademax = end($scale_items) . ' (' .
format_float($item->grademax, $item->get_decimals()) . ')';
} else {
$grademax = end($scale_items) . ' (' . count($scale_items) . ')';
}
} else {
$grademax = format_float($item->grademax, $item->get_decimals());
}
+4 -1
View File
@@ -93,7 +93,10 @@ class core_grade_edittreelib_testcase extends advanced_testcase {
// Make the expected scale text.
$scaleitems = null;
$scaleitems = explode(',', $scale->scale);
$scalestring = end($scaleitems) . ' (' . count($scaleitems) . ')';
// Make sure that we expect grademax (displayed in parenthesis) be the same
// as number of items in the scale.
$scalestring = end($scaleitems) . ' (' .
format_float(count($scaleitems), 2) . ')';
$this->assertEquals(GRADE_TYPE_SCALE, $gradeitem->gradetype);
$this->assertEquals($scale->id, $gradeitem->scaleid);