Hi all,
Hi Bernat,
I would also like to thank Jean-Michel for his excellent and indispensable work.
I get the same problem, for example: http://35.193.77.29/mod/quiz/view.php?id=631 (login: 'student', password: 'Moodle2018#'.
Until the bug is fixed, the red triangle warns that the answer will not be accepted and will actually make the question crash and make it inaccessible until reset by the teacher! (which means that I will have to reset my example if you try it )
Hello,
Thanks to both of you for the report.
I missed these messages and only discover them today.
I tested the new version with php 7.1.9 and also Travis run the phpunit and Behat tests with php 7 without discovering the problem so there is surely something to improve in this area too.
See https://travis-ci.org/jmvedrine/moodle-qtype_formulas/jobs/337781982 ans scroll down to the end of the page to see that phpunit and Behat tests are OK.
When there is a bug it is better to create an issue in the CONTRIB tracker or in Github so that I receive a mail to warn me. That will be faster because I don't read this forum each day.
I will look at the problem.
Thanks also for providing informations and question samples to allow me to reproduce the problem.
It may takes a few days as I have some "family constraints" until Friday.
You are right the problem is in the eval function line 930 of the question/type/formulas/variables.php file.
According to a comment on the page http://php.net/manual/fr/function.eval.php this function has changed in php 7.x from just returning false to terminating the script if the evaluated code generate a fatal error
Most probably the solution is to include it in a try { } catch block
Unfortunately I will not be able to commit the change after having fully tested it (and release a new version until Friday (sorry Family constraints !)
Maybe if you are brave enough you can test to replace this line with something like
try {
eval('$res = '.implode(' ',$splitted).';');
} catch (Throwable $t) {
throw new Exception(get_string('error_eval_numerical','qtype_formulas'));
}
I was able to conduct very quick tests of the above fix and it seems to solve the problem.
It also solve the problem I had when I ported the php tests that were included in variables.php and that are now in question/type/formulas/tests/variables_test.php that 4 tests were not giving the expected result.
And this demonstrate that when you test something you have to consider all factors : when I saw that these 4 tests were falling, I quickly set up some files to verify in that in Hon Wai Lau original tests those 4 tests were also falling and I deducted that these failures were not harmful.
Of coure I was wrong because I tested the original tests with php 7 not with the php version that was used at that time !
Thank you Jean-Michel, I have been "brave" enough, I have tried and it works at
http://formulas.compasspro.eu/mod/quiz/report.php?id=198&mode=overview
We are waiting for the new release, but don't worry, we are not in a hurry