Details

Description

I just regraded a quiz, which uses only short answer an multiple choice questions. I had previously altered the overall feedback settings, but nothing else. I got the following error loads of times at the bottom of the screen, after all the regradings had happened. It went OK it seems other than that.

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Notice: Undefined offset: -2 in E:\Moodle_webserver\moodle\lib\evalmath\evalmath.class.php on line 425

Sam Marshall
added a comment - 21/May/09 7:44 PM We are seeing the same thing here. It appears to be caused by an error in the evalmath class which is used for calculated grades.
To reproduce:
error_reporting(E_ALL);
$silly = new EvalMath();
$silly->nfx('(gi6-20+1)/(2*(gi6-20+0.5))');
The actual results of the function appear to be correct, so this warning does not do any harm, but it is rather disturbing.

Sam Marshall
added a comment - 21/May/09 7:50 PM OK, I found it. The bug is:
When you close a bracket, it looks at the token before the open-bracket (on its stack) to see if it is a function call.
It does this even if there is no token before the open-bracket
So you will get this warning for each bracket in the expression that isn't a function call.
Will fix shortly.

I changed the logic for the last() function involved here so that instead of giving a debugging warning if you ask for something off the end of the stack, it returns null. This is analogous to the pop() function.

While this basically just gets rid of the warning without fixing anything I did verify that the warning was harmless - the postfix version of the expression is correct.

Sam Marshall
added a comment - 21/May/09 7:58 PM This is also reproducible with the expression (1+1)
I changed the logic for the last() function involved here so that instead of giving a debugging warning if you ask for something off the end of the stack, it returns null. This is analogous to the pop() function.
While this basically just gets rid of the warning without fixing anything I did verify that the warning was harmless - the postfix version of the expression is correct.