Moodle

Moodle 2.0 backup and restore may randomise the order of multichoice/numerical/shortanswer answers

Details

  • Testing Instructions:
    Hide

    Create questions of each type, but particularly numerical (with units), shortanswer, multichoice, calculated*, multianswer. With shortanswer/numerical/calculated, make sure you add multiple answers with different feedback.

    Check that queries like select * from {question_answers}, select * from {question_numerical_units}, select * from {question_match_sub} acutally return the records in an arbitrary order. With a new/small/MySQL DB, they often come out in id order, and you will not see the problem.

    Backup your questions and restore them. (e.g. backup and restore course to a new course.)

    Without this patch, you will find that the answers/choices/subquestoins have been restored in a random order.

    With this patch, it works.

    Show
    Create questions of each type, but particularly numerical (with units), shortanswer, multichoice, calculated*, multianswer. With shortanswer/numerical/calculated, make sure you add multiple answers with different feedback. Check that queries like select * from {question_answers}, select * from {question_numerical_units}, select * from {question_match_sub} acutally return the records in an arbitrary order. With a new/small/MySQL DB, they often come out in id order, and you will not see the problem. Backup your questions and restore them. (e.g. backup and restore course to a new course.) Without this patch, you will find that the answers/choices/subquestoins have been restored in a random order. With this patch, it works.
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE
  • Pull from Repository:
  • Pull Master Branch:
    MDL-27394_master

Description

All the backup code is missing the critical ORDER BY id for question_answers, question_numerical_units and question_match_sub.

You often get away with that on MySQL (at least with MyISAM) but on you end up with your data in a random order.

Issue Links

Activity

Hide
Tim Hunt added a comment -

Please review. If it is OK, please merge to 2.0 and request integration.

Show
Tim Hunt added a comment - Please review. If it is OK, please merge to 2.0 and request integration.
Hide
Eloy Lafuente (stronk7) added a comment -

yes, looks great for me

Show
Eloy Lafuente (stronk7) added a comment - yes, looks great for me
Hide
Eloy Lafuente (stronk7) added a comment -

This has been integrated, thanks!
(and backported to 20_STABLE by cherry-picking)

Show
Eloy Lafuente (stronk7) added a comment - This has been integrated, thanks! (and backported to 20_STABLE by cherry-picking)
Hide
Eloy Lafuente (stronk7) added a comment -

Tests performed:

1) Perform some DB hackery to get some unordered results. Generated backup file with wrong order (old behavior) and, after restore checked that some questions (multianswer, shortanswer) were behaving incorrectly.
2) Apply the patch and, using the same hacked DB, generate one backup file, verifying visually that contents in the xml files are properly ordered.
3) Restore the backup files generated by 2) and verify that the bad behaviors found in 1) aren't happening anymore.

So, passed. Ciao

Show
Eloy Lafuente (stronk7) added a comment - Tests performed: 1) Perform some DB hackery to get some unordered results. Generated backup file with wrong order (old behavior) and, after restore checked that some questions (multianswer, shortanswer) were behaving incorrectly. 2) Apply the patch and, using the same hacked DB, generate one backup file, verifying visually that contents in the xml files are properly ordered. 3) Restore the backup files generated by 2) and verify that the bad behaviors found in 1) aren't happening anymore. So, passed. Ciao
Hide
Eloy Lafuente (stronk7) added a comment -

This is now part of Moodle upstream, you did it possible, thanks!

Show
Eloy Lafuente (stronk7) added a comment - This is now part of Moodle upstream, you did it possible, thanks!

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:
    Integration date: