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

Improve efficiency of grade item sortorder fixing

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.4, 2.6.1
    • 2.5.5, 2.6.2
    • Backup, Gradebook
    • MOODLE_25_STABLE, MOODLE_26_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE
    • Hide

      (Copied from MDL-43306)

      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
      (Copied from MDL-43306 ) 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

    Description

      As found in MDL-41062, and fixed in MDL-43946, the SQL for sortorder fixing provide duplicate records (sometimes a lot of them). This ticket is to bring the same fix into the restore code sortorder fix.

      Attachments

        Issue Links

          Activity

            People

              emerrill Eric Merrill
              emerrill Eric Merrill
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Sam Hemelryk Sam Hemelryk
              David Monllaó David Monllaó
              Adrian Greeve, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Mar/14