Index: upgrade.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/assignment/db/upgrade.php,v retrieving revision 1.25 diff -u -r1.25 upgrade.php --- upgrade.php 16 Aug 2008 19:49:44 -0000 1.25 +++ upgrade.php 18 Aug 2008 15:24:55 -0000 @@ -46,12 +46,13 @@ $sqlfrom = "FROM {assignment_submissions} s JOIN {assignment} a ON a.id = s.assignment JOIN {modules} m ON m.name = 'assignment' - JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = a.id) - ORDER BY a.course, s.assignment"; + JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = a.id)"; + + $sqlorder = "ORDER BY a.course, s.assignment"; $count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom"); - if ($rs = $DB->get_recordset_sql("SELECT s.id, s.userid, s.teacher, s.assignment, a.course, cm.id AS cmid $sqlfrom")) { + if ($rs = $DB->get_recordset_sql("SELECT s.id, s.userid, s.teacher, s.assignment, a.course, cm.id AS cmid $sqlfrom $sqlorder")) { $pbar = new progress_bar('migrateassignmentfiles', 500, true);