All short answers are marked wrong (gradedwrong)

All short answers are marked wrong (gradedwrong)

by Duane Habecker -
Number of replies: 11

Recently, every short answer question is now being graded as wrong even though the answer is correct. Even when viewing the problem, clicking "Fill in correct responses", and then "Submit and finish" the question is graded as wrong. We are currently using Moodle 2.4.1+ (Build: 20130125). I went to demo.moodle.net and was unable to reproduce this error.

All other question types appear to working just fine.

Any thoughts?

screen shot of gradedwrong

Attachment Short answer gradedwrong.png
Average of ratings: -
In reply to Duane Habecker

Re: All short answers are marked wrong (gradedwrong)

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 are the settings for this question?

In reply to Tim Hunt

Re: All short answers are marked wrong (gradedwrong)

by Duane Habecker -

Wow! Thank you for your quick reply! Once again the vibrant Moodle community amazes me!

If I understand your question, the settings are...

case

answer

penalty

 

For what it is worth, all our short answer questions behaved properly until our recent Moodle upgrade to 2.4.

Thank you so much for your valuable insight!

 

In reply to Duane Habecker

Re: All short answers are marked wrong (gradedwrong)

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Duane,

1.- Was the upgrade to Moodle 2.4 (from which version) the factor which caused your current problem?

2.- Are you having the problem both on SA questions create before the upgrade and on new SA questions created after the upgrade?

3.- Probably not related, but it seems strange to set the Penalty for each incorrect try to 100%. That rather seems to discourage students from re-trying.sad

4.- Try setting DEBUG mode ON, just in case some error messages might get displayed.

Joseph

In reply to Joseph Rézeau

Re: All short answers are marked wrong (gradedwrong)

by Duane Habecker -

Thanks for the debugging suggestions. Here's what we've done:

1. Yes, we think this is specific to our upgrade to 2.4

2. Yes, short answer questions made last year and questions made today are displaying the same behavior.

3. We get the same behavior regardless of the penalty.

4. With DEBUG on, we receive the following error:

Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110 Warning: preg_match(): Empty regular expression in /Library/WebServer/Documents/moodle/question/type/shortanswer/question.php on line 110

There are other errors as well, but they seem to be theme related (Zebra). I can post them if you think it will help.

Thanks for helping a drowning swimmer in deep water!

Duane

In reply to Duane Habecker

Re: All short answers are marked wrong (gradedwrong)

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

Thanks for that error message. That seems to point to the fix for MDL-37157 as the cause of the error. (https://github.com/moodle/moodle/commit/5a449045c220bc4581372456d04ca47b01b4489e.)

However, it is not clear to me why that change causes these symptoms.

Ah, the docs here: http://php.net/manual/en/normalizer.normalize.php say "Return Values The normalized string or NULL if an error occurred."

Presumably an error is occurring, but PHP is not telling us what the error is. It is just silently failing sad

Can you try deleting those 2 lines that were added in compare_string_with_wildcard?

Bonus marks if you can work out what the error is in normalizer_normalize.

In reply to Tim Hunt

Re: All short answers are marked wrong (gradedwrong)

by Duane Habecker -

Tim and Joseph!

Many thanks to the both of you for helping this non-programmer get our short answer questions working again! Here is what I did, thanks to Joseph's debugging suggestion and Tim's most recent post...

On question/type/shortanswer/question.php we commented out lines 105 - 108

+ if (function_exists('normalizer_normalize')) {
+ $regexp = normalizer_normalize($regexp, Normalizer::FORM_C);
+ $string = normalizer_normalize($string, Normalizer::FORM_C);
+ }

Our short answer questions have returned to behaving as expected.

Thank you so much for your efforts and for being willing to help out a stranger.

Grateful,

Duane

In reply to Duane Habecker

Re: All short answers are marked wrong (gradedwrong)

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

Thanks for the feedback. I created MDL-37746 for this.

In reply to Tim Hunt

Re: All short answers are marked wrong (gradedwrong)

by Jamie Pratt -
I checked the pmatch contrib question type code and it shouldn't be affected by this issue, it is already checking for the existence of the Normalizer before using it.
In reply to Jamie Pratt

Re: All short answers are marked wrong (gradedwrong)

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 shortanswer code also checks that Normalizer is present. The issue is that even when it exists, it may return null "When an error occurs". The only clue we have is that, according to one of the user comments on the docs, input that is not UTF-8 may be an error, but it is not clear.

In reply to Duane Habecker

Re: All short answers are marked wrong (gradedwrong)

by Didier Raboud -

Hi Duane,

can you check that php5-intl is correctly installed on your system? (On what OS / Linux distribution is your Moodle setup?). You also need libicu installed. So what are the versions of libicu and php5-intl ?

Also, could you try the patch mentionned in https://tracker.moodle.org/browse/MDL-37746#comment-200122 ? That is, in question/type/shortanswer/question.php, replace the lines with normalizer_normalize with the following block:

if (function_exists('normalizer_normalize')) {
$regexp_norm = normalizer_normalize($regexp, Normalizer::FORM_C);
$string_norm = normalizer_normalize($string, Normalizer::FORM_C);
$string = is_null($string_norm) ? $string : $string_norm;
$regexp = is_null($regexp_norm) ? $regexp : $regexp_norm;
}

Thanks in advance, cheers, 

OdyX

In reply to Didier Raboud

Re: All short answers are marked wrong (gradedwrong)

by Duane Habecker -

Hi Didier,

We're using php 5.3.8 on Mac OS X Server 10.6.

intl version 1.1.0

ICU version 4.6.1

The code from the patch seems to be working.

Thanks again,

Duane