Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 2.1.1
-
Component/s: Gradebook
-
Testing Instructions:
-
Workaround:
-
Affected Branches:MOODLE_21_STABLE
-
Fixed Branches:MOODLE_21_STABLE, MOODLE_22_STABLE
-
Pull from Repository:
-
Pull Master Branch:
MDL-29173_calc -
Pull Master Diff URL:
Description
When attempting to use the round function in the gradebook, If you set up a custom calculation along the lines of '=round([[ec]],2)' it will return the previous error.
When you track it this is being thrown in 'moodle/lib/evalmath/evalmath.class.php' line 256.
It looks like 'round' was added to the '$fb' array in moodle2+, even though it was no in moodle1.9
This makes it match on the first if statement, which only allows for one argument or throws an exception. In previous versions it was not in the '$fb' array only the '$fc' array (which it still is in moodle2+). My guess is removing it from the '$fb' array will fix the problem, but I am not sure if that will break anything else.
line 247 |
$fnn = $matches[1]; // get the function name
|
$arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you)
|
$fn = $stack->pop();
|
$output[] = array('fn'=>$fn, 'fnn'=>$fnn, 'argcount'=>$arg_count); // send function to output
|
if (in_array($fnn, $this->fb)) { // check the argument count
|
if($arg_count > 1) {
|
$a= new stdClass();
|
$a->expected = 1;
|
$a->given = $arg_count;
|
return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
|
}
|
} elseif (array_key_exists($fnn, $this->fc)) {
|
$counts = $this->fc[$fnn];
|
if (in_array(-1, $counts) and $arg_count > 0) {}
|
elseif (!in_array($arg_count, $counts)) {
|
$a= new stdClass();
|
$a->expected = implode('/',$this->fc[$fnn]);
|
$a->given = $arg_count;
|
return $this->trigger(get_string('wrongnumberofarguments', 'mathslib', $a));
|
}
|
}
|
Replication instructions:
- Add a new grade item.
- Add a custom calculation.
- Use the 'round' function in that calculation.
- Will receive 'invalid formula' error (in non-development mode)