Skip to content

Commit

Permalink
MDL-37806 Display 'Save and show next' button when assessing workshop…
Browse files Browse the repository at this point in the history
… submissions

The button is displayed only when there is a pending (that is not
assessed yet) submission to assess.

AMOS BEGIN
 CPY [savenext,mod_assign],[saveandshownext,mod_workshop]
AMOS END
  • Loading branch information
mudrd8mz committed Jan 31, 2013
1 parent 0001eea commit 1df3bc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
15 changes: 14 additions & 1 deletion mod/workshop/assessment.php
Expand Up @@ -128,9 +128,15 @@
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());
Expand All @@ -146,6 +152,13 @@
}
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"
Expand Down
5 changes: 4 additions & 1 deletion mod/workshop/form/assessment_form.php
Expand Up @@ -77,8 +77,11 @@ public function definition() {
$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);
Expand Down
1 change: 1 addition & 0 deletions mod/workshop/lang/en/workshop.php
Expand Up @@ -208,6 +208,7 @@
$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 ...';
Expand Down

0 comments on commit 1df3bc1

Please sign in to comment.