$isreviewer = ($USER->id == $assessment->reviewerid); $isauthor = ($USER->id == $submission->authorid); if ($isreviewer or $isauthor or ($canviewallassessments and $canviewallsubmissions)) { // such a user can continue } else { print_error('nopermissions', 'error', $workshop->view_url(), 'view this assessment'); } if ($isauthor and !$isreviewer and !$canviewallassessments and $workshop->phase != workshop::PHASE_CLOSED) { // authors can see assessments of their work at the end of workshop only print_error('nopermissions', 'error', $workshop->view_url(), 'view assessment of own work before workshop is closed'); } // only the reviewer is allowed to modify the assessment if ($isreviewer and $workshop->assessing_allowed($USER->id)) { $assessmenteditable = true; } else { $assessmenteditable = false; } // check that all required examples have been assessed by the user if ($assessmenteditable and $workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT and !has_capability('mod/workshop:manageexamples', $workshop->context)) { // the reviewer must have submitted their own submission $reviewersubmission = $workshop->get_submission_by_author($assessment->reviewerid); if (!$reviewersubmission) { // no money, no love $assessmenteditable = false; echo $output->header(); echo $output->heading(get_string('exampleneedsubmission', 'workshop'), 2);
} } $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());
$canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context); $cansetassessmentweight = has_capability('mod/workshop:allocate', $workshop->context); $canoverridegrades = has_capability('mod/workshop:overridegrades', $workshop->context); $isreviewer = $USER->id == $assessment->reviewerid; $isauthor = $USER->id == $submission->authorid; if ($isreviewer or $isauthor or $canviewallassessments and $canviewallsubmissions) { // such a user can continue } else { print_error('nopermissions', 'error', $workshop->view_url(), 'view this assessment'); } if ($isauthor and !$isreviewer and !$canviewallassessments and $workshop->phase != workshop::PHASE_CLOSED) { // authors can see assessments of their work at the end of workshop only print_error('nopermissions', 'error', $workshop->view_url(), 'view assessment of own work before workshop is closed'); } // only the reviewer is allowed to modify the assessment if ($isreviewer and $workshop->assessing_allowed()) { $assessmenteditable = true; } else { $assessmenteditable = false; } // check that all required examples have been assessed by the user if ($assessmenteditable and $workshop->useexamples and $workshop->examplesmode == workshop::EXAMPLES_BEFORE_ASSESSMENT and !has_capability('mod/workshop:manageexamples', $workshop->context)) { // the reviewer must have submitted their own submission $reviewersubmission = $workshop->get_submission_by_author($assessment->reviewerid); if (!$reviewersubmission) { // no money, no love $assessmenteditable = false; echo $output->header(); echo $output->heading(get_string('exampleneedsubmission', 'workshop'), 2); echo $output->footer(); exit;