Moodle
  1. Moodle
  2. MDL-27394

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.

        Gliffy Diagrams

          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

              • Assignee:
                Tim Hunt
                Reporter:
                Tim Hunt
                Peer reviewer:
                Eloy Lafuente (stronk7)
                Integrator:
                Eloy Lafuente (stronk7)
                Tester:
                Eloy Lafuente (stronk7)
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: