MDL-46718: Return user to last accessed page when quick grading

This commit is contained in:
Gregory Faller 2014-08-08 14:48:13 +09:30
parent 753493ae11
commit f707b67259
4 changed files with 16 additions and 3 deletions

View file

@ -2332,9 +2332,12 @@ class assign {
$this->show_intro(),
$this->get_course_module()->id,
get_string('quickgradingresult', 'assign')));
$lastpage = optional_param('lastpage', null, PARAM_INT);
$gradingresult = new assign_gradingmessage(get_string('quickgradingresult', 'assign'),
$message,
$this->get_course_module()->id);
$this->get_course_module()->id,
false,
$lastpage);
$o .= $this->get_renderer()->render($gradingresult);
$o .= $this->view_footer();
return $o;
@ -3093,7 +3096,10 @@ class assign {
if ($showquickgrading && $quickgrading) {
$gradingtable = new assign_grading_table($this, $perpage, $filter, 0, true);
$table = $this->get_renderer()->render($gradingtable);
$quickformparams = array('cm'=>$this->get_course_module()->id, 'gradingtable'=>$table);
$page = optional_param('page', null, PARAM_INT);
$quickformparams = array('cm' => $this->get_course_module()->id,
'gradingtable' => $table,
'page' => $page);
$quickgradingform = new mod_assign_quick_grading_form(null, $quickformparams);
$o .= $this->get_renderer()->render(new assign_form('quickgradingform', $quickgradingform));

View file

@ -51,6 +51,8 @@ class mod_assign_quick_grading_form extends moodleform {
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action', 'quickgrade');
$mform->setType('action', PARAM_ALPHA);
$mform->addElement('hidden', 'lastpage', $instance['page']);
$mform->setType('lastpage', PARAM_INT);
// Skip notifications option.
$mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));

View file

@ -74,12 +74,14 @@ class assign_gradingmessage implements renderable {
* @param string $message This is the message to display
* @param bool $gradingerror Set to true to display the message as an error.
* @param int $coursemoduleid
* @param int $page This is the current quick grading page
*/
public function __construct($heading, $message, $coursemoduleid, $gradingerror = false) {
public function __construct($heading, $message, $coursemoduleid, $gradingerror = false, $page = null) {
$this->heading = $heading;
$this->message = $message;
$this->coursemoduleid = $coursemoduleid;
$this->gradingerror = $gradingerror;
$this->page = $page;
}
}

View file

@ -91,6 +91,9 @@ class mod_assign_renderer extends plugin_renderer_base {
*/
public function render_assign_gradingmessage(assign_gradingmessage $result) {
$urlparams = array('id' => $result->coursemoduleid, 'action'=>'grading');
if (!empty($result->page)) {
$urlparams['page'] = $result->page;
}
$url = new moodle_url('/mod/assign/view.php', $urlparams);
$classes = $result->gradingerror ? 'notifyproblem' : 'notifysuccess';