Skip to content

Commit

Permalink
Merge branch 'MDL-30700-22' of git://github.com/damyon/moodle into MO…
Browse files Browse the repository at this point in the history
…ODLE_22_STABLE
  • Loading branch information
stronk7 committed Dec 11, 2012
2 parents f69dece + eee49d7 commit e6e5a4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/tablelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -225,6 +226,14 @@ function sortable($bool, $defaultcolumn = NULL, $defaultorder = SORT_ASC) {
$this->sort_default_order = $defaultorder;
}

/**
* 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
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
}

/**
Expand Down
1 change: 1 addition & 0 deletions mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e6e5a4d

Please sign in to comment.