General developer forum

Persisting data about question answers and reusing it when next

 
Tim at Lone Pine Koala Sanctuary
Re: Persisting data about question answers and reusing it when next
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

It sounds like you are trying to make something like qtype_calculatedmulti, so you could look at that code.

Or even, the standard mutliple-choice question type has to do this, since it randomly suffles the choices, and that order eneds to be remembered.

The key methods are start_attempt and apply_attempt_state, for example https://github.com/moodle/moodle/blob/master/question/type/multichoice/question.php#L58.

The best docs about this are the comments in the base class: https://github.com/moodle/moodle/blob/master/question/type/questionbase.php#L165

 
Average of ratings: -