MDL-44832 Assign: Convert grading menu to a moodle action-menu

This is required because YUI broke something.
This commit is contained in:
Damyon Wiese 2014-03-28 09:18:01 +08:00
parent 3c87c0880e
commit e9ddbae9c0
3 changed files with 64 additions and 45 deletions

View File

@ -979,13 +979,18 @@ class assign_grading_table extends table_sql implements renderable {
'rownum'=>$this->rownum,
'action'=>'grade');
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$noimage = null;
if (!$row->grade) {
$description = get_string('grade');
} else {
$description = get_string('updategrade', 'assign');
}
$actions[$url->out(false)] = $description;
$actions['grade'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
$submissionsopen = $this->assignment->submissions_open($row->id);
$caneditsubmission = $this->assignment->can_edit_submission($row->id, $USER->id);
@ -1005,7 +1010,11 @@ class assign_grading_table extends table_sql implements renderable {
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('preventsubmissionsshort', 'assign');
$actions[$url->out(false)] = $description;
$actions['lock'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
} else {
$urlparams = array('id' => $this->assignment->get_course_module()->id,
'userid'=>$row->id,
@ -1014,7 +1023,11 @@ class assign_grading_table extends table_sql implements renderable {
'page'=>$this->currpage);
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('allowsubmissionsshort', 'assign');
$actions[$url->out(false)] = $description;
$actions['unlock'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
}
}
@ -1028,7 +1041,11 @@ class assign_grading_table extends table_sql implements renderable {
'page'=>$this->currpage);
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('grantextension', 'assign');
$actions[$url->out(false)] = $description;
$actions['grantextension'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
}
if ($submissionsopen &&
$USER->id != $row->id &&
@ -1040,7 +1057,11 @@ class assign_grading_table extends table_sql implements renderable {
'page'=>$this->currpage);
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('editsubmission', 'assign');
$actions[$url->out(false)] = $description;
$actions['editsubmission'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
}
}
if ($row->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED &&
@ -1052,7 +1073,11 @@ class assign_grading_table extends table_sql implements renderable {
'page'=>$this->currpage);
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('reverttodraftshort', 'assign');
$actions[$url->out(false)] = $description;
$actions['reverttodraft'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
}
if ($row->status == ASSIGN_SUBMISSION_STATUS_DRAFT &&
$this->assignment->get_instance()->submissiondrafts &&
@ -1066,7 +1091,11 @@ class assign_grading_table extends table_sql implements renderable {
'page'=>$this->currpage);
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('submitforgrading', 'assign');
$actions[$url->out(false)] = $description;
$actions['submitforgrading'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
}
$ismanual = $this->assignment->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL;
@ -1083,35 +1112,26 @@ class assign_grading_table extends table_sql implements renderable {
'page'=>$this->currpage);
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$description = get_string('addattempt', 'assign');
$actions[$url->out(false)] = $description;
$actions['addattempt'] = new action_menu_link_secondary(
$url,
$noimage,
$description
);
}
$edit .= $this->output->container_start(array('yui3-menu', 'actionmenu'), 'actionselect' . $row->id);
$edit .= $this->output->container_start(array('yui3-menu-content'));
$edit .= html_writer::start_tag('ul');
$edit .= html_writer::start_tag('li', array('class'=>'menuicon'));
$menuicon = $this->output->pix_icon('t/contextmenu', get_string('actions'));
$edit .= $this->output->action_link('#menu' . $row->id, $menuicon, null, array('class'=>'yui3-menu-label'));
$edit .= $this->output->container_start(array('yui3-menu', 'yui3-loading'), 'menu' . $row->id);
$edit .= $this->output->container_start(array('yui3-menu-content'));
$edit .= html_writer::start_tag('ul');
foreach ($actions as $url => $description) {
$edit .= html_writer::start_tag('li', array('class'=>'yui3-menuitem'));
$edit .= $this->output->action_link($url, $description, null, array('class'=>'yui3-menuitem-content'));
$edit .= html_writer::end_tag('li');
$menu = new action_menu();
$menu->set_owner_selector('.gradingtable-actionmenu');
$menu->set_alignment(action_menu::TL, action_menu::BL);
$menu->set_constraint('.gradingtable > .no-overflow');
$menu->set_menu_trigger(get_string('edit'));
foreach ($actions as $action) {
$menu->add($action);
}
$edit .= html_writer::end_tag('ul');
$edit .= $this->output->container_end();
$edit .= $this->output->container_end();
$edit .= html_writer::end_tag('li');
$edit .= html_writer::end_tag('ul');
$edit .= $this->output->container_end();
$edit .= $this->output->container_end();
// Prioritise the menu ahead of all other actions.
$menu->prioritise = true;
$edit .= $this->output->render($menu);
return $edit;
}

View File

@ -99,19 +99,6 @@ M.mod_assign.init_grading_table = function(Y) {
});
}
Y.use('node-menunav', function(Y) {
var menus = Y.all('.gradingtable .actionmenu');
menus.each(function(menu) {
Y.on("contentready", function() {
this.plug(Y.Plugin.NodeMenuNav, {autoSubmenuDisplay: true});
var submenus = this.all('.yui3-loading');
submenus.each(function (n) {
n.removeClass('yui3-loading');
});
}, "#" + menu.getAttribute('id'));
});
});
var quickgrade = Y.all('.gradingtable .quickgrade');
quickgrade.each(function(quick) {
quick.on('change', function(e) {

View File

@ -254,3 +254,15 @@ td.submissioneditable {
#page-mod-assign-view .mod-assign-history-panel .c0 {
width: 150px;
}
#page-mod-assign-view .gradingtable .moodle-actionmenu {
white-space: nowrap;
}
#page-mod-assign-view .gradingtable .moodle-actionmenu[data-enhanced].show .menu a {
padding-left: 12px;
padding-right: 12px;
}
#page-mod-assign-view .gradingtable .menu-action img {
display: none;
}