Adapting preg question to the new question engine

Re: Adapting preg question to the new question engine

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

The state should be based on the student's final response, rather than the fraction. It is easier to explain with an example.

Suppose you have a questions with penalty 33.3%, and the student gets it right on the third try. Then, the overall fraction will be 33.3%, but the state will be question_state::$right.

Regarding your suggested work-around for the inability to save state information in grade_response. Using a hidden form field does not work very well. First, grade_response is called from processattempt.php, while the renderer is only called from attempt.php, so you will have to re-calculate at least twice.

What is required is a way for grade_response (and similar methods) to call $pendingstep->set_qt_var(), and the problem is that those methods don't have access to $pendingstep. I need to think of the safest way to make that possible.

The OU pmatch question type is gets quite slow in certain situations (a few seconds to process one response in one particularly complex case) so this issue is causing me pain as well as you. I do need to find a solution, but I don't want to be rushed into implementing a bad solution that causes problems in the long term.