Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30700 Assignment 2.2: Added text_sorting function to tablelib

Allows oracle to sort by text (clob) columns (should be used sparingly).
  • Loading branch information...
commit eee49d735c8688e8741bb70d1f3ebb786e968723 1 parent e93213e
@damyon damyon authored
Showing with 16 additions and 2 deletions.
  1. +15 −2 lib/tablelib.php
  2. +1 −0  mod/assignment/lib.php
View
17 lib/tablelib.php
@@ -60,6 +60,7 @@ class flexible_table {
var $column_class = array();
var $column_suppress = array();
var $column_nosort = array('userpic');
+ private $column_textsort = array();
var $setup = false;
var $sess = NULL;
var $baseurl = NULL;
@@ -226,6 +227,14 @@ function sortable($bool, $defaultcolumn = NULL, $defaultorder = SORT_ASC) {
}
/**
+ * Use text sorting functions for this column (required for text columns with Oracle).
+ * @param string column name
+ */
+ function text_sorting($column) {
+ $this->column_textsort[] = $column;
+ }
+
+ /**
* Do not sort using this column
* @param string column name
*/
@@ -520,10 +529,14 @@ public static function get_sort_for_table($uniqueid) {
* @param array $cols column name => SORT_ASC or SORT_DESC
* @return SQL fragment that can be used in an ORDER BY clause.
*/
- public static function construct_order_by($cols) {
+ public static function construct_order_by($cols, $textsortcols=array()) {
+ global $DB;
$bits = array();
foreach ($cols as $column => $order) {
+ if (in_array($column, $textsortcols)) {
+ $column = $DB->sql_order_by_text($column);
+ }
if ($order == SORT_ASC) {
$bits[] = $column . ' ASC';
} else {
@@ -538,7 +551,7 @@ public static function construct_order_by($cols) {
* @return SQL fragment that can be used in an ORDER BY clause.
*/
public function get_sql_sort() {
- return self::construct_order_by($this->get_sort_columns());
+ return self::construct_order_by($this->get_sort_columns(), $this->column_textsort);
}
/**
View
1  mod/assignment/lib.php
@@ -1373,6 +1373,7 @@ function display_submissions($message='') {
$table->no_sorting('finalgrade');
$table->no_sorting('outcome');
+ $table->text_sorting('submissioncomment');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
Please sign in to comment.
Something went wrong with that request. Please try again.