Hi All,
I have to import question items to question bank, which contains image in question text.
I am trying to use <img> tag but it is not adding image to question text.
Any help will be much appreciated.
Thanks.
To add to Tims answer, images are stored as base64, so you will need a way of saving your image to that format.
Hi,
Tim and Marcus Thanks for your reply.
Export of question with image in Moodle XML format takes following form:
<img src="filename.jpg" alt="" width="1024" height="768">
<file name="Penguins.jpg" path="/" encoding="base64">
---encoding of image file
</file>
I am trying to add image from my local machine with base64 encoding
<text><![CDATA[Write as essay on given image.<p><img src="komal.jpg"><br></p>]]></text>
<file name="komal.jpg" path="/" encoding="base64">
---encoding of image file
</file>
But it is displaying image as undefined image(See attachment).Could you please tell me where I am going wrong?
Thanks.
Which version of Moodle are you using? If you paste images into the question fields and then view the HTML you should see something like <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAC/CAIAAAD2LUA0AAAgAElEQVR4nHS995Mj15XnWz bla bla bla
Which is how base64 appears.
I had a quick look around for tools that would export as Base64 and didn't find any.
This has nothing to do with pasting.
The most likely explanation is that the base64 enocding of the image was wrong. Look at the code in question/format/xml to see how Moodle generates it and decodes it.
Anyway, you are going to have to do some debugging to work out why your file is not importing correctly. At what point along the process of parsing the file, then saving the data in the database, is the image getting lost?