1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-17 22:45:54 +02:00

Merge branch 'MDL-37806-workshop-next' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Damyon Wiese 2013-02-04 12:48:42 +08:00
commit c15cda6138
4 changed files with 50 additions and 2 deletions

@ -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"

@ -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);

@ -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 ...';

@ -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
*