Calculated multichoice question - Illegal formula syntax only on grading

Calculated multichoice question - Illegal formula syntax only on grading

by Susana L. -
Number of replies: 4

Hi,

A teacher reported an error trying to manual grade Calculated multichoice questions in a test.
No errors when creating the questions and no errors when the students answered the questions. The error came out only when grading the questions.

https://[moodle...]/mod/quiz/report.php?id=80147&mode=grading&slot=7&qid=182261&grade=all&includeauto=1%C2%A0

Grading attempts 1 to 5 of 14

Illegal formula syntax starting with '2*{Vi}'

More information about this error
Debug info:
Error code: illegalformulasyntax
Stack trace:

    line 438 of /question/type/calculated/question.php: moodle_exception thrown
    line 426 of /question/type/calculated/question.php: call to qtype_calculated_variable_substituter->calculate_raw()
    line 476 of /question/type/calculated/question.php: call to qtype_calculated_variable_substituter->calculate()
    line ? of unknownfile: call to qtype_calculated_variable_substituter->{closure}()
    line 477 of /question/type/calculated/question.php: call to preg_replace_callback()
    line 156 of /question/type/calculatedmulti/question.php: call to qtype_calculated_variable_substituter->replace_expressions_in_text()
    line 65 of /question/type/calculatedmulti/question.php: call to qtype_calculatedmulti_calculate_helper::calculate_all_expressions()
    line 169 of /question/type/calculated/question.php: call to qtype_calculatedmulti_single_question->calculate_all_expressions()
    line 60 of /question/type/calculatedmulti/question.php: call to qtype_calculated_question_helper::apply_attempt_state()
    line 1415 of /question/engine/questionattempt.php: call to qtype_calculatedmulti_single_question->apply_attempt_state()
    line 862 of /question/engine/questionusage.php: call to question_attempt::load_from_records()
    line 355 of /question/engine/datalib.php: call to question_usage_by_activity::load_from_records()
    line 84 of /question/engine/lib.php: call to question_engine_data_mapper->load_questions_usage_by_activity()
    line 409 of /mod/quiz/report/grading/report.php: call to question_engine::load_questions_usage_by_activity()
    line 155 of /mod/quiz/report/grading/report.php: call to quiz_grading_report->display_grading_interface()
    line 96 of /mod/quiz/report.php: call to quiz_grading_report->display()


The formulas:

{=2*{Vi}} V, {=0.78*{Vi}*sqrt(2)/sqrt( {R}*{R}+6.28*{Fc}*{L}*6.28*{Fc}*{L} )} A
{=2*{Vi}} V, {=0.78*{Vi}*sqrt(2)/sqrt(3)/sqrt( {R}*{R}+6.28*{Fc}*{L}*6.28*{Fc}*{L} )} A

On Moodle 2.7 Postgresql

Thank you!
susana

Average of ratings: -
In reply to Susana L.

Re: Calculated multichoice question - Illegal formula syntax only on grading

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That is very strange. The code that is failing here would also be used if you went and reviewed the quiz attempt, but you say everything other than manual grading works. Can you try clicking all the 'Review attempt' links in the quiz results, just to double-check? Thanks.

In reply to Tim Hunt

Re: Calculated multichoice question - Illegal formula syntax only on grading

by Susana L. -

Hi Tim. You are right . On Review attempt we get this same error.

https://[moodle...]/mod/quiz/review.php?attempt=131804

Illegal formula syntax starting with '2*{Vi}'

More information about this error
Debug info:
Error code: illegalformulasyntax
Stack trace:

    line 438 of /question/type/calculated/question.php: moodle_exception thrown
    line 426 of /question/type/calculated/question.php: call to qtype_calculated_variable_substituter->calculate_raw()
    line 476 of /question/type/calculated/question.php: call to qtype_calculated_variable_substituter->calculate()
    line ? of unknownfile: call to qtype_calculated_variable_substituter->{closure}()
    line 477 of /question/type/calculated/question.php: call to preg_replace_callback()
    line 156 of /question/type/calculatedmulti/question.php: call to qtype_calculated_variable_substituter->replace_expressions_in_text()
    line 65 of /question/type/calculatedmulti/question.php: call to qtype_calculatedmulti_calculate_helper::calculate_all_expressions()
    line 169 of /question/type/calculated/question.php: call to qtype_calculatedmulti_single_question->calculate_all_expressions()
    line 60 of /question/type/calculatedmulti/question.php: call to qtype_calculated_question_helper::apply_attempt_state()
    line 1415 of /question/engine/questionattempt.php: call to qtype_calculatedmulti_single_question->apply_attempt_state()
    line 862 of /question/engine/questionusage.php: call to question_attempt::load_from_records()
    line 355 of /question/engine/datalib.php: call to question_usage_by_activity::load_from_records()
    line 84 of /question/engine/lib.php: call to question_engine_data_mapper->load_questions_usage_by_activity()
    line 474 of /mod/quiz/attemptlib.php: call to question_engine::load_questions_usage_by_activity()
    line 494 of /mod/quiz/attemptlib.php: call to quiz_attempt->__construct()
    line 504 of /mod/quiz/attemptlib.php: call to quiz_attempt::create_helper()
    line 46 of /mod/quiz/review.php: call to quiz_attempt::create()

Attached the full question xml. Thank you!

In reply to Susana L.

Re: Calculated multichoice question - Illegal formula syntax only on grading

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Is it possible that the question was edited to add the Vi variable after some students had attempted it? (You could compare the date when the quiz attempt was started with the date when the question was last modified.)

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Calculated multichoice question - Illegal formula syntax only on grading

by Susana L. -

Yes, the question was edited after the attempt started. The quiz was "messed up"... and I was not aware of that before opening this thread.

Thank you for your help!