Problems adding images to quizzes

Problems adding images to quizzes

by Robert Fransen -
Number of replies: 36

We have a fairly recent install of Moodle 2.x being used by a subset of teachers who are transitioning to it from our older Moodle 1.9.x server.

An issue has just come up regarding adding images to quizzes. This is reported from one of our power users.

"We cannot add images to quizzes or labels. We copy and paste images into our quiz questions or for a label and we end up getting a 500 server error and have to log off and log back on in order to get Moodle to work.  Whenever we try to open these in a quiz it again locks up moodle. If we take out the picture it works fine. We have tried several pictures. It worked in Moodle 1.9. An example would be a matching question.  Match the image to the term.  When we add that question (with the images) the quiz will not work."

The error message that appears in the browser after trying to trying to preview the quiz is:

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.

The specs on the server are as follows:

Moodle software 2.2

Windows Server 2008 R2

IIS 7.5

PHP 5.3.8

MySQL 5.0.8

I've looked through some log files to try and find errors but I'm not sure where exactly to look.

Thanks in advance for any assistance.

Average of ratings: Useful (1)
In reply to Robert Fransen

Re: Problems adding images to quizzes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The phrase "copy and paste images into our quiz questions or for a label" worries me.

I wonder what they are doing. They should be adding images using the add image icon in the HTML editor.

In reply to Tim Hunt

Re: Problems adding images to quizzes

by Robert Fransen -

I think that is what they are doing and just used the incorrect terminology. I created a quiz myself and added an image the way you describe and get the same results, the 500 Internal Server error message.

In reply to Robert Fransen

Re: Problems adding images to quizzes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What is the URL of the page that gives the 500 error?

In reply to Tim Hunt

Re: Problems adding images to quizzes

by Robert Fransen -
In reply to Robert Fransen

Re: Problems adding images to quizzes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well, the next thing is to turn on Debugging to see if you can get a real error message.

In reply to Tim Hunt

Re: Problems adding images to quizzes

by Robert Fransen -

and I got this one when trying to edit the quiz:

https://moodle.server.org/mod/quiz/edit.php?cmid=3086

In reply to Robert Fransen

Re: Problems adding images to quizzes

by Rui Pimenta -

Hi!

I have the same issue.

In reply to Rui Pimenta

Re: Problems adding images to quizzes

by Jean-Michel Védrine -

Hello Rui,

The problem reported by Robert was that some of his teachers were using an incorrect way to add images to quiz questions in Moodle 2.0/2.1: they were using copy and paste rather than using the icon with the tree in the editor (this one : tree icon).

So if your problem is the same, you just need to add images using the right method and the problem will be gone.

If your problem is somewhat different, try to explain it better not forgetting to give the Moodle version you use, so that we can try to help you.

In reply to Jean-Michel Védrine

Re: Problems adding images to quizzes

by Robert Fransen -

Hello Jean Michel,

Actually, the teachers were posting images correctly, but the terminology they used to describe the situation was incorrect. They are not copy-pasting but using the proper import image button.

I have created quizzes myself, imported images and recreated the problem. If I remove the images, the quiz works fine. If I add an image to any quiz, it fails in the same manner.

It is still an issue that I have not been able to resolve, although I'm starting to think it has something to do with some PHP settings and interaction with IIS7.5

We are currently using Moodle 2.2. Full server specs are in the original post.

Thanks for any insight to resolve this issue.

Cheers,

Robert Fransen

In reply to Robert Fransen

Re: Problems adding images to quizzes

by Catherine Berry -

I am also having this problem. Images work fine in labels or web pages. If I add an image to a quiz question, then trying to preview the question gives an error 500 and I then have to close down my browser and re-open it.

We are using Moodle 2.1.2 on a Windows server.

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Catherine Berry -

Can I just ask - is anyone able to add images to quiz questions and then preview without problems?

If so, as Robert has suggested, it may be to do with php settings or something else in our particular Moodle installations.

If no-one can do it, then presumbly it's a Moodle problem and needs to be added to the Tracker.

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Mauno Korpelainen -

