Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.1, 2.3.3, 3.0.6, 3.1.2, 3.2
-
MySQL, Microsoft SQL
-
MOODLE_21_STABLE, MOODLE_23_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
-
MOODLE_30_STABLE, MOODLE_31_STABLE
-
wip-
MDL-29332-master-3 -
-
-
3.2 Sprint 5
Description
If you enter a formula in a quiz question using the calculated question format, where the formula uses variables with the same characters in different cases, then a quiz using that question will be broken.
See http://moodle.org/mod/forum/discuss.php?d=183056 for other details...
For example, a question using "
{I}+
{i}" can be created and added to a quiz, but it will break the quiz. It will generate the error:
Debug info: Duplicate entry '2-_var_I' for key 'mdl_quesattestepdata_attna_uix'
|
INSERT INTO mdl_question_attempt_step_data (attemptstepid,name,value) VALUES(?,?,?)
|
[array (
|
0 => 2,
|
1 => '_var_I',
|
2 => '7.5',
|
)]
|
Stack trace:
|
|
* line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
|
* line 878 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
|
* line 920 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
|
* line 130 of /question/engine/datalib.php: call to mysqli_native_moodle_database->insert_record()
|
* line 98 of /question/engine/datalib.php: call to question_engine_data_mapper->insert_question_attempt_step()
|
* line 71 of /question/engine/datalib.php: call to question_engine_data_mapper->insert_question_attempt()
|
* line 93 of /question/engine/lib.php: call to question_engine_data_mapper->insert_questions_usage_by_activity()
|
* line 198 of /mod/quiz/startattempt.php: call to question_engine::save_questions_usage_by_activity()
|
The problem in 2.1 is that databases can use case insensitive tables, and the question engine creates a unique index on the variable names that are used in the calculations. In fact the standard Moodle setup instructions recommend using the "utf8_unicode_ci" collation for MySQL which is case insensitive (see http://docs.moodle.org/20/en/Create_Moodle_site_database). And the question documentation does not point out that variables need to be unique, ignoring case.
In versions prior to 2.1, this problem was not as apparent, as the unique index did not exist. There still must have been problem, but they didn't seem to be as noticeable. Now, in 2.1, the quizzes break completely. This will be a major problem for users upgrading from earlier versions of Moodle that have these types of questions defined.
I'm not sure how to solve this. Perhaps a case-sensitive case in the code? Or something that makes sure that the tables are not case insensitive?
Attachments
Issue Links
- has been marked as being related by
-
MDL-33655 MySQL case insensitivity breaks get_directory_files
-
- Closed
-
-
MDL-36208 Case-insensitive collations in the database cause problems and should be changed to case-sensitive
-
- Open
-
-
MDL-64688 Add support to case-insensitive searches regardless of the database engine
-
- Open
-