|
@@ -1,139 +0,0 @@
|
|
|
-<?php
|
|
|
-// This file is part of
|
|
|
-//
|
|
|
-// Moodle is free software: you can redistribute it and/or modify
|
|
|
-// it under the terms of the GNU General Public License as published by
|
|
|
-// the Free Software Foundation, either version 3 of the License, or
|
|
|
-// (at your option) any later version.
|
|
|
-//
|
|
|
-// Moodle is distributed in the hope that it will be useful,
|
|
|
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-// GNU General Public License for more details.
|
|
|
-//
|
|
|
-// You should have received a copy of the GNU General Public License
|
|
|
-// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
-
|
|
|
-require_once('../../config.php');
|
|
|
-require_once('locallib.php');
|
|
|
-require_once('lib.php');
|
|
|
-require_once('submissiontype_form.php');
|
|
|
-
|
|
|
-
|
|
|
-$cmid = required_param('cmid', PARAM_INT); // Course Module ID
|
|
|
-$id = required_param('id' , PARAM_INT); // Gradeimporter id
|
|
|
-
|
|
|
-if (!$cm = get_coursemodule_from_id('gradeimporter', $cmid)) {
|
|
|
- throw new moodle_exception('invalidcoursemodule');
|
|
|
-}
|
|
|
-
|
|
|
-if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
|
|
|
- throw new moodle_exception('coursemisconf');
|
|
|
-}
|
|
|
-
|
|
|
-$context = context_module::instance($cm->id);
|
|
|
-
|
|
|
-require_capability('mod/gradeimporter:edit', $context);
|
|
|
-
|
|
|
-if (!$gradeimporter = $DB->get_record('gradeimporter', array('id' => $cm->instance))) {
|
|
|
- throw new moodle_exception(get_string('invalidid', 'gradeimporter'));
|
|
|
-}
|
|
|
-
|
|
|
-$url = new moodle_url('/mod/gradeimporter/submissiontype.php', array('cmid' => $cm->id));
|
|
|
-if (!empty($id)) {
|
|
|
- $url->param('id', $id);
|
|
|
-}
|
|
|
-$PAGE->set_url($url);
|
|
|
-
|
|
|
-require_login($course, false, $cm);
|
|
|
-
|
|
|
-
|
|
|
-if ($submissiontype) {
|
|
|
- if (isguestuser()) {
|
|
|
- throw new moodle_exception('guestnoedit', 'gradeimporter', "$CFG->wwwroot/mod/gradeimporter/view.php?id=$cmid");
|
|
|
- }
|
|
|
-} else {
|
|
|
-
|
|
|
- $submissiontype = new stdClass();
|
|
|
- $submissiontype->id = null;
|
|
|
-}
|
|
|
-
|
|
|
-$maxfiles = 50;
|
|
|
-$maxbytes = $course->maxbytes;
|
|
|
-
|
|
|
-$descriptionoptions = array('trusttext' => true, 'maxfiles' => $maxfiles,
|
|
|
- 'maxbytes' => $maxbytes, 'context' => $context,
|
|
|
- 'subdirs' => file_area_contains_subdirs($context, 'mod_gradeimporter',
|
|
|
- 'submissiontype', $submissiontype->id));
|
|
|
-
|
|
|
-$submissiontypeoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
|
|
|
-
|
|
|
-$submissiontype = file_prepare_standard_editor($submissiontype, 'description', $descriptionoptions,
|
|
|
- $context, 'mod_gradeimporter', 'description', $submissiontype->id);
|
|
|
-
|
|
|
-$submissiontype->cmid = $cm->id;
|
|
|
-
|
|
|
-$mform = new mod_gradeimporter_submissiontype_form(null, array('submissiontype' => $submissiontype,
|
|
|
- 'cm' => $cm,
|
|
|
- 'descriptionoptions' => $descriptionoptions,
|
|
|
- 'submissiontypeoptions' => $submissiontypeoptions
|
|
|
- )
|
|
|
- );
|
|
|
-
|
|
|
-if ($mform->is_cancelled()) {
|
|
|
- if ($id) {
|
|
|
- redirect("view.php?id=$cm->id&mode=entry&hook=$id");
|
|
|
- } else {
|
|
|
- redirect("view.php?id=$cm->id");
|
|
|
- }
|
|
|
-} else if ($submissiontype = $mform->get_data()) {
|
|
|
- if (empty($submissiontype->id)) {
|
|
|
- $submissiontype->gradeimporterid = $gradeimporter->id;
|
|
|
-
|
|
|
- $isnewentry = true;
|
|
|
- } else {
|
|
|
- $isnewentry = false;
|
|
|
- }
|
|
|
-
|
|
|
- $submissiontype->description = '';
|
|
|
- $submissiontype->descriptionformat = FORMAT_HTML;
|
|
|
- $submissiontype->definitiontrust = 0;
|
|
|
-
|
|
|
- if ($isnewentry) {
|
|
|
- $submissiontype->id = $DB->insert_record('gradeimporter_submissiontype', $submissiontype);
|
|
|
- } else {
|
|
|
- $DB->update_record('gradeimporter', $submissiontype);
|
|
|
- }
|
|
|
-
|
|
|
- $submissiontype = file_postupdate_standard_editor($submissiontype, 'description',
|
|
|
- $descriptionoptions, $context, 'mod_gradeimporter',
|
|
|
- 'submissiontype', $submissiontype->id);
|
|
|
-
|
|
|
- $DB->update_record('gradeimporter_submissiontype', $submissiontype);
|
|
|
-
|
|
|
- if ($isnewentry) {
|
|
|
- // Update completion state
|
|
|
- $completion = new completion_info($course);
|
|
|
- if ($completion->is_enabled($cm) == COMPLETION_TRACKING_AUTOMATIC && $gradeimporter->completionentries) {
|
|
|
- $completion->update_state($cm, COMPLETION_COMPLETE);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- redirect("submission.php?id=$id&cmid=$cm->id&page=0");
|
|
|
-}
|
|
|
-
|
|
|
-if (!empty($id)) {
|
|
|
- $PAGE->navbar->add(get_string('edit'));
|
|
|
-}
|
|
|
-
|
|
|
-$PAGE->set_title($gradeimporter->name);
|
|
|
-$PAGE->set_heading($course->fullname);
|
|
|
-echo $OUTPUT->header();
|
|
|
-echo $OUTPUT->heading(format_string($gradeimporter->name), 2);
|
|
|
-if ($gradeimporter->intro) {
|
|
|
- echo $OUTPUT->box(format_module_intro('gradeimporter', $gradeimporter, $cm->id), 'generalbox', 'intro');
|
|
|
-}
|
|
|
-
|
|
|
-$mform->display();
|
|
|
-
|
|
|
-echo $OUTPUT->footer();
|