At least I can add images to my quizzes and preview them...

There might be a couple of reasons for non visible images - the most obvious reason is always the method how you add images.

Usually a good start to solve problematic cases is to check the actual url of the (missing) image that you should see with image plugin in editor (and the preview of this image in editor plugin preview window if it exists). Or you can in most cases check the path (url) of "missing/corrupted images" with mouse right click - Properties in IE (it shows in a place holder for such images).

But the reason might be as well an issue like http://tracker.moodle.org/browse/MDL-29559 - particularly if you copy and paste code from the same site, with images in source. Or use drag and drop methods etc.

Or maybe some new IIS (url) / Windows server bug ???

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Catherine Berry -

Thanks for the replies - but all the tracker entries mentioned are about images not appearing. This isn't the problem. The image appears fine when I am editing the question. Once I've saved it and then press Preview, a new window appears and it tries for some time to load the page before giving an error 500. I then close the window but I cannot then do anything more on the site - it is completely locked up and I have to close it down and open it up again.

It seems to be exactly the same problem described by Robert in the opening post - except that he mentions labels as well. I'm not having any problem with images in labels or pages, only quiz questions. I've looked at the path for the image (when editing the question) and it seems to be exactly the same as it would be in a label.

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Mauno Korpelainen -

Ah - right - and then the problem is not at all in paths of images but your site configuration and requirements of moodle 2.2...

Moodle 2.2 requires: PHP 5.3.2, MySQL 5.0.25 or Postgres 8.3 or MSSQL 2005 or Oracle 10.2 and in his post Robert says they have MySQL 5.0.8

So my quess is that some code of preview.php in quiz or in some lib file is not compatible with the version of mysql and therefore the window / browser hangs.

If debugging is set to ALL from administration menu ( Site Administration > Development > Debugging ) you might also get some helpful debug messages like Tim mentioned...

The 500 error most likely means here that something unexpected happens on your server and on Apache sites you might find the answer right a way from server logs of apache ( ...apache/logs/error.log ) - on IIS sites you may need to search first where server logs are saved, some docs like http://portal.smartertools.com/KB/a154/where-are-my-iis-log-files-stored.aspx (or google) might help to find IIS server logs.

Average of ratings: Useful (1)
In reply to Catherine Berry

Re: Problems adding images to quizzes

by Mauno Korpelainen -

Catherine,

can you check the version of your database - http://download.moodle.org/ tells that all moodle 2.X require MySQL 5.0.25 if you use MySQL...

But you had similar 500 errors in http://moodle.org/mod/forum/discuss.php?d=191666 too and that could mean something else on servers side too - for example if your host is GoDaddy or memory_limit in php.ini is too low etc.

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Catherine Berry -

Thank you for the suggestions Mauno.

I already have debugging on and nothing is showing up.

We are on Moodle 2.1 with php 5.3.8 and mysql 5.0.51.

The errors we were getting before appear to have been due to some php libraries not supported in php 5.3 - this is now fixed.

I've asked my colleague who is our expert on php installations, mysql etc to take a look at this thread - she will probably be able to track down the problem with the help of your suggestions.

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Mauno Korpelainen -

Those 500 errors are common errors that can be hard to explain - some suggestions in http://docs.moodle.org/22/en/Errors_FAQ#Error:_.22500:Internal_Server_Error.22 too.

GoDaddy as a host is a very special case with several custom problems (settings) and on other sites the most common php settings causing different issues are memory_limit, max_execution_time, max_input_time, post_max_size and upload_max_size... and for example memory_limit should be larger than post_max_size and the value of post_max_size must be larger than upload_max_filesize... (These settings affect mostly file upload)

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Jean-Michel Védrine -

Hello Catherine,

Unfortunately the fact that "The image appears fine when I am editing the question" don't means that images urls are fines ! In moodle 2.x urls in the html editor and outside of this editor are not the sames.

It would really be interesting to look in your database to see if these questions are correctly saved but unfortunately this require some knowledge of how images and files are managed in Moodle to see if everything is saved correctly.

