$example->authorid = $USER->id; $example->example = 1; } $canmanage = has_capability('mod/workshop:manageexamples', $workshop->context); $canassess = has_capability('mod/workshop:peerassess', $workshop->context); $refasid = $DB->get_field('workshop_assessments', 'id', array('submissionid' => $example->id, 'weight' => 1)); if ($example->id and ($canmanage or $workshop->assessing_examples_allowed() and $canassess)) { // ok you can go } elseif (is_null($example->id) and $canmanage) { // ok you can go } else { print_error('nopermissions', 'error', $workshop->view_url(), 'view or manage example submission'); } if ($id and $delete and $confirm and $canmanage) { require_sesskey(); $workshop->delete_submission($example); redirect($workshop->view_url()); } if ($id and $assess and $canmanage) { // reference assessment of an example is the assessment with the weight = 1. There should be just one // such assessment require_sesskey(); if (!$refasid) { $refasid = $workshop->add_allocation($example, $USER->id, 1); } redirect($workshop->exassess_url($refasid)); } if ($id and $assess and $canassess) { // training assessment of an example is the assessment with the weight = 0 require_sesskey(); $asid = $DB->get_field('workshop_assessments', 'id', array('submissionid' => $example->id, 'weight' => 0, 'reviewerid' => $USER->id));
break; } } } $edit = ($editable and $edit); if (!$candeleteall and $ownsubmission and $editable) { // Only allow the student to delete their own submission if it's still editable and hasn't been assessed. if (count($workshop->get_assessments_of_submission($submission->id)) > 0) { $deletable = false; } else { $deletable = true; } } if ($submission->id and $delete and $confirm and $deletable) { require_sesskey(); $workshop->delete_submission($submission); // Event information. $params = array('context' => $workshop->context, 'courseid' => $workshop->course->id, 'relateduserid' => $submission->authorid, 'other' => array('submissiontitle' => $submission->title)); $params['objectid'] = $submission->id; $event = \mod_workshop\event\submission_deleted::create($params); $event->add_record_snapshot('workshop', $workshoprecord); $event->trigger(); redirect($workshop->view_url()); } $seenaspublished = false; // is the submission seen as a published submission? if ($submission->id and ($ownsubmission or $canviewall or $isreviewer)) { // ok you can go } elseif ($submission->id and $ispublished) { // ok you can go $seenaspublished = true;