gradebook MDL-22670 added function to trim trailing zeros

This commit is contained in:
Andrew Davis
2010-06-04 03:59:49 +00:00
parent b79c7c289b
commit 3cf33f5181
+5 -1
View File
@@ -367,7 +367,7 @@ class grade_edit_tree {
if ((($aggcoef == 'aggregationcoefweight' || $aggcoef == 'aggregationcoef') && $type == 'weight') ||
($aggcoef == 'aggregationcoefextraweight' && $type == 'extra')) {
return '<input type="text" size="6" id="aggregationcoef_'.$item->id.'" name="aggregationcoef_'.$item->id.'"
value="'.format_float($item->aggregationcoef, 4).'" />';
value="'.grade_edit_tree::format_number($item->aggregationcoef).'" />';
} elseif ($aggcoef == 'aggregationcoefextrasum' && $type == 'extra') {
$checked = ($item->aggregationcoef > 0) ? 'checked="checked"' : '';
return '<input type="hidden" name="extracredit_'.$item->id.'" value="0" />
@@ -377,6 +377,10 @@ class grade_edit_tree {
}
}
function format_number($number) {
return rtrim(rtrim(format_float($number, 4),'0'),'.');
}
/**
* Given an element of the grade tree, returns whether it is deletable or not (only manual grade items are deletable)
*