Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.8.2
-
None
-
Debian etch, but using moodle 1.8.2 from upstream moodle.org (not Debian package), other info on http://kno.ii.uni.wroc.pl/phpinfo.php if needed
-
MySQL
-
MOODLE_18_STABLE
-
MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
Description
When looking at the list of assignments (by "View ... submitted assignments"), press "status" to sort by status. All records disappear.
Reason: SQL query generated to sort by status is invalid. It looks like
SELECT u.id, u.firstname, u.lastname, u.picture, s.id AS submissionid, s.grade, s.submissioncomment, s.timemodified, s.timemarked FROM mdl_user u LEFT JOIN mdl_assignment_submissions s ON u.id = s.userid AND s.assignment = 1 WHERE u.id IN (3,4) ORDER BY status ASC, lastname ASC
So "status" is used in "order by", but it doesn't exist in returned set. It worked in moodle 1.6.x. I have a strong feeling that this bug is caused by incorrectly fixing #8164 ("MS SQL cannot return Boolean data type in query results, any code using this returns no results when using Sql 2005"). Looks like when fixing #8164, status field was removed from SQL clauses, but it's still needed there for sorting.
To fix this on our moodle installation we used the attached patch. Basically, it adds again the SQL code that was already in moodle 1.6. So careless applying it will probably break #8164 again... The patch is only safe for people that run on database that can handle such SQL, like MySQL. The correct solution is probably to make a better fix to #8164.