$grader = FALSE; if ($submissionid && $vpl->has_capability(VPL_GRADE_CAPABILITY)) { $subinstance = $DB->get_record('vpl_submissions', array('id' => $submissionid)); } else { $subinstance = $vpl->last_user_submission($userid); } $vpl->password_check(); } //Check consistence if (!$subinstance) { throw new Exception(get_string('nosubmission', VPL)); } if ($subinstance->vpl != $vpl->get_instance()->id) { throw new Exception(get_string('invalidcourseid')); } $submissionid = $subinstance->id; if ($vpl->is_inconsistent_user($subinstance->userid, $userid)) { throw new Exception('vpl submission user inconsistence'); } if ($vpl->get_instance()->id != $subinstance->vpl) { throw new Exception('vpl submission vpl inconsistence'); } $submission = new mod_vpl_submission($vpl, $subinstance); $fgm = $submission->get_submitted_fgm(); $fgm->download_files($vpl->get_printable_name()); } catch (Exception $e) { $vpl->prepare_page('views/downloadsubmission.php', array('id' => $id)); $vpl->print_header(get_string('download', VPL)); echo $OUTPUT->box($e->getMessage()); $vpl->print_footer(); }