Question bank page stuck on some question having image

Question bank page stuck on some question having image

by Azmat Ullah -
Number of replies: 8
Picture of Plugin developers
Hi, 

I notice question bank page having around 300 questions loading slow, and it stuck if question contains image (base64), then if we edit that question and just click on Save changes after that it started works! 

Moodle version 4.1.1 is using, It seems the image is on draft area of atto editor and due to some bug it's not displaying in question bank until we edit the question. 

It's not easy to do this process in different courses manullay. 
Average of ratings: -
In reply to Azmat Ullah

Re: Question bank page stuck on some question having image

by David Trelles -
We're having similar issue, base64 images are not showing when learning are taking the quiz in Chrome, only when editing quiz questions:



How it should look:



A

Any idea? We have so many complaints about this issue affecting thousands of users.

We're in Moodle 4.1.5

In reply to David Trelles

Re: Question bank page stuck on some question having image

by Eva Koperdakova -
Recently I have been reported the same issue.

Found such questions as well. Teacher/Administrator can see the picture when editing, linked as draft. When doing quiz attempt, there is no picture.
But it seems to me that only those that use links to already uploaded files or questions duplicates. (and questions banks of the restored courses from other sites as well).

Moodle 4.1.5 (updated from 3.9)
In reply to Azmat Ullah

Re: Question bank page stuck on some question having image

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
I may be mistaken, but I believe that nowadays and in the Moodle context, the Base64 format offers no advantage over more common formats such as PNG and JPEG. Moodle handles separate image files quite well and you should have no problems if you use PNG or JPEG files.

There are many applications (just Google "from Base64 to image") you can use to convert Base64 to images, e.g. CodeBeautify.org - Base64 to image converter➚.

Base64 is used in Moodle XML files, but once the questions are imported, the images they contain are automatically converted back into PNG or JPEG files, which Moodle handles very well. Moodle does the conversion automatically, you don't have to do anything.

So why do you have questions containing Base64 images in your question bank? Maybe, as you say, you just need to save them.

I would have to check further. Perhaps restored courses also contain Base64 images which are not save as separate files (PNG, JPEG) until they are saved...
In reply to Azmat Ullah

Re: Question bank page stuck on some question having image

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Note that if, for some reason, the images are in Base64 within your question, you can easily convert them. Here's how:

If you're using the Atto editor or the Plain text area editor and you see something like this in the source code (HTML) of the question: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABoA AAAFPCAMAAABanPxvAAAABGdBTUEAALGPC/xhBQAA ACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6m AAAF3CculE8AAACHFBMVEUAAAD///86MilPQziFcl+NeWXfv5/f v58AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAmJiYzMzN xcXFzc3O SkpKSkpIAAABXV1cvLy8AAAAAAAAAAABKSDLGwHcAAA AAAAAAAAAAAAAAAADJw3gAAAD/95k... (usually very long), saving the question will not change anything; the image will remain in Base64.

However, if you're using the TinyMCE editor to edit the question, any Base64 image will automatically be converted to a separate PNG or JPEG file as soon as you edit the question, and it will remain as such afterwards. What you will want to see in the source code (HTML) of the question is something like this: <img src="https://yourdomain/draftfile.php/5/user/draft/611357397/blobid0%20%281%29.png">.

So, simply edit and save your questions as required, with the TinyMCE editor, and that should solve your problem.

In reply to Dominique Bauer

Re: Question bank page stuck on some question having image

by Abdel Kawy Abdel Hady -
The issue is that I have more than 500 question I edited using TestGen and imported into Moodle using XML. Is there any possible way to convert those images in database or any setting in Moodle that allow base64 images since it was working before the latest upgrade?
In reply to Abdel Kawy Abdel Hady

Re: Question bank page stuck on some question having image

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

any possible way to convert those images in database

I'm not sure. If a developer joins this conversation, they might be able to provide you with an answer. Editing questions with TinyMCE automatically converts them. It might take you a few hours to edit 500 questions, but it could be a zen activity.

any setting in Moodle that allow base64 images

Moodle accepts base64 images by default, so no additional settings are necessary.

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Question bank page stuck on some question having image

by QST Support -
I believe the issue is in TestGen, the images are saved in the question in base64 format.
In TestGens case, you could have the same image written again and again if you used it in other questions and exported those questions.

In Moodle XML in the question there is only the link to the image, the image is located in it's own xml tags.
Moodle then reads that the image is in it's own xml tags (base64 encoded) and decodes the image and adds that image to it's database and writes the correct link to the image into the question.
If the image is used in multiple questions, there is only one image referenced and created because it has the same name.
Much better way of doing things.

In a sense this is a kind of simple way to add images to questions from TestGens point of view cause then they do not have to provide you with a real file manager, because the editor looks after the images.
When TestGen questions are shown to a user and they have the same image in many questions on the same page, that image is sent over in each question again and again.
So TestGen is kinda heavy on the bandwith.
With Moodle it's just a link and it's only fetched once.

I believe Test Gen also exports in QTI format, try our Free Account that does Free conversions at qstonline.org
Import your questions in QTi, view them and export as Moodle XML and import into Moodle.
If that does not work, because I am beginning to think that TestGen may be doing the same thing in QTI instead of following the standard,
then send us a few questions with the images in them to qstsupport@shaw.ca and we will alter our converter to allow for this and it will give you good Moodle XML.
We support TestGen conversion, but did not know they were sticking the base64 images into the questions. Ugly way to move questions around.

Not a difficult fix from our perspective and it makes our converter handier for more people.
Our converter works very quickly but only accepts 30mb file at a time. Also, it does not like images over 100kb so you may want to reduce the size of some of your images.
I imagine you can do this in the TestGen editor.
We have a cap because anything over that does not produce a much better image on the web.
We accept multiple choice one answer, multiple choice many answers, True/False, Short answer and essay. 
We will work with you until it works correctly.
Average of ratings: Useful (1)