You posted your php and msql versions but you didn't give your server configuration. Are you using the same version of IIS that Robert mentionned ? If yes I strongly suspect a setting in IIS to be the root of the problem, .

it would be interesting to know if there are others users with an IIS server where questions with an image preview is working fine and compare IIS settings.

All my servers are on linux+apache and I never had this problem.

In reply to Jean-Michel Védrine

Re: Problems adding images to quizzes

by Catherine Berry -

Thanks Jean-Michel.

IIS version is 7.0.

I had a look in the database. I am trying to give the format of the link in the database, but every time I post it gets changed and turned into a link! It involves PLUGINFILE with two @ on each side. Not sure if that helps at all... I also had a look at a label which contains an image and that used the same format.

I know nothing about IIS settings but my colleague is having a look.

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Mauno Korpelainen -

Most likely this is caused by settings of IIS.

I suspect a same kind of issue that Rob explained in http://moodle.org/mod/forum/discuss.php?d=160142#p750737

and the first thing to check might be to check if "Verify normalization" is checked in IIS HTTP policy (could be unchecked).

Verify

See http://technet.microsoft.com/en-us/library/bb794802.aspx for more details: "... Note that while we recommend that you use the Verify Normalization function, it may also block legitimate requests that contain a %. "

Moodle takes care of url encoding/decoding in file requests so unchecking "Verify normalization" should not cause any security issues.

Moodle 2 is using  @ @ PLUGINFILE @ @  with the moodle 2 file system so it is not causing the issue.

EDIT: By the way I just remembered that also algebra filter is using double @:s - I have never used algebra filter on my sites (also some old versions of asciimath fallback scripts used double @:s) but you could also check that algebra filter is not enabled in site administation > plugins > filters > manage filters to be sure that there is no conflict between @ @ PLUGINFILE @ @ code and algebra filter...

You could also try adding some external image like

Image

to quiz to test if the same thing happens with all images, not just images added with editor plugin (file system of moodle).

Average of ratings: Useful (4)
In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Mauno Korpelainen -

h t t p : / / moodle.org/theme/moodleofficial/pix/community.gif

( the link was changed to image here but any external image could be used... )

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Catherine Berry -

Thanks Mauno!

It was the algebra filter!! I turned it off and now the images are fine and there are no crashes. As you said, it must be a conflict with the double @'s.

I don't think I will ever need the algebra filter, as I am using all your wonderful maths plugins instead - but maybe it's something that needs to be addressed, for those who do need the algebra filter.

Many thanks for your help.

In reply to Catherine Berry

Re: Problems adding images to quizzes

by Mauno Korpelainen -

I did in fact suggest a couple of times (1-2 years ago) that algebra filter could have been removed from core moodle 2 and those few sites still using it could have downloaded algebra filter from modules and plugins database. But some old moodle sites are still using algebra filter and want to keep it in core. I keep algebra filter always disabled.

I think I saw some time ago an issue about algebra filter notation crashing the site elsewhere so I could try to check if the reason is in the content (syntax or conflicts with @ @ PLUGINFILE @ @ / double @:s ) and create a new tracker issue if necessary - or for example in some missing files of perl, permissions etc that algebra filter is using as a "subfilter" of tex filter.

Average of ratings: Useful (2)
In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Mauno Korpelainen -

It looks like preview.php really tries to use algebra filter for @ @ PLUGINFILE @ @ and the result depends on environment. On my Debian test server (linux) images were opened ok but when I enable algebra filter in a local PC (Windows 7) that can't use file filter/algebra/algebra2tex.pl the browser tries to open this file every time it finds a image from local file system ( with @ @ PLUGINFILE @ @ ) and the preview.php window stays blank (loading).

So the next guess is that on Windows servers that do not have proper perl files or permissions to execute file filter/algebra/algebra2tex.pl and/or filter/tex/mimetex.exe (algebra filter is using this file from tex filter folder) IIS does not know what to do with "algebra filter notations". In my tests this did not happen on all pages but it happened in preview.php if algebra filter was enabled.

