diff --git a/lib/tablelib.php b/lib/tablelib.php
index 1915e7f7347..41df2e9e855 100644
--- a/lib/tablelib.php
+++ b/lib/tablelib.php
@@ -451,9 +451,13 @@ class flexible_table {
$this->sess->sortby = array_slice($this->sess->sortby, 0, $this->maxsortkeys);
}
- // If we didn't sort just now, then use the default sort order if one is defined and the column exists
- if (empty($this->sess->sortby) && !empty($this->sort_default_column)) {
- $this->sess->sortby = array ($this->sort_default_column => ($this->sort_default_order == SORT_DESC ? SORT_DESC : SORT_ASC));
+ // MDL-35375 - If a default order is defined and it is not in the current list of order by columns, add it at the end.
+ // This prevents results from being returned in a random order if the only order by column contains equal values.
+ if (!empty($this->sort_default_column)) {
+ if (!array_key_exists($this->sort_default_column, $this->sess->sortby)) {
+ $defaultsort = array($this->sort_default_column => $this->sort_default_order);
+ $this->sess->sortby = array_merge($this->sess->sortby, $defaultsort);
+ }
}
$ilast = optional_param($this->request[TABLE_VAR_ILAST], null, PARAM_RAW);
diff --git a/mod/assign/gradingtable.php b/mod/assign/gradingtable.php
index c77a8f9bee5..9a075955a65 100644
--- a/mod/assign/gradingtable.php
+++ b/mod/assign/gradingtable.php
@@ -162,8 +162,8 @@ class assign_grading_table extends table_sql implements renderable {
get_string('selectall') .
'"/>';
- // Edit links.
- $columns[] = 'edit';
+ // We have to call this column userid so we can use userid as a default sortable column.
+ $columns[] = 'userid';
$headers[] = get_string('edit');
}
@@ -281,8 +281,11 @@ class assign_grading_table extends table_sql implements renderable {
// set the columns
$this->define_columns($columns);
$this->define_headers($headers);
+ // We require at least one unique column for the sort.
+ $this->sortable(true, 'userid');
+ $this->no_sorting('recordid');
$this->no_sorting('finalgrade');
- $this->no_sorting('edit');
+ $this->no_sorting('userid');
$this->no_sorting('select');
$this->no_sorting('outcomes');
@@ -291,14 +294,17 @@ class assign_grading_table extends table_sql implements renderable {
$this->no_sorting('teamstatus');
}
+ $plugincolumnindex = 0;
foreach ($this->assignment->get_submission_plugins() as $plugin) {
if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) {
- $this->no_sorting('assignsubmission_' . $plugin->get_type());
+ $submissionpluginindex = 'plugin' . $plugincolumnindex++;
+ $this->no_sorting($submissionpluginindex);
}
}
foreach ($this->assignment->get_feedback_plugins() as $plugin) {
if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->has_user_summary()) {
- $this->no_sorting('assignfeedback_' . $plugin->get_type());
+ $feedbackpluginindex = 'plugin' . $plugincolumnindex++;
+ $this->no_sorting($feedbackpluginindex);
}
}
@@ -669,7 +675,7 @@ class assign_grading_table extends table_sql implements renderable {
* @param stdClass $row
* @return string
*/
- function col_edit(stdClass $row) {
+ function col_userid(stdClass $row) {
$edit = '';
if ($this->rownum < 0) {
$this->rownum = $this->currpage * $this->pagesize;
diff --git a/mod/assign/lang/en/assign.php b/mod/assign/lang/en/assign.php
index bc4cf8134aa..61d8624f936 100644
--- a/mod/assign/lang/en/assign.php
+++ b/mod/assign/lang/en/assign.php
@@ -309,6 +309,8 @@ $string['viewownsubmissionform'] = 'View own submit assignment page.';
$string['viewownsubmissionstatus'] = 'View own submission status page.';
$string['viewsubmissionforuser'] = 'View submission for user: {$a}';
$string['viewsubmission'] = 'View submission';
+$string['viewfull'] = 'View full';
+$string['viewsummary'] = 'View summary';
$string['viewsubmissiongradingtable'] = 'View submission grading table.';
$string['viewrevealidentitiesconfirm'] = 'View reveal student identities confirmation page.';
diff --git a/mod/assign/module.js b/mod/assign/module.js
index a1986b5f39b..3501563f354 100644
--- a/mod/assign/module.js
+++ b/mod/assign/module.js
@@ -86,7 +86,6 @@ M.mod_assign.init_grading_table = function(Y) {
} else {
confirmmessage = eval('M.str.assign.batchoperationconfirm' + operation.get('value'));
}
- console.log(confirmmessage);
if (!confirm(confirmmessage)) {
e.preventDefault();
}
@@ -151,3 +150,63 @@ M.mod_assign.init_grade_change = function(Y) {
});
}
};
+
+M.mod_assign.init_plugin_summary = function(Y, subtype, type, submissionid) {
+ suffix = subtype + '_' + type + '_' + submissionid;
+ classname = 'contract_' + suffix;
+ contract = Y.one('.' + classname);
+ if (contract) {
+ contract.on('click', function(e) {
+ img = e.target;
+ imgclasses = img.getAttribute('class').split(' ');
+ for (i = 0; i < imgclasses.length; i++) {
+ classname = imgclasses[i];
+ if (classname.indexOf('contract_') == 0) {
+ thissuffix = classname.substr(9);
+ }
+ }
+ fullclassname = 'full_' + thissuffix;
+ full = Y.one('.' + fullclassname);
+ if (full) {
+ full.hide(true);
+ }
+ summaryclassname = 'summary_' + thissuffix;
+ summary = Y.one('.' + summaryclassname);
+ if (summary) {
+ summary.show(true);
+ }
+ });
+ }
+ classname = 'expand_' + suffix;
+ expand = Y.one('.' + classname);
+
+ full = Y.one('.full_' + suffix);
+ if (full) {
+ full.hide();
+ full.toggleClass('hidefull');
+ }
+ if (expand) {
+ expand.on('click', function(e) {
+ img = e.target;
+ imgclasses = img.getAttribute('class').split(' ');
+ for (i = 0; i < imgclasses.length; i++) {
+ classname = imgclasses[i];
+ if (classname.indexOf('expand_') == 0) {
+ thissuffix = classname.substr(7);
+ }
+ }
+ summaryclassname = 'summary_' + thissuffix;
+ summary = Y.one('.' + summaryclassname);
+ if (summary) {
+ summary.hide(true);
+ }
+ fullclassname = 'full_' + thissuffix;
+ full = Y.one('.' + fullclassname);
+ if (full) {
+ full.show(true);
+ }
+ });
+ }
+
+
+}
diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php
index ff60f0cf114..94d596fd6fa 100644
--- a/mod/assign/renderer.php
+++ b/mod/assign/renderer.php
@@ -632,12 +632,28 @@ class mod_assign_renderer extends plugin_renderer_base {
$o = '';
if ($submissionplugin->view == assign_submission_plugin_submission::SUMMARY) {
- $icon = $this->output->pix_icon('t/preview', get_string('view' . substr($submissionplugin->plugin->get_subtype(), strlen('assign')), 'mod_assign'));
- $link = '';
$showviewlink = false;
$summary = $submissionplugin->plugin->view_summary($submissionplugin->submission, $showviewlink);
+
+ $classsuffix = $submissionplugin->plugin->get_subtype() . '_' . $submissionplugin->plugin->get_type() . '_' . $submissionplugin->submission->id;
+ $o .= $this->output->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix);
+
+ $link = '';
if ($showviewlink) {
- $link = $this->output->action_link(
+ $previewstr = get_string('viewsubmission', 'assign');
+ $icon = $this->output->pix_icon('t/preview', $previewstr);
+
+ $expandstr = get_string('viewfull', 'assign');
+ $classes = 'expandsummaryicon expand_' . $classsuffix;
+ $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, array('class'=>$classes));
+
+ $jsparams = array($submissionplugin->plugin->get_subtype(),
+ $submissionplugin->plugin->get_type(),
+ $submissionplugin->submission->id);
+ $this->page->requires->js_init_call('M.mod_assign.init_plugin_summary', $jsparams);
+
+ $link .= '';
$link .= $this->output->spacer(array('width'=>15));
}
$o .= $link . $summary;
+ $o .= $this->output->box_end();
+ if ($showviewlink) {
+ $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix);
+ $classes = 'expandsummaryicon contract_' . $classsuffix;
+ $o .= $this->output->pix_icon('t/switch_minus',
+ get_string('viewsummary', 'assign'),
+ null,
+ array('class'=>$classes));
+ $o .= $submissionplugin->plugin->view($submissionplugin->submission);
+ $o .= $this->output->box_end();
+ }
} else if ($submissionplugin->view == assign_submission_plugin_submission::FULL) {
$o .= $this->output->box_start('boxaligncenter submissionfull');
$o .= $submissionplugin->plugin->view($submissionplugin->submission);
@@ -699,12 +727,28 @@ class mod_assign_renderer extends plugin_renderer_base {
$o = '';
if ($feedbackplugin->view == assign_feedback_plugin_feedback::SUMMARY) {
- $icon = $this->output->pix_icon('t/preview', get_string('view' . substr($feedbackplugin->plugin->get_subtype(), strlen('assign')), 'mod_assign'));
- $link = '';
$showviewlink = false;
$summary = $feedbackplugin->plugin->view_summary($feedbackplugin->grade, $showviewlink);
+
+ $classsuffix = $feedbackplugin->plugin->get_subtype() . '_' . $feedbackplugin->plugin->get_type() . '_' . $feedbackplugin->grade->id;
+ $o .= $this->output->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix);
+
+ $link = '';
if ($showviewlink) {
- $link = $this->output->action_link(
+ $previewstr = get_string('viewfeedback', 'assign');
+ $icon = $this->output->pix_icon('t/preview', $previewstr);
+
+ $expandstr = get_string('viewfull', 'assign');
+ $classes = 'expandsummaryicon expand_' . $classsuffix;
+ $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, array('class'=>$classes));
+
+ $jsparams = array($feedbackplugin->plugin->get_subtype(),
+ $feedbackplugin->plugin->get_type(),
+ $feedbackplugin->grade->id);
+ $this->page->requires->js_init_call('M.mod_assign.init_plugin_summary', $jsparams);
+
+ $link .= '';
+
$link .= $this->output->spacer(array('width'=>15));
}
$o .= $link . $summary;
+ $o .= $this->output->box_end();
+ if ($showviewlink) {
+ $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix);
+ $classes = 'expandsummaryicon contract_' . $classsuffix;
+ $o .= $this->output->pix_icon('t/switch_minus',
+ get_string('viewsummary', 'assign'),
+ null,
+ array('class'=>$classes));
+ $o .= $feedbackplugin->plugin->view($feedbackplugin->grade);
+ $o .= $this->output->box_end();
+ }
} else if ($feedbackplugin->view == assign_feedback_plugin_feedback::FULL) {
$o .= $this->output->box_start('boxaligncenter feedbackfull');
$o .= $feedbackplugin->plugin->view($feedbackplugin->grade);
diff --git a/mod/assign/styles.css b/mod/assign/styles.css
index 65963bb718a..45fd7e421d5 100644
--- a/mod/assign/styles.css
+++ b/mod/assign/styles.css
@@ -134,3 +134,16 @@ div.earlysubmission {
td.submissioneditable {
color: red;
}
+
+.expandsummaryicon {
+ cursor: pointer;
+ display: none;
+}
+
+.jsenabled .expandsummaryicon {
+ display: inline;
+}
+
+.hidefull {
+ display: none;
+}