A problem with SQL and number of records

A problem with SQL and number of records

by David Mudrák -
Number of replies: 1
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi guys,

a colleague of mine is running into problems during course restoring. He is using latest stable 1.8.4+ installed by Windows installer package. He gets following errors at the moment when his Moodle tries to restore a quiz categories and questions:

SELECT * FROM mdl_question_answers WHERE question = '76' AND answer = 'repondez'(with limits 0, 100)

Found more than one record in get_record_sql !

Array
(
[183] => Array
(
[question] => 76
[answer] => repondez
[fraction] => 0
[feedback] => Pozor na pravopis!
)

[184] => Array
(
[question] => 76
[answer] => répondez
[fraction] => 1
[feedback] => správně
)
)


The very similar problem occur follows and these two repeat many many times.

I thing the problem might be in the similarity of the values in the column "answer". Compare SQL condition
answer = 'repondez'
with the found records containing both 'repondez' and 'répondez'. It is a quiz focused on Spanish spelling and only one of these answers is correct.
The very same situation comes with SQL query containing condition:
answer = 'reponds'
while apparently there are at least two records returned by SQL: one with "reponds" and the second with "réponds".

This looks like character set issue of MySQL server inside a Moodle Windows package. Has anybody here encountered this before? Thanks for any reply.

David
Average of ratings: -
In reply to David Mudrák

Re: A problem with SQL and number of records

by Richard Enison -
DM,

What you need is an accent-sensitive collation sequence. Problem is, according to web pages I have found all over the Internet (with several Google searches, after giving up on the MySQL manual), MySQL doesn't have a case-insensitive accent-sensitive collation. The best you can do is utf8_bin, which is totally sensitive. In particular, it is case-sensitive, but at least it is accent-sensitive.

RLE