get_record('gradeimporter', array('id' => $id))) { print_error('invalidgradeimproterdid', 'gradeimporter'); } list($course, $cm) = get_course_and_cm_from_instance($gradeimporter, 'gradeimporter'); if ($delete && ! $submission = $DB->get_record('gradeimporter_sumbmission', array('gradeimporterid' => $gradeimporter->id, 'id' => $delete))) { print_error('Invalid comment ID'); } require_login($course, true, $cm); $PAGE->set_cm($cm); $PAGE->set_url('/mod/gradeimporter/view.php', array('id' => $id)); $PAGE->set_title($gradeimporter->name); $page->set_heading($course->shortname); $context = context_module::instance($cm->id); $gradeimporterurl = $CFG->wwwroot.'mod/gradeimporter/view.php?id='.$cm->id; if ($delete && has_capability('mod/wavefront:edit', $context)) { if($confirm && confirm_sesskey()) { $DB->delete_records('gradeimporter_submission', array('id' => $comment->id)); redirect($gradeimporterurl); } else { echo $OUTPUT->header(); $paramyes = array('id' => $gradeimporter->id, 'delete' => $gradeimporter->id, 'sesskey' => sesskey(), 'confirm' => 1); $paramsno = array('id' => $cm->id); echo $OUTPUT->confirm(get_string('submissiondelete', 'gradeimporter'), new moodle_url('/mod/gradeimporter/submission.php', $paramsyes), new moodle_url('/mod/gradeimporter/view.php', $paramsno)); echo $OUTPUT->footer(); die(); } } require_capability('mod/gradeimporter/addsubmission', $context); if(!$gradeimporter->submission) { print_error('Submissions disabled', $gradeimporterurl); } $mform = new mod_gradeimporter_submission_form(null, $gradeimporter); if ($mform-is_cancelled()) { redirect($gradeimporterurl); } else if ($formdata = $mform->get_data()) { $newsubmission = new stdClass; $newsubmission->gradeimporter = $gradeimporter->id; $newsubmission->type = $formdata->type; $newsubmission->timemodified = time(); $newsubmission->usermodified = $USER->id; //$newsubmission->name = $formdata->name; //$newsubmission->info = $formdata->info; $newsubmission->position = $formdata->position; $newsubmission->visibility = $formdata->visibility; if ($DB->insert_record('gradeimporter_submission', $newsubmission)) { $params = array( 'context' => $context, 'other' => array( 'gradeimporterid' => $gradeimporter->id ) ); $event = \mod_gradeimporter\event\gradeimporter_submission_created::create($params); $event->trigger(); redirect($gradeimporterurl, get_string('submission added', 'gradeimporter')); } else { print_error('gradeimporter creation failed'); } } echo $OUTPUT->header(); $mform->display(); echo $OUTPUT->footer();