Grade import with new grade items: items are in reverse order

Grade import with new grade items: items are in reverse order

by Jeff King -
Number of replies: 0
Hi,
I have a customer who imports grades from a CSV file which typically contain grade items that do not yet exist in Moodle. When they get imported, the questions (grade items) are sorted in reverse order.

For example in the CSV the header (first line) would be:
UserID, Question1, Question2, Question3

But once you do the import, it displays in Moodle as:
Question3, Question2, Question1
Does anyone know why this is? I traced through the code, and I see it inserts records into the grade_import_newitem table, and I guess at some point that gets put into grade_items table, but with the reverse sortorder that I want. I can't figure out how I could fix this in code, or if there is some other way to fix this behaviour.

Thanks!
-Jeff