Procházet zdrojové kódy

Update 'forms/submission/submission.php'

Fixed redirect to GradeImport view (from "redirect("view.php?id=$cm->id&edit=1");" to "redirect($CFG->dirroot . "/mod/gradeimporter/view.php?id=" . $cm->id . "&edit=1");"
Initial reference to LInE.
Adjust in indentation.
leo před 2 roky
rodič
revize
6e52dcc188
1 změnil soubory, kde provedl 50 přidání a 55 odebrání
  1. 50 55
      forms/submission/submission.php

+ 50 - 55
forms/submission/submission.php

@@ -1,5 +1,7 @@
 <?php
-// This file is part of
+// This file is part of LInE contributions to Free Education, Private Data
+// LInE (Laboratory of Informatics in Education)
+// www.usp.br/line
 //
 // Moodle is free software: you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -42,8 +44,8 @@ $context = context_module::instance($cm->id);
 // Sets URL
 $url = new moodle_url('/mod/gradeimporter/forms/submission/submission.php', array('cmid' => $cm->id));
 if (!empty($id)) {
-    $url->param('id', $id);
-}
+  $url->param('id', $id);
+  }
 $PAGE->set_url($url);
 
 // Requires capabilities
@@ -53,10 +55,10 @@ require_capability('mod/gradeimporter:edit', $context);
 // Prepare data for submission form
 
 if (!isset($entry)) {
-    // If its creating new submission
-    $entry = new stdClass();
-    $entry->id = null;
-}
+  // If its creating new submission
+  $entry = new stdClass();
+  $entry->id = null;
+  }
 
 // Set parameters to sendo to the form
 $entry->cmid = $cm->id;
@@ -64,61 +66,54 @@ $maxbytes = $course->maxbytes;
 
 // Prepare file manager
 $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);
 
 // Create new mform to show to the user
 $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()) {
-    // Handle form cancel operation, if cancel button is present on form
-    redirect("view.php?id=$cm->id&edit=1");
-} else if ($formdata = $mform->get_data()) {
-
-    // reset_submissions($context->id); // Remove when going to production
-
-    $entry = create_submission($formdata, $gradeimporter->id, $USER->id);
-
-    // Gets file manager content
-    $entry = file_postupdate_standard_filemanager($entry, 'submissionfiles',
-                                            $filemanageroptions, $context, 'mod_gradeimporter',
-                                            'submissionfiles', $entry->id);
-
-    store_files($context, $cm, $entry);
-    // When complete redirect to view.php
-    // uncomment later
-    redirect("view.php?id=$cm->id&edit=1");
-    // In this case you process validated data. $mform->get_data() returns data posted in form.
-} else {
-    // This branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
-    // ...or on the first display of the form.
-    if ($subid != -1) {
-        // If its updating an existing submission
-        // Get data from db and insert into form
-        $subdata = $DB->get_record('gradeimporter_submission', array('id' => $subid));
-        $subdata->description = array('text' => $subdata->description,
-                                        'format' => $subdata->descriptionformat
-                                    );
-        $mform->set_data($subdata);
+  // Handle form cancel operation, if cancel button is present on form
+  redirect($CFG->wwwroot . "/mod/gradeimporter/view.php?id=" . $cm->id . "&edit=1");
+  }
+else if ($formdata = $mform->get_data()) {
+  // reset_submissions($context->id); // Remove when going to production
+  $entry = create_submission($formdata, $gradeimporter->id, $USER->id);
+
+  // Gets file manager content
+  $entry = file_postupdate_standard_filemanager($entry, 'submissionfiles', $filemanageroptions, $context, 'mod_gradeimporter', 'submissionfiles', $entry->id);
+
+  store_files($context, $cm, $entry);
+  // When complete redirect to view.php
+  // uncomment later
+  redirect("view.php?id=" . $cm->id . "&edit=1");
+  // In this case you process validated data. $mform->get_data() returns data posted in form.
+  }
+else { // else if ($formdata = $mform->get_data())
+  // This branch is executed if the form is submitted but the data doesn't validate and the form should be redisplayed
+  // ...or on the first display of the form.
+  if ($subid != -1) {
+    // If its updating an existing submission
+    // Get data from db and insert into form
+    $subdata = $DB->get_record('gradeimporter_submission', array('id' => $subid));
+    $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);
+  $PAGE->set_title($gradeimporter->name);
+  $PAGE->set_heading($course->fullname);
+  print $OUTPUT->header();
+  print $OUTPUT->heading(format_string($gradeimporter->name), 2);
 
-    $mform->display();
+  $mform->display();
 
-    echo $OUTPUT->footer();
-}
+  print $OUTPUT->footer();
+  }