$example->authorid = $USER->id; $example->example = 1; } $canmanage = has_capability('mod/workshopplus:manageexamples', $workshopplus->context); $canassess = has_capability('mod/workshopplus:peerassess', $workshopplus->context); $refasid = $DB->get_field('workshopplus_assessments', 'id', array('submissionid' => $example->id, 'weight' => 1)); if ($example->id and ($canmanage or $workshopplus->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', $workshopplus->view_url(), 'view or manage example submission'); } if ($id and $delete and $confirm and $canmanage) { require_sesskey(); $workshopplus->delete_submission($example); redirect($workshopplus->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 = $workshopplus->add_allocation($example, $USER->id, 1); } redirect($workshopplus->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('workshopplus_assessments', 'id', array('submissionid' => $example->id, 'weight' => 0, 'reviewerid' => $USER->id));