|
@@ -1,15 +1,13 @@
|
|
|
<?php
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -18,13 +16,16 @@ require_once('../../../../config.php');
|
|
|
require_once('../../locallib.php');
|
|
|
require_once('../../lib.php');
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
require_once('submission_form.php');
|
|
|
require_once('submission_form_functions.php');
|
|
|
|
|
|
-$cmid = required_param('cmid', PARAM_INT);
|
|
|
-$id = optional_param('id', 0, PARAM_INT);
|
|
|
-$subid = optional_param('subid', -1, PARAM_INT);
|
|
|
-
|
|
|
+$cmid = required_param('cmid', PARAM_INT);
|
|
|
+$id = optional_param('id', 0, PARAM_INT);
|
|
|
+$subid = optional_param('subid', -1, PARAM_INT);
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -40,7 +41,7 @@ $context = context_module::instance($cm->id);
|
|
|
$url = new moodle_url('/mod/gradeimporter/forms/submission/submission.php', array('cmid' => $cm->id));
|
|
|
if (!empty($id)) {
|
|
|
$url->param('id', $id);
|
|
|
-}
|
|
|
+ }
|
|
|
$PAGE->set_url($url);
|
|
|
|
|
|
|
|
@@ -53,7 +54,7 @@ if (!isset($entry)) {
|
|
|
|
|
|
$entry = new stdClass();
|
|
|
$entry->id = null;
|
|
|
-}
|
|
|
+ }
|
|
|
|
|
|
|
|
|
$entry->cmid = $cm->id;
|
|
@@ -61,62 +62,58 @@ $maxbytes = $course->maxbytes;
|
|
|
|
|
|
|
|
|
$filemanageroptions = array('subdirs' => 0,
|
|
|
- 'maxbytes' => $maxbytes,
|
|
|
- 'areamaxbytes' => 10485760,
|
|
|
- 'maxfiles' => 1,
|
|
|
- 'accepted_types' => array('.csv', '.zip')
|
|
|
- );
|
|
|
+ 'maxbytes' => $maxbytes,
|
|
|
+ 'areamaxbytes' => 10485760,
|
|
|
+ 'maxfiles' => 1,
|
|
|
+ 'accepted_types' => array('.csv', '.zip'));
|
|
|
|
|
|
-$entry = file_prepare_standard_filemanager($entry, 'submissionfiles', $filemanageroptions, $context,
|
|
|
- 'mod_gradeimporter', 'submissionfiles', $entry->id);
|
|
|
+$entry = file_prepare_standard_filemanager($entry, 'submissionfiles', $filemanageroptions, $context, 'mod_gradeimporter', 'submissionfiles', $entry->id);
|
|
|
|
|
|
|
|
|
$mform = new mod_gradeimporter_submission_form(null, array('submission' => $entry,
|
|
|
- 'filemanageroptions' => $filemanageroptions,
|
|
|
- 'gradeimporterid' => $gradeimporter->id,
|
|
|
- 'cmid' => $cm->id
|
|
|
- )
|
|
|
- );
|
|
|
+ 'filemanageroptions' => $filemanageroptions,
|
|
|
+ 'gradeimporterid' => $gradeimporter->id,
|
|
|
+ 'cmid' => $cm->id));
|
|
|
|
|
|
if ($mform->is_cancelled()) {
|
|
|
|
|
|
$viewurl = new moodle_url('/mod/gradeimporter/view.php', ['id' => $cm->id, 'edit' => 1]);
|
|
|
redirect($viewurl);
|
|
|
-} else if ($formdata = $mform->get_data()) {
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+else if ($formdata = $mform->get_data()) {
|
|
|
validate_formdata($formdata);
|
|
|
+
|
|
|
|
|
|
$entry = create_submission($formdata, $gradeimporter->id, $USER->id);
|
|
|
|
|
|
|
|
|
- $entry = file_postupdate_standard_filemanager($entry, 'submissionfiles',
|
|
|
- $filemanageroptions, $context, 'mod_gradeimporter',
|
|
|
- 'submissionfiles', $entry->id);
|
|
|
+ $entry = file_postupdate_standard_filemanager($entry, 'submissionfiles', $filemanageroptions, $context, 'mod_gradeimporter', 'submissionfiles', $entry->id);
|
|
|
|
|
|
store_files($context, $cm, $entry);
|
|
|
|
|
|
$viewurl = new moodle_url('/mod/gradeimporter/view.php', ['id' => $cm->id, 'edit' => 1]);
|
|
|
redirect($viewurl);
|
|
|
-
|
|
|
-} else {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+else {
|
|
|
|
|
|
|
|
|
if ($subid != -1) {
|
|
|
|
|
|
|
|
|
$subdata = $DB->get_record('gradeimporter_submission', array('id' => $subid));
|
|
|
- $subdata->description = array('text' => $subdata->description,
|
|
|
- 'format' => $subdata->descriptionformat
|
|
|
- );
|
|
|
+ $subdata->description = array('text' => $subdata->description, 'format' => $subdata->descriptionformat);
|
|
|
$mform->set_data($subdata);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
$PAGE->set_title($gradeimporter->name);
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
- echo $OUTPUT->header();
|
|
|
- echo $OUTPUT->heading(format_string($gradeimporter->name), 2);
|
|
|
+ print $OUTPUT->header();
|
|
|
+ print $OUTPUT->heading(format_string($gradeimporter->name), 2);
|
|
|
|
|
|
$mform->display();
|
|
|
|
|
|
- echo $OUTPUT->footer();
|
|
|
-}
|
|
|
+ print $OUTPUT->footer();
|
|
|
+ }
|