Permalink
Browse files

MDL-33431: Allow in page toggling of full/summary of submissions/feed…

…back in assignment
  • Loading branch information...
1 parent f9e6212 commit 66d3fe3708d4a9a008895aa863f9d127b6d53f3e Damyon Wiese committed Sep 20, 2012
Showing with 138 additions and 7 deletions.
  1. +2 −0 mod/assign/lang/en/assign.php
  2. +60 −1 mod/assign/module.js
  3. +63 −6 mod/assign/renderer.php
  4. +13 −0 mod/assign/styles.css
@@ -309,6 +309,8 @@
$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.';
View
@@ -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);
+ }
+ });
+ }
+
+
+}
View
@@ -632,12 +632,28 @@ public function render_assign_submission_plugin_submission(assign_submission_plu
$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 .= '<noscript>';
+ $link .= $this->output->action_link(
new moodle_url('/mod/assign/view.php',
array('id' => $submissionplugin->coursemoduleid,
'sid'=>$submissionplugin->submission->id,
@@ -646,11 +662,23 @@ public function render_assign_submission_plugin_submission(assign_submission_plu
'returnaction'=>$submissionplugin->returnaction,
'returnparams'=>http_build_query($submissionplugin->returnparams))),
$icon);
+ $link .= '</noscript>';
$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 @@ public function render_assign_feedback_plugin_feedback(assign_feedback_plugin_fe
$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 .= '<noscript>';
+ $link .= $this->output->action_link(
new moodle_url('/mod/assign/view.php',
array('id' => $feedbackplugin->coursemoduleid,
'gid'=>$feedbackplugin->grade->id,
@@ -713,10 +757,23 @@ public function render_assign_feedback_plugin_feedback(assign_feedback_plugin_fe
'returnaction'=>$feedbackplugin->returnaction,
'returnparams'=>http_build_query($feedbackplugin->returnparams))),
$icon);
+ $link .= '</noscript>';
+
$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);
View
@@ -134,3 +134,16 @@ div.earlysubmission {
td.submissioneditable {
color: red;
}
+
+.expandsummaryicon {
+ cursor: pointer;
+ display: none;
+}
+
+.jsenabled .expandsummaryicon {
+ display: inline;
+}
+
+.hidefull {
+ display: none;
+}

0 comments on commit 66d3fe3

Please sign in to comment.