MDL-9628 Fixed typos and added language strings. Corrected a bug that prevented a decimalpoints of 0 from being used (empty($decimalpoints)) -> is_null
This commit is contained in:
@@ -11,14 +11,14 @@ class edit_category_form extends moodleform {
|
||||
$mform->addElement('header', 'general', get_string('gradecategory', 'grades'));
|
||||
$mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
|
||||
|
||||
$options = array(GRADE_AGGREGATE_MEAN_ALL =>get_string('aggregatemeanall', 'grades'),
|
||||
GRADE_AGGREGATE_MEAN_GRADED=>get_string('aggregatemeangraded', 'grades'),
|
||||
GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'),
|
||||
GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'),
|
||||
GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'),
|
||||
$options = array(GRADE_AGGREGATE_MEAN_ALL =>get_string('aggregatemeanall', 'grades'),
|
||||
GRADE_AGGREGATE_MEAN_GRADED =>get_string('aggregatemeangraded', 'grades'),
|
||||
GRADE_AGGREGATE_MEDIAN =>get_string('aggregatemedian', 'grades'),
|
||||
GRADE_AGGREGATE_MIN =>get_string('aggregatemin', 'grades'),
|
||||
GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'),
|
||||
GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN_ALL =>get_string('aggregateweightedmeanall', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN_GRADED =>get_string('aggregateweightedgraded', 'grades'),
|
||||
GRADE_AGGREGATE_WEIGHTED_MEAN_GRADED =>get_string('aggregateweightedmeangraded', 'grades'),
|
||||
GRADE_AGGREGATE_EXTRACREDIT_MEAN_ALL =>get_string('aggregateextracreditmeanall', 'grades'),
|
||||
GRADE_AGGREGATE_EXTRACREDIT_MEAN_GRADED=>get_string('aggregateextracreditmeangraded', 'grades'));
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ class grade_report {
|
||||
$gradeval = '';
|
||||
} else {
|
||||
// decimal points as specified by user
|
||||
if (empty($decimalpoints)) {
|
||||
if (is_null($decimalpoints)) {
|
||||
$decimalpoints = $this->get_pref('decimalpoints');
|
||||
}
|
||||
$gradeval = number_format($gradeval, $decimalpoints, $this->get_lang_string('decpoint', 'langconfig'),
|
||||
|
||||
@@ -7,12 +7,16 @@ $string['addcategoryerror'] = 'Could not add category.';
|
||||
$string['addexceptionerror'] = 'Error occurred while adding exception for userid:gradeitem';
|
||||
$string['addfeedback'] = 'Add Feedback';
|
||||
$string['additem'] = 'Add Grade Item';
|
||||
$string['aggregateextracreditmeanall'] = 'Mean of all grades (extra credits)';
|
||||
$string['aggregateextracreditmeangraded'] = 'Mean of non-empty grades (extra credits)';
|
||||
$string['aggregatemeanall'] = 'Mean of all grades';
|
||||
$string['aggregatemedian'] = 'Median of all grades';
|
||||
$string['aggregatemeangraded'] = 'Mean of non-empty grades';
|
||||
$string['aggregatemin'] = 'Smallest grade';
|
||||
$string['aggregatemax'] = 'Highest grade';
|
||||
$string['aggregatemode'] = 'Mode of all grades';
|
||||
$string['aggregateweightedmeanall'] = 'Weighted mean of all grades';
|
||||
$string['aggregateweightedmeangraded'] = 'Weighted mean of non-empty grades';
|
||||
$string['aggregation'] = 'Aggregation';
|
||||
$string['aggregationposition'] = 'Aggregation position';
|
||||
$string['aggregationview'] = 'Aggregation view';
|
||||
|
||||
@@ -423,7 +423,7 @@ class grade_category extends grade_object {
|
||||
}
|
||||
|
||||
/// normalize the grades first - all will have value 0...1
|
||||
// ungraded items are not used in aggreagation
|
||||
// ungraded items are not used in aggregation
|
||||
foreach ($grade_values as $k=>$v) {
|
||||
if (is_null($v)) {
|
||||
// null means no grade
|
||||
@@ -437,7 +437,7 @@ class grade_category extends grade_object {
|
||||
$this->apply_limit_rules($grade_values);
|
||||
asort($grade_values, SORT_NUMERIC);
|
||||
|
||||
// let's see we have still enough grades to do any statisctics
|
||||
// let's see we have still enough grades to do any statistics
|
||||
if (count($grade_values) == 0) {
|
||||
// not enough attempts yet
|
||||
$grade->finalgrade = null;
|
||||
@@ -452,12 +452,18 @@ class grade_category extends grade_object {
|
||||
switch ($this->aggregation) {
|
||||
case GRADE_AGGREGATE_MEDIAN: // Middle point value in the set: ignores frequencies
|
||||
$num = count($grade_values);
|
||||
// re-index grade_values array
|
||||
$sorted_values = $grade_values;
|
||||
sort($sorted_values);
|
||||
$halfpoint = intval($num / 2);
|
||||
|
||||
if($num % 2 == 0) {
|
||||
$rawgrade = ($grade_values[ceil($halfpoint)] + $grade_values[floor($halfpoint)]) / 2;
|
||||
if ($num == 0) {
|
||||
$rawgrade = null;
|
||||
} elseif ($num == 1) {
|
||||
$rawgrade = reset($sorted_values);
|
||||
} else if($num % 2 == 0) {
|
||||
$rawgrade = ($sorted_values[ceil($halfpoint)] + $sorted_values[floor($halfpoint)]) / 2;
|
||||
} else {
|
||||
$rawgrade = $grade_values[$halfpoint];
|
||||
$rawgrade = $sorted_values[$halfpoint];
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -550,7 +556,7 @@ class grade_category extends grade_object {
|
||||
}
|
||||
break;
|
||||
|
||||
case GRADE_AGGREGATE_MEAN_ALL: // Arithmetic average of all grade items including even NULLs; NULL grade caunted as minimum
|
||||
case GRADE_AGGREGATE_MEAN_ALL: // Arithmetic average of all grade items including even NULLs; NULL grade counted as minimum
|
||||
$num = count($items); // you can calculate sum from this one if you multiply it with count($this->depends_on() ;-)
|
||||
$sum = array_sum($grade_values);
|
||||
$rawgrade = $sum / $num;
|
||||
|
||||
Reference in New Issue
Block a user