} 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)); if (!$asid) { $asid = $workshop->add_allocation($example, $USER->id, 0); } if ($asid == workshop::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', 'workshop'));
$edit = ($editable and $edit); $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; } elseif (is_null($submission->id) and $cansubmit) { // ok you can go } else { print_error('nopermissions', 'error', $workshop->view_url(), 'view or create submission'); } if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed($USER->id)) { require_sesskey(); $assessmentid = $workshop->add_allocation($submission, $USER->id); redirect($workshop->assess_url($assessmentid)); } if ($edit) { require_once dirname(__FILE__) . '/submission_form.php'; $maxfiles = $workshop->nattachments; $maxbytes = $workshop->maxbytes; $contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $workshop->context, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL); $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'return_types' => FILE_INTERNAL); $submission = file_prepare_standard_editor($submission, 'content', $contentopts, $workshop->context, 'mod_workshop', 'submission_content', $submission->id); $submission = file_prepare_standard_filemanager($submission, 'attachment', $attachmentopts, $workshop->context, 'mod_workshop', 'submission_attachment', $submission->id); $mform = new workshop_submission_form($PAGE->url, array('current' => $submission, 'workshop' => $workshop, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts)); if ($mform->is_cancelled()) { redirect($workshop->view_url()); } elseif ($cansubmit and $formdata = $mform->get_data()) { if ($formdata->example == 0) {
$failures[$reviewee] = "error::No group for name $reviewee"; continue; } $group = $groups[$reviewee]; if (empty($submissions_by_group[$group->id])) { $failures[$reviewee] = "error::No submission for $reviewee"; continue; } $submission = $submissions_by_group[$group->id]; foreach($reviewers as $i) { $i = trim($i); if (empty($i)) continue; if (!empty($users[$i])) { $res = $workshop->add_allocation($submission, $users[$i]->id); } else { $failures[$i] = "error::No user for username $i"; } } } } $SESSION->workshop_upload_messages = $failures; } $url = new moodle_url('/mod/workshop/allocation.php', array('cmid' => $cm->id, 'method' => 'manual')); redirect($url);