Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Question-lesson link

From MoodleDocs
Revision as of 06:28, 4 October 2011 by Oleg Sychev (talk | contribs)

The problems of linking the lesson module with the question engine is exists long ago in the Moodle. We at the Volgograd State Technical University are interested in it too, and may spent some effort developing it.

However, good link require some additions to the question interface. We are supposing to add two simple functions, which don't interfere with other parts, but would allow question to report it state in universal manner.

Let's call a question attempt property (if anyone could propose a better word, I gladly rename them) some piece of data, describing current state of the attempt - i.e. number of submitting student made (in interactive/adaptive mode), matching answer, that used for grading (for shortanswer/numerical question), grade given (with or without penalties) etc.

Now we need just two functions like supported_attempt_properties() and get_attempt_property()

supported_attempt_properties function returns an array of properties this question type supports and the type of their values (i.e. number, string etc). Like for

 shortanswer array(
   'numattempts' => array('type' => TYPE_INT, 'min' => '0', max => '...'), 
    'answer' => array('type' => TYPE_STRING),...
 ). 

The possible data types could be defined, so that even complex types like multichoice or match could report anything important.

get_attempt_property has a two arguments: object, representing the question state (whatever this is in a new question engine) and a property name. It returns the actual value of given property for a given attempt. It is used by external module to query the properties value.

Those two functions with appropriate data types would allow to report almost anything, and place property reporting on appropriate inheritance levels (number of attempts could be reported by generic question class). They allow very much flexibility for the 3d party question authors while remaining easy to implement. They also allowed for a greater flexibility for a lesson module, like redirecting student somewhere after 4 unsuccessful tries at question, or something. What's more, the only thing that is presumed in that kind of link is available data types, anything else could be changed without affecting class's interface. We could even make data types a classes, then it could be easy to add new ones too.