Bläddra i källkod

Update 'forms/submission/submission_form.php'

Reference do LInE. Indentation adjusts.
leo 2 år sedan
förälder
incheckning
28b2f2461c
1 ändrade filer med 73 tillägg och 74 borttagningar
  1. 73 74
      forms/submission/submission_form.php

+ 73 - 74
forms/submission/submission_form.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
@@ -16,86 +18,83 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-require_once("$CFG->dirroot/course/moodleform_mod.php");
-require_once("$CFG->libdir/formslib.php");
+require_once($CFG->dirroot . "/course/moodleform_mod.php");
+require_once($CFG->libdir . "/formslib.php");
 require_once("submission_form_functions.php");
 
 class mod_gradeimporter_submission_form extends moodleform {
 
-    public function definition() {
-        global $CFG, $DB;
-
-        $mform = $this->_form;
-
-        // Custom data
-        $submission = $this->_customdata['submission']; // Load fields data
-        $filemanageroptions = $this->_customdata['filemanageroptions'];
-        $gradeimporterid = $this->_customdata['gradeimporterid'];
-        $cmid = $this->_customdata['cmid'];
-        // ----------------------------------------------------------------
-        // General information
-
-        // Header
-        $mform->addElement('header',  'newsub',  get_string('newsubmission', 'gradeimporter'));
-
-        // Submission name field
-        $mform->addElement('text', 'name', get_string('submissionname', 'gradeimporter'));
-        $mform->setType('name', PARAM_TEXT);
-        $mform->addRule('name', null, 'required', null, 'client');
-
-        $mform->addElement('editor', 'description', get_string('description'));
-        $mform->setType('description', PARAM_TEXT);
-
-        $mform->addElement('filemanager', 'submissionfiles_filemanager', get_string('submissionfiles', 'gradeimporter'),
-                            null, $filemanageroptions);
-        $mform->addHelpButton('submissionfiles_filemanager', 'submissionfiles', 'gradeimporter');
-
-        // Add button to open new subtypeform
-        $subtypeformurl = new moodle_url("/mod/gradeimporter/forms/submissiontype/submissiontype.php",
-                                            array('cmid' => $cmid, 'id' => $gradeimporterid)
-                                        );
-        $newsubtypebutton = "<div class=\"col-md-9 form-inline align-items-start felement\">
-                                <button class=\"btn btn-primary\" onclick=\"window.open('$subtypeformurl','_self')\">
-                                    New type
-                                </button>
-                            </div>";
-        $mform->addElement('html', $newsubtypebutton);
-
-        // To edit
-        $subtypes = get_types_array($gradeimporterid);
-        var_dump ($subtypes);
-        if ($subtypes) {
-            $selectvalues = array();
-            foreach ($subtypes as $id => $type) {
-                $selectvalues[$id] = $type->name;
-            }
-        } else {
-            $selectvalues = array('create new type first');
-        }
-        $mform->addElement('select', 'type', get_string('submissiontype', 'gradeimporter'), $selectvalues);
+  public function definition () {
+    global $CFG, $DB;
+
+    $mform = $this->_form;
+
+    // Custom data
+    $submission = $this->_customdata['submission']; // Load fields data
+    $filemanageroptions = $this->_customdata['filemanageroptions'];
+    $gradeimporterid = $this->_customdata['gradeimporterid'];
+    $cmid = $this->_customdata['cmid'];
+    // ----------------------------------------------------------------
+    // General information
 
-        $mform->addElement('selectyesno', 'visibility',  get_string('visibility', 'gradeimporter'));
-        $mform->setDefault('visibility', array('value' => 1));
-        $mform->addHelpButton('visibility', 'visibility', 'gradeimporter');
+    // Header
+    $mform->addElement('header',  'newsub',  get_string('newsubmission', 'gradeimporter'));
 
-        $mform->addElement('selectyesno', 'gradebook',  get_string('gradebook', 'gradeimporter'));
-        $mform->setDefault('gradebook', array('value' => 0));
-        $mform->addHelpButton('gradebook', 'gradebook', 'gradeimporter');
+    // Submission name field
+    $mform->addElement('text', 'name', get_string('submissionname', 'gradeimporter'));
+    $mform->setType('name', PARAM_TEXT);
+    $mform->addRule('name', null, 'required', null, 'client');
 
-        // -----------------------------
-        // Hidden fields
-        $mform->addElement('hidden', 'id');
-        $mform->setType('id', PARAM_INT);
-        $mform->addElement('hidden', 'cmid');
-        $mform->setType('cmid', PARAM_INT);
+    $mform->addElement('editor', 'description', get_string('description'));
+    $mform->setType('description', PARAM_TEXT);
 
-        // ------------------------------
-        // Save and cancel buttons
-        $this->add_action_buttons();
+    $mform->addElement('filemanager', 'submissionfiles_filemanager', get_string('submissionfiles', 'gradeimporter'), null, $filemanageroptions);
 
-        // ------------------------------
-        // Sets preloaded data to fields
-        $this->set_data($submission);
-    }
+    $mform->addHelpButton('submissionfiles_filemanager', 'submissionfiles', 'gradeimporter');
 
-}
+    // Add button to open new subtypeform
+    $subtypeformurl = new moodle_url("/mod/gradeimporter/forms/submissiontype/submissiontype.php", array('cmid' => $cmid, 'id' => $gradeimporterid));
+    $newsubtypebutton = "<div class=\"col-md-9 form-inline align-items-start felement\">
+  <button class=\"btn btn-primary\" onclick=\"window.open('" . $subtypeformurl . "','_self')\">New type</button>
+  </div>\n";
+    $mform->addElement('html', $newsubtypebutton);
+
+    // To edit
+    $subtypes = get_types_array($gradeimporterid);
+    var_dump ($subtypes);
+    if ($subtypes) {
+      $selectvalues = array();
+      foreach ($subtypes as $id => $type) {
+        $selectvalues[$id] = $type->name;
+        }
+      } 
+    else {
+      $selectvalues = array('create new type first');
+      }
+    $mform->addElement('select', 'type', get_string('submissiontype', 'gradeimporter'), $selectvalues);
+
+    $mform->addElement('selectyesno', 'visibility',  get_string('visibility', 'gradeimporter'));
+    $mform->setDefault('visibility', array('value' => 1));
+    $mform->addHelpButton('visibility', 'visibility', 'gradeimporter');
+
+    $mform->addElement('selectyesno', 'gradebook',  get_string('gradebook', 'gradeimporter'));
+    $mform->setDefault('gradebook', array('value' => 0));
+    $mform->addHelpButton('gradebook', 'gradebook', 'gradeimporter');
+
+    // -----------------------------
+    // Hidden fields
+    $mform->addElement('hidden', 'id');
+    $mform->setType('id', PARAM_INT);
+    $mform->addElement('hidden', 'cmid');
+    $mform->setType('cmid', PARAM_INT);
+
+    // ------------------------------
+    // Save and cancel buttons
+    $this->add_action_buttons();
+
+    // ------------------------------
+    // Sets preloaded data to fields
+    $this->set_data($submission);
+    } // public function definition()
+
+  } // class mod_gradeimporter_submission_form extends moodleform