(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
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.
has a non-specific relationship to
MDL-43946Problems with upgrade_grade_item_fix_sortorder()
Closed
is a regression caused by
MDL-43306Backup introduces duplicate gradeitem sortorders when restoring