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

Backup introduces duplicate gradeitem sortorders when restoring

    Details

    • Testing Instructions:
      Hide

      Setup:

      1. Create COURSE1 with default settings
      2. Add an assignment 'Assign 1' with default settings
      3. Create COURSE2 with default settings
      4. Add an assignment 'Assign 2' with default settings
      5. VERIFY: Examine the database and ensure the grade items exist, and both have the same sort order in different courses. e.g:

        SELECT id, itemname, courseid, sortorder 
        FROM mdl_grade_items 
        WHERE itemname LIKE 'Assign%'
        ORDER BY sortorder, courseid;
         
         id | itemname | courseid | sortorder
        ----+----------+----------+-----------
          4 | Assign 1 |        2 |         2
          2 | Assign 2 |        3 |         2
        

      Attempt to create duplicates through import:

      1. Go to COURSE1
      2. Select import, choose COURSE2
      3. Choose ONLY to import ASSIGNCOURSE2
      4. VERIFY: Examine the database and ensure the grade items that are imported don't have duplicate sortorder and courseids:

        SELECT id, itemname, courseid, sortorder 
        FROM mdl_grade_items 
        WHERE itemname like 'Assign%' 
        ORDER BY sortorder, courseid
        ;
         id | itemname | courseid | sortorder
        ----+----------+----------+-----------
          4 | Assign 1 |        2 |         2
          2 | Assign 2 |        3 |         2
          7 | Assign 2 |        2 |         4
        (3 rows)
        

      5. Go to Grades > Categories and items > Simple view and ensure that the grade items for the two assignments appear

      Backup/Restore test:

      1. Backup a course with numerous activities and grade items
      2. VERIFY: it restores without problem.

      phpunit:
      run phpunit lib/grade/tests/grade_item_test.php

      Show
      Setup: Create COURSE1 with default settings Add an assignment 'Assign 1' with default settings Create COURSE2 with default settings Add an assignment 'Assign 2' with default settings VERIFY: Examine the database and ensure the grade items exist, and both have the same sort order in different courses. e.g: SELECT id, itemname, courseid, sortorder FROM mdl_grade_items WHERE itemname LIKE 'Assign%' ORDER BY sortorder, courseid;   id | itemname | courseid | sortorder ----+----------+----------+----------- 4 | Assign 1 | 2 | 2 2 | Assign 2 | 3 | 2 Attempt to create duplicates through import: Go to COURSE1 Select import, choose COURSE2 Choose ONLY to import ASSIGNCOURSE2 VERIFY: Examine the database and ensure the grade items that are imported don't have duplicate sortorder and courseids: SELECT id, itemname, courseid, sortorder FROM mdl_grade_items WHERE itemname like 'Assign%' ORDER BY sortorder, courseid ; id | itemname | courseid | sortorder ----+----------+----------+----------- 4 | Assign 1 | 2 | 2 2 | Assign 2 | 3 | 2 7 | Assign 2 | 2 | 4 (3 rows) Go to Grades > Categories and items > Simple view and ensure that the grade items for the two assignments appear Backup/Restore test: Backup a course with numerous activities and grade items VERIFY: it restores without problem. phpunit: run phpunit lib/grade/tests/grade_item_test.php
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull Master Branch:
      wip-mdl-43306-m
    • Story Points (Obsolete):
      13
    • Sprint:
      BACKEND Sprint 9

      Description

      As discovered in MDL-41062, restore creates duplciate sort orders when restoring grade items. This can result in inconsistent sorting of items.

      Steps to reproduce:

      Setup:

      1. Create COURSE1 with default settings
      2. Add an assignment ASSIGNCOURSE1 with default settings
      3. Create COURSE2 with default settings
      4. Add an assignment ASSIGNCOURSE2 with default settings

      Create duplicates:

      1. Go to COURSE1
      2. Select import, choose COURSE2 and choose to import ASSIGNCOURSE2

      Examine the database and look at the sort order of the grade items. Duplicates should not be seen in the same course.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    10/Mar/14