. require_once('../../../../config.php'); require_once('submission_functions.php'); // Get Params to correctly load page $cmid = required_param('cmid', PARAM_INT); $subid = required_param('subid', PARAM_INT); $gradeimporterid = optional_param('id', 0, PARAM_INT); // Get course module and $course to check capability $cm = get_coursemodule_from_id('gradeimporter', $cmid, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); // Gets context to check capability $context = context_module::instance($cm->id); // Sets Page URL $url = new moodle_url('/mod/gradeimporter/forms/submission/delete.php', array('cmid' => $cm->id, 'subid' => $subid)); if (!empty($gradeimporterid)) { $url->param('id', $gradeimporterid); } $PAGE->set_url($url); // Check if its teacher opening the page require_login ($course, false, $cm); require_capability('mod/gradeimporter:edit', $context); // Get globals global $DB; // Get submission $submission = $DB->get_record('gradeimporter_submission', array('id' => $subid, 'gradeimporterid' => $gradeimporterid)); // If submission doesn't exist, throw error if (!$submission) { throw new moodle_exception(get_string('submissionnotfound', 'gradeimporter', $subid)); } // Get feedbacks associated with it $feedbacks = $DB->get_records('gradeimporter_feedback', array('submissionid' => $subid)); foreach ($feedbacks as $feedback) { // For each feedback, deletes its files and then delete it delete_feedback_files($feedback); $DB->delete_records('gradeimporter_feedback', array('id' => $feedback->id)); } // Delete submission $DB->delete_records('gradeimporter_submission', array('id' => $submission->id)); // Print page and redirects to submission page after 5 seconds $PAGE->set_title($submission->name); $PAGE->set_heading($course->fullname); $PAGE->set_context($context); $viewlink = new moodle_url('CFG->dirroot/mod/gradeimporter/view.php', array('id' => $cmid, 'edit' => 1)); echo $OUTPUT->header("refresh:5;url=../../view.php?id=$cmid&edit=1"); echo "

".get_string('deletesubmissiondata', 'gradeimporter', $submission->name)."

"; echo "

".get_string('deletefeedbacksdata', 'gradeimporter', count($feedbacks))."

"; echo "

".get_string('redirect5s', 'gradeimporter')."".get_string('here', 'gradeimporter')."

"; echo $OUTPUT->footer();