Hello Susana,
I have implemented a slightly different solution :
the question/type/fileresponse/backup/moddle1/lib.php script implement the normal code to create the xml that would be needed for a 2.2 version of the fileresponse question (if there was one) :
class moodle1_qtype_fileresponse_handler extends moodle1_qtype_handler {
/**
* @return array
*/
public function get_question_subpaths() {
return array(
'FILERESPONSE'
);
}
/**
* Appends the fileresponse specific information to the question
*/
public function process_question(array $data, array $raw) {
// convert and write the answers first
if (isset($data['answers'])) {
$this->write_answers($data['answers'], $this->pluginname);
}
// convert and write the fileresponse options
$options = $data['fileresponse'][0];
$this->xmlwriter->begin_tag('fileresponse', array('id' => $this->converter->get_nextid()));
$this->xmlwriter->full_tag('maxbytes', $options['maxbytes']);
$this->xmlwriter->full_tag('essay', $options['essay']);
$this->xmlwriter->end_tag('fileresponse');
}
}
Then, in the question/type/fileresponse/backup/moodle2/restore_qtype_fileresponse_plugin.class.php script the protected function define_question_plugin_structure and
public function process_fileresponse($data) are totaly normal except the record in the question_fileresponse table is not really created
And the heart of the proces is in the protected function after_execute_question where I convert the fileresponse question to an essay question and create the needed record in the qtype_essay_options table :
protected function after_execute_question() {
global $DB;
$fileresponses = $DB->get_records_sql("
SELECT *
FROM {question} q
WHERE q.qtype = ?
", array('fileresponse'));
foreach ($fileresponses as $q) {
$defaultoptions = new stdClass();
$defaultoptions->questionid = $q->id;
$defaultoptions->responseformat = 'editor';
$defaultoptions->responsefieldlines = 15;
$defaultoptions->attachments = 1;
$defaultoptions->graderinfo = '';
$defaultoptions->graderinfoformat = FORMAT_HTML;
$DB->insert_record('qtype_essay_options', $defaultoptions);
$q->qtype = 'essay';
$DB->update_record('question', $q);
}
}
And good news is that it seems to works well : not only 1.9 backups including fileresponse questions are restored without errors or warnings but file responses questions are converted into essay questions.
Of course I have only tested it with small 1.9 backups including only few fileresponses questions but if you want give it a try, I would be happy to send it to you with short instructions to install it. Send me a private message with your mail adress.
WARNING : I have not really upgraded fileresponse question type to work in Moodle 2.1/2.2 !! The result of my work is a non fonctionnal fileresponse question type, the only features wich are working are
- installation of the plugin
- restoration of 1.9 backups
All other features wil produce various errors and inexpected results, so I suggest to
- install it
- restore 1.9 backups
- uninstall it
Because if your users try to create new fileresponse questions in Moodle 2.1/2.2 you will be in big trouble !!