Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: 1.9.4
-
Fix Version/s: None
-
Component/s: Assignment, Database SQL/XMLDB
-
Labels:None
-
Environment:Apache 2, PHP 5.2.8, RedHat Linux. MSSQL running on IIS for our DB server.
-
Database:Microsoft SQL
-
Difficulty:Moderate
-
Affected Branches:MOODLE_19_STABLE
Description
When users would try to sort assignment submissions by the Comment field, all of the assignment submissions would disappear. You have to actually logout and log back in again to get the assignments back.
The issue appears to be that MSSQL doesn't allow you to sort records using text or ntext columns – and since the submissioncomment column is ntext, the query fails.
What I've done is modified the flexible_table class in /lib/tablelib.php to have an additional variable, $column_properties, and method, column_properties, which allow you to store arbitrary metadata about columns. I then changed the flexible_table::get_sql_sort() method to check if a column had a property associated with it called 'type'. If a column has a 'type' property, and that property is set to 'text', then the generated $sortstring calls sql_order_by_text() on that column, to generate any DB-specific SQL necessary for sorting an ntext or text column.
I also modified /mod/assignment/lib.php to make use of the new flexible_table::column_properties() method so that the submissioncomment column has a 'type' property associated with it.
We've experienced this same issue trying to sort by "timemodified." We're running Moodle on Server 2003/IIS with a MSSQL backend. I'll give this fix a try and report back.