} elseif (is_null($example->id) and $canmanage) { // ok you can go } else { print_error('nopermissions', 'error', $teamwork->view_url(), 'view or manage example submission'); } if ($id and $delete and $confirm and $canmanage) { require_sesskey(); $teamwork->delete_submission($example); redirect($teamwork->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 = $teamwork->add_allocation($example, $USER->id, 1); } redirect($teamwork->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('teamwork_assessments', 'id', array('submissionid' => $example->id, 'weight' => 0, 'reviewerid' => $USER->id)); if (!$asid) { $asid = $teamwork->add_allocation($example, $USER->id, 0); } if ($asid == teamwork::ALLOCATION_EXISTS) { // the training assessment of the example was not found but the allocation already // exists. this probably means that the user is the author of the reference assessment. echo $output->header(); echo $output->box(get_string('assessmentreferenceconflict', 'teamwork'));