The best option to prevent such issues is for now to disable algebra filter (particularly if it is not at all functional) and in the long run Tim might try find out why this page is using algebra filter for @ @ PLUGINFILE @ @ wink (he knows best the logic of filters and quizzes...)

 

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Robert Fransen -

Brilliant!

It looks like turning off the algebra filter has solved my problem as well. Much thanks for looking into this. You've made my day.

Cheers,

R. Fransen

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Rui Pimenta -

Hi!

Thanks for your help, turning off the algebra filter solved my problem too. one more question, if someone can help me. Where can i find the option to unchek the verify normalization? I'am using w2008 r2 and iis 7.5, i think its different that's why i can find it.

Thanks. Best regards.

In reply to Rui Pimenta

Re: Problems adding images to quizzes

by Mauno Korpelainen -

I am not at all sure but I suppose each Microsoft product version has some kind of Help files or search option - for example in ISA 2004 that tab might have been found with guide

1) Open the Microsoft ISA Server Management, expand the ISA Server computer node, and click Firewall Policy.

2) In the details pane, right-click the rule and select Configure HTTP.

3) A "Configure HTTP policy for rule" window should appear...

On the other hand if your problem was caused by algebra filter trying to render @ @ PLUGINFILE @ @ code (used by file system of moodle 2) in preview.php it may not be necessary to find Verify normalization check box at all... wink

Similar conflicts might occur in some 3rd party activities etc as well if algebra filter is using double @:s as delimiters and if local file system is using the same double @:s around PLUGINFILE path that is changed to correct paths elsewhere with some functions of moodle

 

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Jean-Michel Védrine -

Hello Tim and Mauno,

I am now convinced there is a bug in the question bank (tested with Moodle 2.1 but I think it should be the same with Moodle 2.2, not yet tested)

The problem is that on some page filters are called with texts that contain unrecoded urls (that is texts containning @ @ PLUGINFILE @ @ and similar urls)

You know I am unfamiliar with "modern" debugging tools, so to test that I replaced the filter/algebra/filter/php file with a fake one containing a filter_algebra class that just logged the strings it was operating on, but returned the string unchanged.

As I expected on several question bank and quiz pages string with unrecoded urls were in my log files.

For instance the problem can be seen on :

  • question/preview.php in all cases if for instance the question text contain an image or for a MC question if any answer contain an image
  • mod/quiz/edit.php if the question bank content is displayed

I will create an issue in the tracker.

 

Average of ratings: Useful (1)
In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Peter Kupfer -

I've basically been having problems with quizzes since we upgraded to 2.3.1+ in August and I am willing to bet it was the stinking algebra filter this whole time (sorry for the terse language). I have been having this same problem and have spent more hours than I care to count trying to diagnose why I keep getting 500 Server errors and why it wasn't a consistent issue.

Thanks for figuring this out. Perhaps the Algrbra filter should be removed now that we have the equartion editor.

Peter

In reply to Peter Kupfer

Re: Problems adding images to quizzes

by Jean-Michel Védrine -

Hello,

This bug is now fixed. So if you upgrade to 2.3.2 even if you activate again the algebra filter everything should be fine.

Average of ratings: Useful (1)
In reply to Jean-Michel Védrine

Re: Problems adding images to quizzes

by Eric Eakin -

Hello,

We are running Moodle 2.23+ on mssql 2008 r2. Whenever I add images (not cutting and pasting) to quiz questions, it causes Moodle to time out. Any Help? Help is much appreciated!

 

Thanks

 

In reply to Eric Eakin

Re: Problems adding images to quizzes

by Jean-Michel Védrine -

Hello Eric,

All his thread is about people getting a server error 500. It was found that the culprit was the algebra filter.

If you really get a time out when you try to add an image, your problem seems different. Have you tried to activate Debugging to see if an error message is displayed ?

In reply to Mauno Korpelainen

Re: Problems adding images to quizzes

by Eugene Matusov -

Thanks A LOT, Mauno! On your advice, I disabled the Albegra filter and the Question Editing stopped hanging the server.