Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31386

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: 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

      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.

        Gliffy Diagrams

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Mar/12