Missatges enviats per Joseph Rézeau

Imatge Core developers Imatge Plugin developers Imatge Testers Imatge Translators
OK, I had not noticed that function try_importing_using_qtypes( $data, $question=null, $extra=null ) in $qtype->$methodname( $data, $question, $this, $extra )) actually makes its own functions available to the plugin question type through the $this parameter. I had never come across this way of "sharing" functions yet. How different is it from a require_once call ?
By the way, what is the $extra parameter for?
Joseph
Imatge Core developers Imatge Plugin developers Imatge Testers Imatge Translators

Hi Howard,

I have started to play with the new import/export format for plugin question types in HEAD, with my REGEXP question type. So far I have implemented the export_to_xml method and am glad to report that it was quite easy to implement and that it does work fine! In file question/type/regexp/questiontype.php, inside class question_regexp_qtype extends default_questiontype {} I simply added the following:

 function export_to_xml( $question, $format, $extra=null ) {
 $expout = " <usehint>{$question->options->usehint}</usehint>\n ";
 foreach($question->options->answers as $answer) {
 $percent = 100 * $answer->fraction;
 $expout .= " <answer fraction=\"$percent\">\n";
 $expout .= $this->writetext( $answer->answer,3,false );
 $expout .= " <feedback>\n";
 $expout .= $this->writetext( $answer->feedback,4,false );
 $expout .= " </feedback>\n";
 $expout .= " </answer>\n";
 }
 return $expout;
 }

I also needed to copy from question/format/xml/format.php function writetext( $raw, $ilev=0, $short=true) {} because it seems I cannot link to that file from my own question type, but it's only a few lines.

I will now work on the import_from_xml method, and test backup/restore and then report here. I hope the recent changes by Jamie Pratt to the question bank will not interfere too much with your import/export methods. If you want to take a look at my REGEXP question type you can download it (version 1.8 is OK for 1.9/HEAD) from the plugins download here.

Many thanks for making these methods available to "plugin question types".

Joseph

Imatge Core developers Imatge Plugin developers Imatge Testers Imatge Translators
And what about the Questionnaire module? Although it is less "moodle-like" than Feedback it has recently been made much more user-friendly than it was, and it contains a number of useful question types, including the much-needed Likert scales, etc.
It would be a desirable goal to unify all those "survey, feedback, questionnaire, etc." modules into one unique serve-all purposes module, but in the meantime each of them serves its own purposes, so why not make life easier for moodlers by including them into core?
Joseph