Moodle
  1. Moodle
  2. MDL-31386

Restoring a matched question in a lesson leads to answers being processed in incorrect order

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.4, 2.2.1, 2.3
    • Fix Version/s: 2.1.5, 2.2.2
    • Component/s: Backup, Lesson
    • Labels:
    • Testing Instructions:
      Hide

      Preparation

      • Create a new course
      • Create a new lesson within that course
      • Choose Edit
      • Create a new 'Question Page'
      • Choose 'Matching' as the type
      • Set some answers for each field

      Backup

      • Create a new backup of the course

      Restore

      • Restore into the new course
      • Confirm that the question definition is correct for the restored question
      Show
      Preparation Create a new course Create a new lesson within that course Choose Edit Create a new 'Question Page' Choose 'Matching' as the type Set some answers for each field Backup Create a new backup of the course Restore Restore into the new course Confirm that the question definition is correct for the restored question
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-31386-master-1
    • Rank:
      37903

      Description

      When using a matched answer question in a lesson, the fields (Correct Answer, Wrong Answer, Answer 1, Answer n) are determined by the order of the answers in the database. That's to say that when they're retrieved, they are sorted by id ascending. As a result you get:

      • id 0: Correct Answer: "Correct Answer text"
      • id 1: Wrong Answer: "Wrong Answer text"
      • id 2: Answer 1: "Answer 1 text"
      • id 3: Answer 2: "Answer 2 text"
      • id 4: Answer 3: "Answer 3 text"

      When backing up a course with a lesson, these are ordered n reverse:

      <answer id="5">
      </answer>
      <answer id="4">
      </answer>
      <answer id="3">
      </answer>
      <answer id="2">
      </answer>
      <answer id="1">
      </answer>
      

      As a result, when the restore takes place, the questions are taken out of order and reversed:

      • id 0: Correct Answer: "Answer 3 text"
      • id 1: Wrong Answer: "Answer 2 text"
      • id 2: Answer 1: "Answer 1 text"
      • id 3: Answer 2: "Wrong Answer text"
      • id 4: Answer 3: "Correct Answer text"

      And you end up with the

      I can't decide whether the issue lies with:

      • the backup process reversing the order of the answers; or
      • the restore process not ordering the answers by the id in the XML structure.

        Issue Links

          Activity

          Andrew Nicols created issue -
          Andrew Nicols made changes -
          Field Original Value New Value
          Description When using a matched answer question in a lesson, the fields (Correct Answer, Wrong Answer, Answer 1, Answer n) are determined by the order of the answers in the database. That's to say that when they're retrieved, they are sorted by id ascending. As a result you get:

          * id 0: Correct Answer
          * id 1: Wrong Answer
          * id 2: Answer 1
          * id n: Answer n

          When backing up a course with a lesson, these are ordered n reverse:
          {code}
          <answer id="5">
          </answer>
          <answer id="4">
          </answer>
          <answer id="3">
          </answer>
          <answer id="2">
          </answer>
          <answer id="1">
          </answer>
          {code}

          As a result, when the restore takes place, the questions are taken out of order and reversed.
          When using a matched answer question in a lesson, the fields (Correct Answer, Wrong Answer, Answer 1, Answer n) are determined by the order of the answers in the database. That's to say that when they're retrieved, they are sorted by id ascending. As a result you get:

          * id 0: Correct Answer
          * id 1: Wrong Answer
          * id 2: Answer 1
          * id n: Answer n

          When backing up a course with a lesson, these are ordered n reverse:
          {code}
          <answer id="5">
          </answer>
          <answer id="4">
          </answer>
          <answer id="3">
          </answer>
          <answer id="2">
          </answer>
          <answer id="1">
          </answer>
          {code}

          As a result, when the restore takes place, the questions are taken out of order and reversed.

          I can't decide whether the issue lies with:
          * the backup process reversing the order of the answers; or
          * the restore process not ordering the answers by the id in the XML structure.
          Andrew Nicols made changes -
          Description When using a matched answer question in a lesson, the fields (Correct Answer, Wrong Answer, Answer 1, Answer n) are determined by the order of the answers in the database. That's to say that when they're retrieved, they are sorted by id ascending. As a result you get:

          * id 0: Correct Answer
          * id 1: Wrong Answer
          * id 2: Answer 1
          * id n: Answer n

          When backing up a course with a lesson, these are ordered n reverse:
          {code}
          <answer id="5">
          </answer>
          <answer id="4">
          </answer>
          <answer id="3">
          </answer>
          <answer id="2">
          </answer>
          <answer id="1">
          </answer>
          {code}

          As a result, when the restore takes place, the questions are taken out of order and reversed.

          I can't decide whether the issue lies with:
          * the backup process reversing the order of the answers; or
          * the restore process not ordering the answers by the id in the XML structure.
          When using a matched answer question in a lesson, the fields (Correct Answer, Wrong Answer, Answer 1, Answer n) are determined by the order of the answers in the database. That's to say that when they're retrieved, they are sorted by id ascending. As a result you get:

          * id 0: Correct Answer: "Correct Answer text"
          * id 1: Wrong Answer: "Wrong Answer text"
          * id 2: Answer 1: "Answer 1 text"
          * id 3: Answer 2: "Answer 2 text"
          * id 4: Answer 3: "Answer 3 text"

          When backing up a course with a lesson, these are ordered n reverse:
          {code}
          <answer id="5">
          </answer>
          <answer id="4">
          </answer>
          <answer id="3">
          </answer>
          <answer id="2">
          </answer>
          <answer id="1">
          </answer>
          {code}

          As a result, when the restore takes place, the questions are taken out of order and reversed:

          * id 0: Correct Answer: "Answer 3 text"
          * id 1: Wrong Answer: "Answer 2 text"
          * id 2: Answer 1: "Answer 1 text"
          * id 3: Answer 2: "Wrong Answer text"
          * id 4: Answer 3: "Correct Answer text"

          And you end up with the

          I can't decide whether the issue lies with:
          * the backup process reversing the order of the answers; or
          * the restore process not ordering the answers by the id in the XML structure.
          Andrew Nicols made changes -
          Assignee moodle.com [ moodle.com ] Andrew Nicols [ dobedobedoh ]
          Andrew Nicols made changes -
          Status Open [ 1 ] Development in progress [ 3 ]
          Andrew Nicols made changes -
          Testing Instructions h2. Preparation
          * Create a new course
          * Create a new lesson within that course
          * Choose Edit
          * Create a new 'Question Page'
          * Choose 'Matching' as the type
          * Set some answers for each field

          h2. Backup
          * Create a new backup of the course

          h2. Restore
          * Restore into the new course
          * Confirm that the question definition is correct for the restored question
          Pull 2.2 Diff URL https://git.luns.net.uk/?p=moodle.git;a=commitdiff;h=a731d18ce51dd392ca0738420a5f55bb96fbb192
          Pull 2.2 Branch MDL-31386-master-1
          Pull from Repository git://git.luns.net.uk/moodle.git
          Labels patch
          Andrew Nicols made changes -
          Link This issue will be resolved by MDL-31390 [ MDL-31390 ]
          Andrew Nicols made changes -
          Andrew Nicols made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Andrew Nicols made changes -
          Priority Minor [ 4 ] Major [ 3 ]
          Affects Version/s 2.2.1 [ 11456 ]
          Affects Version/s 2.1.4 [ 11452 ]
          Affects Version/s 2.3 [ 10657 ]
          Michael de Raadt made changes -
          Fix Version/s STABLE backlog [ 10463 ]
          Labels patch patch triaged
          Component/s Lesson [ 10075 ]
          Adrian Greeve made changes -
          Peer reviewer abgreeve
          Adrian Greeve made changes -
          Original Estimate 0 minutes [ 0 ]
          Remaining Estimate 0 minutes [ 0 ]
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Adrian Greeve made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Tim Hunt made changes -
          Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
          Fix Version/s 2.1.5 [ 11553 ]
          Fix Version/s 2.2.2 [ 11552 ]
          Fix Version/s 2.3 [ 10657 ]
          Fix Version/s STABLE backlog [ 10463 ]
          Andrew Nicols made changes -
          Link This issue has been marked as being related by MDL-31589 [ MDL-31589 ]
          Eloy Lafuente (stronk7) made changes -
          Currently in integration Yes [ 10041 ]
          Sam Hemelryk made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator samhemelryk
          Sam Hemelryk made changes -
          Integrator samhemelryk stronk7
          Eloy Lafuente (stronk7) made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Affects Version/s 2.3 [ 10657 ]
          Fix Version/s 2.3 [ 10657 ]
          moodle.com made changes -
          Tester ankit_frenz
          Ankit Agarwal made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Ankit Agarwal made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          Eloy Lafuente (stronk7) made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes [ 10041 ]
          Eloy Lafuente (stronk7) made changes -
          Integration date 17/Feb/12
          Ashley Holman made changes -
          Link This issue is duplicated by MDL-34339 [ MDL-34339 ]

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: