mirror of
https://github.com/moodle/moodle.git
synced 2025-02-15 21:36:58 +01:00
Workshop: fixed checking of examples assessment before own submission
This commit is contained in:
parent
792fd768da
commit
514d8c2269
@ -86,6 +86,8 @@ $string['evaluationmethod_help'] = 'The grading evaluation method determines how
|
||||
$string['example'] = 'Example submission';
|
||||
$string['exampleadd'] = 'Add example submission';
|
||||
$string['exampleassess'] = 'Assess example submission';
|
||||
$string['exampleassesstask'] = 'Assess examples';
|
||||
$string['exampleassesstaskdetails'] = 'expected: {$a->expected}<br />assessed: {$a->assessed}';
|
||||
$string['exampleassessments'] = 'Example submissions to assess';
|
||||
$string['examplecomparing'] = 'Comparing assessments of example submission';
|
||||
$string['exampledelete'] = 'Delete example';
|
||||
|
@ -1004,7 +1004,9 @@ class workshop {
|
||||
/**
|
||||
* Are reviewers allowed to create/edit their assessments of the example submissions?
|
||||
*
|
||||
* Note this does not check other conditions like the number of already submitted examples etc.
|
||||
* Returns null if example submissions are not enabled in this workshop. Otherwise returns
|
||||
* true or false. Note this does not check other conditions like the number of already
|
||||
* assessed examples, examples mode etc.
|
||||
*
|
||||
* @return null|bool
|
||||
*/
|
||||
@ -1794,6 +1796,28 @@ class workshop_user_plan implements renderable {
|
||||
}
|
||||
$phase->tasks['instructreviewers'] = $task;
|
||||
}
|
||||
if ($this->workshop->useexamples and $this->workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION
|
||||
and has_capability('mod/workshop:submit', $workshop->context, $userid, false)
|
||||
and !has_capability('mod/workshop:manageexamples', $this->workshop->context, $userid)) {
|
||||
$task = new stdclass();
|
||||
$task->title = get_string('exampleassesstask', 'workshop');
|
||||
$examples = $workshop->get_examples_for_reviewer($userid);
|
||||
$a = new stdclass();
|
||||
$a->expected = count($examples);
|
||||
$a->assessed = 0;
|
||||
foreach ($examples as $exampleid => $example) {
|
||||
if (!is_null($example->grade)) {
|
||||
$a->assessed++;
|
||||
}
|
||||
}
|
||||
$task->details = get_string('exampleassesstaskdetails', 'workshop', $a);
|
||||
if ($a->assessed == $a->expected) {
|
||||
$task->completed = true;
|
||||
} elseif ($this->workshop->phase >= workshop::PHASE_ASSESSMENT) {
|
||||
$task->completed = false;
|
||||
}
|
||||
$phase->tasks['examples'] = $task;
|
||||
}
|
||||
if (has_capability('mod/workshop:submit', $this->workshop->context, $userid, false)) {
|
||||
$task = new stdclass();
|
||||
$task->title = get_string('tasksubmit', 'workshop');
|
||||
|
@ -60,8 +60,19 @@ $cansubmit = has_capability('mod/workshop:submit', $workshop->context);
|
||||
$canallocate = has_capability('mod/workshop:allocate', $workshop->context);
|
||||
$canoverride = (($workshop->phase == workshop::PHASE_EVALUATION) and has_capability('mod/workshop:overridegrades', $workshop->context));
|
||||
$isreviewer = $DB->record_exists('workshop_assessments', array('submissionid' => $submission->id, 'reviewerid' => $USER->id));
|
||||
$editable = $workshop->submitting_allowed();
|
||||
$edit = ($editable and $edit);
|
||||
$editable = $cansubmit and $ownsubmission and $workshop->submitting_allowed();
|
||||
if ($editable and $workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_SUBMISSION
|
||||
and !has_capability('mod/workshop:manageexamples', $workshop->context)) {
|
||||
// check that all required examples have been assessed by the user
|
||||
$examples = $workshop->get_examples_for_reviewer($USER->id);
|
||||
foreach ($examples as $exampleid => $example) {
|
||||
if (is_null($example->grade)) {
|
||||
$editable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$edit = ($editable and $edit);
|
||||
|
||||
if ($submission->id and ($ownsubmission or $canviewall or $isreviewer)) {
|
||||
// ok you can go
|
||||
@ -77,7 +88,7 @@ if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop-
|
||||
redirect($workshop->assess_url($assessmentid));
|
||||
}
|
||||
|
||||
if ($edit and $ownsubmission) {
|
||||
if ($edit) {
|
||||
require_once(dirname(__FILE__).'/submission_form.php');
|
||||
|
||||
$maxfiles = $workshop->nattachments;
|
||||
@ -161,7 +172,7 @@ echo $OUTPUT->heading(format_string($workshop->name), 2);
|
||||
|
||||
// if in edit mode, display the form to edit the submission
|
||||
|
||||
if ($edit and $ownsubmission) {
|
||||
if ($edit) {
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
@ -176,7 +187,7 @@ if ($submission->id) {
|
||||
echo $OUTPUT->box(get_string('noyoursubmission', 'workshop'));
|
||||
}
|
||||
|
||||
if ($ownsubmission and $editable) {
|
||||
if ($editable) {
|
||||
$url = new moodle_url($PAGE->url, array('edit' => 'on', 'id' => $submission->id));
|
||||
echo $OUTPUT->single_button($url, get_string('editsubmission', 'workshop'), 'get');
|
||||
}
|
||||
|
@ -101,27 +101,26 @@ case workshop::PHASE_SUBMISSION:
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
|
||||
$examplesdone = true;
|
||||
$examplesdone = !$workshop->useexamples;
|
||||
if ($workshop->assessing_examples_allowed()
|
||||
and has_capability('mod/workshop:submit', $workshop->context)
|
||||
and ! has_capability('mod/workshop:manageexamples', $workshop->context)) {
|
||||
$examples = $workshop->get_examples_for_reviewer($USER->id);
|
||||
$total = count($examples);
|
||||
$done = 0;
|
||||
$todo = 0;
|
||||
$left = 0;
|
||||
// make sure the current user has all examples allocated
|
||||
foreach ($examples as $exampleid => $example) {
|
||||
if (is_null($example->assessmentid)) {
|
||||
$examples[$exampleid]->assessmentid = $workshop->add_allocation($example, $USER->id, 0);
|
||||
}
|
||||
if (is_null($example->grade)) {
|
||||
$todo++;
|
||||
} else {
|
||||
$done++;
|
||||
$left++;
|
||||
}
|
||||
}
|
||||
if ($todo > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) {
|
||||
if ($left > 0 and $workshop->examplesmode != workshop::EXAMPLES_VOLUNTARY) {
|
||||
$examplesdone = false;
|
||||
} else {
|
||||
$examplesdone = true;
|
||||
}
|
||||
print_collapsible_region_start('', 'workshop-viewlet-examples', get_string('exampleassessments', 'workshop'));
|
||||
echo $output->box_start('generalbox exampleassessments');
|
||||
|
Loading…
x
Reference in New Issue
Block a user