Question type

This forum post has been removed

Number of replies: 3
The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Question type

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

Well, the get_correct_response() method has no relation to getting the correct response from the database!

Have you looked at how any of the standard question types work?

The docs that exist are: https://docs.moodle.org/dev/Question_types and also, the extensive phpdoc comments on all the methods in the base classes.

In reply to Tim Hunt

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Question type

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

The way it works is that all the data that defines the question (including the question text, what the right answer is, and all the feedback) is loaded by some methods in the question type class, like qtype_shortanswer. Some of it - the bits that are present in all questions and stored in the mdl_question table, are loaded by the base class, and then any question-type specific bits are load by get_question_options.

That just loads all the data into some stdClass objects (because history of the code). Then there is a method make_question which takes all that data and creates an instance of your question_definition class (e.g. qtype_shortanswer_question). That should have all the data you need to define things like what the correct answer is.