Hello Tim,
I decided it would be wise to define 3 questions definition classes :
class qtype_formulas_base extends question_graded_automatically
class qtype_formulas_singlesubmit extends qtype_formulas_base
class qtype_formulas_peranswersubmit extends qtype_formulas_base
Then in my qtype I do
protected function make_question_instance($questiondata) {
question_bank::load_question_definition_classes($this->name());
if ($questiondata->options->peranswersubmit) {
$class = 'qtype_formulas_peranswersubmit';
} else {
$class = 'qtype_formulas_singlesubmit';
}
return new $class();
}
I have also defined 3 renderer classes :
class qtype_formulas_base_renderer extends qtype_renderer
class qtype_formulas_singlesubmit_renderer extends qtype_formulas_base_renderer
class qtype_formulas_peranswersubmit_renderer extends qtype_formulas_base_renderer
each question defintion class return the appropriate renderer in it's get_renderer method
and the last one has also
public function make_behaviour(question_attempt $qa, $preferredbehaviour) {
if ($preferredbehaviour == 'adaptive') {
return question_engine::make_behaviour(
'adaptiveperanswersubmit', $qa, $preferredbehaviour);
}
return question_engine::make_archetypal_behaviour($preferredbehaviour, $qa);
}
Am I on the right way ? I am really not sure I fully understand QE2 !
For the moment I concentrate my efforts on the singlesubmit question definition and rendered (the easier !). So doing I don't have to look at writting the adaptiveperanswersubmit behaviour now. Will see later !
Things progress nicely, the question are displaying OK and I think grading is OK too. I have a lot of trouble with javascript (I am not good at it, and there is quite a lot in formulas qtype !)
I need also to redo bell and whistle (understand colors, feedback, feedback images, ...)
As you may guess I have some questions (of course i would probaly find the answers myself looking at the code and comments but as my students say "it's easier to ask you")
in clear_wrong_from_response method, do I need to unset wrong responses or set them to an empty string ? Looking at various existing question types don't provide a clear answer.
I am puzzled by classify_response and get_possible_responses. I don't think I can return anything meaningfull.
formulas questions have variables including random variables wich value may change for each attempt.
Of course the number of variants is not infinite (nothing really is in real life !) but it can be very big (a variable can be specified as been drawn in an interval range given by the form 'start:stop:step' and it will have a value equal to start + n * step for a random integer n such as start + n * step < stop. I think this prevent all analysis.
If I understand well this will prevent some reports for formulas questions ?
It is clear that radom guess score is 0 for formulas questions.