Multichoice responses and images

Multichoice responses and images

by William Mair -
Number of replies: 2

Hi,

I am using Moodle 2.7.1+ (Build 20140724) and trying to adapt the multichoice answers and responses to include images as part of the output.

I've changed the locallib.php file to add, the maxfiles, add the setType and removed the default (or rather commented out) - as per below example change for the response - which allows me to add the editor in and allows me to select images and add them with no problem.

--------------------

$this->_form->addElement('editor', 'response_editor['.$count.']', $label, array('rows'=>'4', 'columns'=>'80'), array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES));

$this->_form->setType('response_editor['.$count.']', PARAM_RAW);

//$this->_form->setDefault('response_editor['.$count.']', array('text'=>'', 'format'=>FORMAT_MOODLE));

--------------------

However, when I preview the question as an Admin or undertake the question as a student, the image shows as a brokenlink.php file (thanks to Inspect Element) rather than the correct draftfile.php which is in the editor and the database answer table.

I'm assuming I've missed something off editing the code to displaying the image, but not sure what I am missing.

Could anyone help/assist me?

Thanks

Average of ratings: -
In reply to William Mair

Re: Multichoice responses and images

by Jean-Michel Védrine -

Hello,

Unfortunately it's not so simple to add images support, believe me.

It would be a lot easier for you to upgrade to Moodle 2.8 (best choice: 2.8.5+) because this is the version where I have added this improvement. And you will get all the other fixes and enhancements I have done on the Moodle 2.8 branch (and guess what 2.9 will be even better smile )

But if you can't upgrade to 2.8, and are decided to spend some time working on it, I see no reason the changes I have made in Moodle 2.8 to make this working could not be backported to Moodle 2.7

If you know how to use git look for the commit with MDL-32870 in the comment text and use this commit.