diff --git a/mod/workshop/assessment.php b/mod/workshop/assessment.php index 851f290456c..64cbf3fbf92 100644 --- a/mod/workshop/assessment.php +++ b/mod/workshop/assessment.php @@ -128,9 +128,15 @@ $strategy = $workshop->grading_strategy_instance(); if (is_null($assessment->grade) and !$assessmenteditable) { $mform = null; } else { + // Are there any other pending assessments to do but this one? + if ($assessmenteditable) { + $pending = $workshop->get_pending_assessments_by_reviewer($assessment->reviewerid, $assessment->id); + } else { + $pending = array(); + } // load the assessment form and process the submitted data eventually $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable, - array('editableweight' => $cansetassessmentweight)); + array('editableweight' => $cansetassessmentweight, 'pending' => !empty($pending))); $mform->set_data(array('weight' => $assessment->weight)); // other values are set by subplugins if ($mform->is_cancelled()) { redirect($workshop->view_url()); @@ -146,6 +152,13 @@ if (is_null($assessment->grade) and !$assessmenteditable) { } if (!is_null($rawgrade) and isset($data->saveandclose)) { redirect($workshop->view_url()); + } else if (!is_null($rawgrade) and isset($data->saveandshownext)) { + $next = reset($pending); + if (!empty($next)) { + redirect($workshop->assess_url($next->id)); + } else { + redirect($PAGE->url); // This should never happen but just in case... + } } else { // either it is not possible to calculate the $rawgrade // or the reviewer has chosen "Save and continue" diff --git a/mod/workshop/form/assessment_form.php b/mod/workshop/form/assessment_form.php index f6e5e032caf..43cd3fc83d3 100644 --- a/mod/workshop/form/assessment_form.php +++ b/mod/workshop/form/assessment_form.php @@ -77,8 +77,11 @@ class workshop_assessment_form extends moodleform { $buttonarray[] = $mform->createElement('cancel', 'backtoeditform', get_string('backtoeditform', 'workshop')); } if ($this->mode == 'assessment') { - $buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop')); + if (!empty($this->options['pending'])) { + $buttonarray[] = $mform->createElement('submit', 'saveandshownext', get_string('saveandshownext', 'workshop')); + } $buttonarray[] = $mform->createElement('submit', 'saveandclose', get_string('saveandclose', 'workshop')); + $buttonarray[] = $mform->createElement('submit', 'saveandcontinue', get_string('saveandcontinue', 'workshop')); $buttonarray[] = $mform->createElement('cancel'); } $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); diff --git a/mod/workshop/lang/en/workshop.php b/mod/workshop/lang/en/workshop.php index 5e1d5150180..25a4fbb3d4d 100644 --- a/mod/workshop/lang/en/workshop.php +++ b/mod/workshop/lang/en/workshop.php @@ -208,6 +208,7 @@ $string['recentsubmissions'] = 'Workshop submissions:'; $string['saveandclose'] = 'Save and close'; $string['saveandcontinue'] = 'Save and continue editing'; $string['saveandpreview'] = 'Save and preview'; +$string['saveandshownext'] = 'Save and show next'; $string['selfassessmentdisabled'] = 'Self-assessment disabled'; $string['showingperpage'] = 'Showing {$a} items per page'; $string['showingperpagechange'] = 'Change ...'; diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index a534f4c5cd4..3d7781938a6 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -1169,6 +1169,37 @@ class workshop { return $DB->get_records_sql($sql, $params); } + /** + * Get allocated assessments not graded yet by the given reviewer + * + * @see self::get_assessments_by_reviewer() + * @param int $reviewerid the reviewer id + * @param null|int|array $exclude optional assessment id (or list of them) to be excluded + * @return array + */ + public function get_pending_assessments_by_reviewer($reviewerid, $exclude = null) { + + $assessments = $this->get_assessments_by_reviewer($reviewerid); + + foreach ($assessments as $id => $assessment) { + if (!is_null($assessment->grade)) { + unset($assessments[$id]); + continue; + } + if (!empty($exclude)) { + if (is_array($exclude) and in_array($id, $exclude)) { + unset($assessments[$id]); + continue; + } else if ($id == $exclude) { + unset($assessments[$id]); + continue; + } + } + } + + return $assessments; + } + /** * Allocate a submission to a user for review *