/**
* Use text sorting functions for this column (required for text columns with Oracle).
+ * Be warned that you cannot use this with column aliases. You can only do this
+ * with real columns. See MDL-40481 for an example.
* @param string column name
*/
function text_sorting($column) {
$stepdata = $this->lateststeps[$attempt->usageid][$slot];
- if (is_null($stepdata->$field)) {
+ if (property_exists($stepdata, $field . 'full')) {
+ $value = $stepdata->{$field . 'full'};
+ } else {
+ $value = $stepdata->$field;
+ }
+
+ if (is_null($value)) {
$summary = '-';
} else {
- $summary = trim($stepdata->$field);
+ $summary = trim($value);
}
if ($this->is_downloading() || $field != 'responsesummary') {
* @param string $alias the table alias for latest state information relating to that slot.
*/
protected function get_required_latest_state_fields($slot, $alias) {
- return "$alias.questionsummary AS question$slot,
- $alias.rightanswer AS right$slot,
- $alias.responsesummary AS response$slot";
+ global $DB;
+ $sortableresponse = $DB->sql_order_by_text("{$alias}.questionsummary");
+ if ($sortableresponse === "{$alias}.questionsummary") {
+ // Can just order by text columns. No complexity needed.
+ return "{$alias}.questionsummary AS question{$slot},
+ {$alias}.rightanswer AS right{$slot},
+ {$alias}.responsesummary AS response{$slot}";
+ } else {
+ // Work-around required.
+ return $DB->sql_order_by_text("{$alias}.questionsummary") . " AS question{$slot},
+ {$alias}.questionsummary AS question{$slot}full,
+ " . $DB->sql_order_by_text("{$alias}.rightanswer") . " AS right{$slot},
+ {$alias}.rightanswer AS right{$slot}full,
+ " . $DB->sql_order_by_text("{$alias}.responsesummary") . " AS response{$slot},
+ {$alias}.responsesummary AS response{$slot}full";
+ }
}
}