Explorar el Código

New version of submission_form.php and submission.php files.
- Easier to read
- Functions used on them are inside forms/submission_form_functions.php
- Filepicker added, still not receiving and adding data to database. Everything else is working;

Bernardo hace 2 años
padre
commit
86de33fabb
Se han modificado 9 ficheros con 102 adiciones y 487 borrados
  1. 41 18
      lang/en/gradeimporter.php
  2. 3 3
      mod_form.php
  3. 12 1
      readme.md
  4. 45 121
      submission.php
  5. 0 138
      submission_form.php
  6. 0 139
      submissiontype.php
  7. 0 59
      submissiontype_form.php
  8. 1 1
      version.php
  9. 0 7
      view.php

+ 41 - 18
lang/en/gradeimporter.php

@@ -1,4 +1,21 @@
 <?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('forms_lang.php');
+
 $string['gradeimporter'] = 'Grade Importer';
 $string['pluginname'] = 'Grade Importer';
 
@@ -7,41 +24,44 @@ $string['modulenameplural'] = 'Grade Importers';
 
 $string['gradeimporterintro'] = 'This module facilitates...';
 $string['gradeimportername'] = 'Grade Importer Name';
-$string['pluginadministration'] ='plugin administration string';
+$string['pluginadministration'] = 'plugin administration string';
 $string['displayingview'] = 'Posted Grades';
 
-//submission.php
+// Submission.php
 $string['invalidgradeimporterid'] = 'Invalid Grade Importer ID';
 $string['submissionadded'] = "Submission added to DB";
 $string['newsubmission'] = "Add new submission";
 
-//formStrings
+// FormStrings
 
-    //Generic 
+    // Generic
     $string['description'] = 'Description';
     $string['visibility'] = 'Can students see this?';
     $string['name'] = 'Name';
     $string['yes'] = 'Yes';
     $string['no'] = 'no';
 
-    //Generic error Messages
+    // Generic error Messages
     $string['error_nameField'] = 'Insert a name';
 
 
-    //gradeImporter form
+    // GradeImporter form
     $string['general'] = 'General informations';
     $string['visibilityOn'] = 'Students can see this';
     $string['visibilityOff'] = 'Students can\'t see this';
-    
-    //subtypes
+
+    // Submission form
+
+    // Subtypes
         $string['exam'] = 'Exam';
         $string['activity'] = 'Activity';
 
-    //gradeImporter form errors
+    // GradeImporter form errors
 
 
 
-    //submission form
+    // Submission form
+
     $string['gradebookN'] = 'This submission goes to gradebook';
     $string['gradebookY'] = 'This submission does not go to gradebook';
     $string['submissionFiles'] = 'Students feedback file';
@@ -54,28 +74,28 @@ $string['newsubmission'] = "Add new submission";
     $string['visibilityYN'] = 'Students can see this submission';
 
 
-    //submission form help buttons
-    $string['submissionType_help'] = 'Choose submission type (e.g. Exam, Activity)'; 
+    // Submission form help buttons
+    $string['submissionType_help'] = 'Choose submission type (e.g. Exam, Activity)';
     $string['submissionFiles_help'] = 'Must be only one file, either a .zip or a .csv';
     $string['csvdelimiter_help'] = 'CSV delimiter of the config.csv file';
     $string['gradebookYN_help'] = 'Yes, results go to gradebook \n No, Results don\'t go to gradebook';
     $string['visibilityYN_help'] = 'Yes, this is available to students \n No, This is not available to students';
 
-    //submission form errors
+    // Submission form errors
 
 
-//Submission type 
+// Submission type
     $string['newsubtype'] = 'Add new submission type';
 
-    //Submission type help
+    // Submission type help
     $string['newsubtype_help'] = 'Goes to new sub type form (sub type examples: Exam, Test, Activity)';
 
-//events string
+// Events string
     $string['eventmodelsubmissioncreated'] = 'Submission created';
 
 $string['downloadconfigcsv'] = 'Download config CSV';
 
-//view - table presentation
+// View - table presentation
 $string['student']      = 'Student';
 $string['type']         = 'Type';
 $string['submission']   = 'Submission';
@@ -83,4 +103,7 @@ $string['comment']      = 'Comment';
 $string['grade']        = 'Grade';
 $string['file']         = 'File';
 $string['nameCol']      = 'Name';
-$string['editSub']      = "Edit this submission";
+$string['editSub']      = "Edit this submission";
+
+// Access Errors
+    $string['guestnoedit'] = "Guests can't edit forms";

+ 3 - 3
mod_form.php

@@ -26,17 +26,17 @@ class mod_gradeimporter_mod_form extends moodleform_mod {
         $mform =& $this->_form;
         $coursemodulesid = optional_param('update', 0, PARAM_INT);
 
+        // Header
         $mform->addElement('header', 'general', get_string('general', 'gradeimporter'));
 
+        // Name text field
         $mform->addElement('text', 'name', get_string('name', 'gradeimporter'), array('size' => '64'));
         $mform->setType('name', PARAM_TEXT);
         $mform->addRule('name', get_string('error_nameField', 'gradeimporter'), 'required', null, 'client');
 
+        // Description
         $this->standard_intro_elements(get_string('description', 'gradeimporter'));
 
-        // $ynoptions = array(0 => get_string('visibilityOn', 'gradeimporter'), 1 => get_string('visibilityOff', 'gradeimporter'));
-        // $mform->addElement('')
-
         $features = array('groups' => false, 'groupings' => false,
                         'groupmembersonly' => false,  'outcomes' => false,
                         'gradecat' => false, 'idnumber' => false

+ 12 - 1
readme.md

@@ -14,12 +14,23 @@
 
 ### Support plugins
 
-- [XMLDB - plugin to help build install.xml](https://docs.moodle.org/dev/Using_XMLDB)
+- [XMLDB](https://docs.moodle.org/dev/Using_XMLDB)
+  - Plugin to facilitate building DB tables and fields description file (install.xml)
 - [PluginSkel](https://moodle.org/plugins/tool_pluginskel)
+  - Creates a skeleton of the plugin you aim to build giving files and folders needed for it to work
 
 ### APIs
 
+- [Core API](https://docs.moodle.org/dev/Core_APIs#Form_API_.28form.29)
+  - List of all APIs and their documentations
+- [Form API](https://docs.moodle.org/dev/Form_API)
+  - Formulary API, how to add and manipulate fields
+- [Data Manipulation](https://docs.moodle.org/dev/Data_manipulation_API)
+  - Functions to access Moodle DB
 - [String API](https://docs.moodle.org/dev/String_API)
 - [File API](https://docs.moodle.org/dev/File_API)
+  - Manage files stored by moodle
   - [Files in Forms](https://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms)
+    - How to use File API inside forms
   - [File API internals](https://docs.moodle.org/dev/File_API_internals)
+    - How the File API works internally

+ 45 - 121
submission.php

@@ -17,156 +17,80 @@
 require_once('../../config.php');
 require_once('locallib.php');
 require_once('lib.php');
-require_once('submission_form.php');
 
+require_once('forms/submission_form.php'); // Requires Form class File
+require_once('forms/submission_form_functions.php'); // Require functions file for submission form
 
 $cmid = required_param('cmid', PARAM_INT);            // Course Module ID.
 $id = optional_param('id', 0, PARAM_INT);           // Gradeimporter id.
-$subid = optional_param('subid', 1, PARAM_INT);       // Submission id.
-$update = optional_param('update', 0, PARAM_INT);      // If 1 the submission is beign updated.
+$subid = optional_param('subid', -1, PARAM_INT);       // Submission id.
+// $update = optional_param('update', 0, PARAM_INT);      // If 1 the submission is beign updated.
 
+// Checks if everything is correct
+// If any of the queries fail, throw error because of MUST_EXIST clause
+$cm = get_coursemodule_from_id('gradeimporter', $cmid, 0, false, MUST_EXIST);
+$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+$gradeimporter = $DB->get_record('gradeimporter', array('id' => $cm->instance), '*', MUST_EXIST);
 
-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');
-}
 
+// Gets context for File API
 $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'));
-}
-
+// Sets URL
 $url = new moodle_url('/mod/gradeimporter/submission.php', array('cmid' => $cm->id));
 if (!empty($id)) {
     $url->param('id', $id);
 }
 $PAGE->set_url($url);
 
+// Requires capabilities
 require_login($course, false, $cm);
+require_capability('mod/gradeimporter:edit', $context);
 
+// Prepare data for submission form
 
-if (isset($submission)) {
-    if (isguestuser()) {
-        throw new moodle_exception(get_string('guestnoedit', 'gradeimporter').
-                            " $CFG->wwwroot/mod/gradeimporter/view.php?id=$cmid");
-    }
-} else {
+if (!isset($submission)) {
+    // If its creating new submission
     $submission = new stdClass();
     $submission->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', 'submission', $submission->id));
-
-$submissionoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
-
-$submission = file_prepare_standard_editor($submission, 'description', $descriptionoptions, $context,
-                                            'mod_gradeimporter', 'description', $submission->id);
-$submission = file_prepare_standard_filemanager($submission, 'submission', $submissionoptions, $context,
-                                                'mod_gradeimporter', 'submission', $submission->id);
-
+// Set parameters to sendo to the form
 $submission->cmid = $cm->id;
+$maxbytes = $course->maxbytes;
 
 $mform = new mod_gradeimporter_submission_form(null, array('submission' => $submission,
-                                                     'cm' => $cm, 'descriptionoptions' => $descriptionoptions,
-                                                     'submissionoptions' => $submissionoptions,
-                                                     'gradeimporterid' => $gradeimporter->id
-                                                    ));
-
-if ($update == 1) {
-    $subtoupdate = $DB->get_record('gradeimporter_submission', array('id' => $subid));
-    $array = (array) $subtoupdate;
-    echo 'aaaa'.$array['description'];
-    $mform->set_data($subtoupdate);
-}
+                                                            'maxbytes' => $maxbytes
+                                                        )
+                                                );
 
 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 ($submission = $mform->get_data()) {
-    $timenow = time();
-
-    if (empty($submission->id)) {
-        $submission->gradeimporterid    = $gradeimporter->id;
-        $submission->userid             = $USER->id;
-        $submission->timecreated        = $timenow;
-
-        $isnewentry                     = true;
-    } else {
-        $isnewentry                     = false;
-    }
-    $submission->description        = '';           // Updated later.
-    $submission->descriptionformat  = FORMAT_HTML;  // Updated later.
-    $submission->definitiontrust    = 0;
-    $submission->timemodified       = $timenow;
-    $submission->position           = -1;
-
-    if ($isnewentry) {
-        // Add new entry.
-        $submission->id = $DB->insert_record('gradeimporter_submission', $submission);
-    } else {
-        // Update existing entry.
-        $DB->update_record('gradeimporter', $submission);
-    }
-
-    $submission = file_postupdate_standard_editor($submission, 'description',
-                                            $descriptionoptions, $context, 'mod_gradeimporter',
-                                            'description', $submission->id);
-
-    $submission = file_postupdate_standard_filemanager($submission, 'submission',
-                                            $submissionoptions, $context, 'mod_gradeimporter',
-                                            'submission', $submission->id);
-
-    gradeimporter_check_for_zips($context, $cm, $submission);
-
-    // Store updated values.
-    // Error: write to database invalid.
-    $DB->update_record('gradeimporter_submission', $submission);
-
-    // Refetch complete entry.
-    $submission = $DB->get_record('gradeimporter_submission', array('id' => $submission->id));
-
-    // Trigger event and update completion (if entry was created).
-    $eventparams = array(
-        'context' => $context,
-        'objectid' => $submission->id,
-        );
-    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);
-        }
+    // Handle form cancel operation, if cancel button is present on form
+    echo("form is cancelled");
+} else if ($formdata = $mform->get_data()) {
+    create_submission($formdata, $gradeimporter->id, $USER->id);
+    // When complete redirect to view.php
+    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);
     }
 
-    redirect("view.php?id=$cm->id&edit=1");
-}
+    $PAGE->set_title($gradeimporter->name);
+    $PAGE->set_heading($course->fullname);
+    echo $OUTPUT->header();
+    echo $OUTPUT->heading(format_string($gradeimporter->name), 2);
 
-if (!empty($id)) {
-    $PAGE->navbar->add(get_string('edit'));
-}
+    $mform->display();
 
-$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');
+    echo $OUTPUT->footer();
 }
-
-$mform->display();
-
-echo $OUTPUT->footer();

+ 0 - 138
submission_form.php

@@ -1,138 +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/>.
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once($CFG->dirroot.'/lib/formslib.php');
-
-// require_once($CFG->dirroot.'/course/moodleform_mod.php');
-// require_once($CFG->dirroot.'/mod/gradeimporter/lib.php');
-
-class mod_gradeimporter_submission_form extends moodleform {
-
-    public function definition() {
-        global $CFG, $DB;
-
-        $mform =& $this->_form;
-
-        $submission         = $this->_customdata['submission'];
-        $cm                 = $this->_customdata['cm'];
-        $descriptionoptions = $this->_customdata['descriptionoptions'];
-        $submissionoptions  = $this->_customdata['submissionoptions'];
-        $gradeimporterid    = $this->_customdata['gradeimporterid'];
-
-        $context = context_module::instance($cm->id);
-        $fmtoptions = array('context' => $context);
-
-        // ----------------------------------------------------------------------
-        // Form elements start here
-        $mform->addElement('header', 'general', get_string('general', 'form'));
-
-        // Submission name
-        $mform->addElement('text', 'name', get_string('name', 'gradeimporter'), array('size' => '64'));
-        $mform->setType('name', PARAM_TEXT);
-        $mform->addRule('name', get_string('error_nameField', 'gradeimporter'), 'required', null, 'client');
-
-        // Description
-        $mform->addElement('editor', 'descriptioneditor',
-                            get_string('submissionDescription', 'gradeimporter'),
-                            null, $descriptionoptions,
-                        );
-
-        $mform->setType('descriptioneditor', PARAM_RAW);
-
-        $mform->addElement('header', 'filehandling', get_string('filehandling', 'gradeimporter'));
-
-        $url = new moodle_url('/mod/gradeimporter/submissiontype.php?id='.$gradeimporterid.'&cmid='.$cm->id.'&page=0');
-        $newsubtypecontent = '<a href='.$url.'>'.get_string('newsubtype', 'gradeimporter').'</a>';
-        /*$newsubtypecontent = '<form action="'. $url . '">'.
-                '<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
-                '<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
-                '<input type="hidden" name="page" value="0" />'.
-                '<input type="submit" Value="'.get_string('newsubtype', 'gradeimporter').'" />'.
-                '</form>';*/
-        $mform->addElement('html', $newsubtypecontent);
-
-        // Submission type
-        $submissiontyperecords = $DB->get_records('gradeimporter_submissiontype', null, 'id', 'id, name, description');
-        $submissiontyperecords = array_values($submissiontyperecords);
-        $submissiontype = array();
-
-        foreach (array_keys($submissiontyperecords) as $key) {
-            $submissiontype[$submissiontyperecords[$key]->id] = $submissiontyperecords[$key]->name;
-        }
-
-        $mform->addElement('select', 'type',
-                            get_string('submissiontype', 'gradeimporter'),
-                            $submissiontype,
-                            array('onChange' => 'config_type(this.value);')
-                        );
-        // $mform->setDefault('submissiontype', 0); // default submissiontype = 3
-        $mform->addHelpButton('type', 'submissiontype', 'gradeimporter');
-
-        // Receive the files
-        $mform->addElement('filemanager', 'submission_filemanager',
-                            get_string('submissionFiles', 'gradeimporter'),
-                            null, $descriptionoptions
-                        );
-
-        $mform->addHelpButton('submission_filemanager', 'submissionFiles', 'gradeimporter');
-
-        // Csv delimiter
-        $csvdelimiter = array();
-        $csvdelimiter[1] = ',';
-        /*$csvdelimiter[2] = ';';
-        $csvdelimiter[3] = ':';
-        $csvdelimiter[4] = '\t';
-        */
-
-        $mform->addElement('select', 'csvdelimiter',
-                            get_string('csvdelimiter', 'gradeimporter'),
-                            $csvdelimiter,
-                            array('onChange' => 'config_type(this.value);')
-                        );
-        $mform->setDefault('csvdelimiter', 1); // Default csvdelimiter = 3
-        $mform->addHelpButton('csvdelimiter', 'csvdelimiter', 'gradeimporter');
-
-        // Gradebook Y/N Combobox
-        $ynarray = array();
-        $ynarray[0] = get_string('no', 'gradeimporter');
-        $ynarray[1] = get_string('yes', 'gradeimporter');
-        $mform->addElement('select', 'gradebook', get_string('gradebookYN', 'gradeimporter'), $ynarray);
-        // $mform->setDefault('gradebook', 0);
-        $mform->addHelpButton('gradebook', 'gradebookYN', 'gradeimporter');
-
-        // Visibility Y/N Combobox
-        $mform->addElement('select', 'visibility', get_string('visibilityYN', 'gradeimporter'), $ynarray);
-        // $mform->setDefault('visibility', 0);
-        $mform->addHelpButton('visibility', 'visibilityYN', 'gradeimporter');
-
-        // -----------------------------
-        // Hidden fields
-        $mform->addElement('hidden', 'id');
-        $mform->setType('id', PARAM_INT);
-        $mform->addElement('hidden', 'cmid');
-        $mform->setType('cmid', PARAM_INT);
-        // ------------------------------
-
-        // --------------------------------------------------------------
-        $this->add_action_buttons();
-
-        // --------------------------------------------------------------
-        $this->set_data($submission);
-    }
-}
-

+ 0 - 139
submissiontype.php

@@ -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('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();

+ 0 - 59
submissiontype_form.php

@@ -1,59 +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/>.
-
-defined('MOODLE_INTERNAL') or die();
-require_once($CFG->dirroot.'/lib/formslib.php');
-
-class mod_gradeimporter_submissiontype_form extends moodleform {
-
-    public function definition() {
-        global $CFG, $DB;
-
-        $mform =& $this->_form;
-
-        $submissiontype = $this->_customdata['submissiontype'];
-        $cm             = $this->_customdata['cm'];
-        $descriptionoptions = $this->_customdata['descriptionoptions'];
-        $submissiontypeoptions  = $this->_customdata['submissiontypeoptions'];
-
-        $context    = context_module::instance($cm->id);
-        $fmtoptions = array('context' => $context);
-
-        // --------------------
-        // Form starts here
-        $mform->addElement('header', 'general', get_string('general', 'form'));
-
-        // Submission type name
-        $mform->addElement('text', 'name', get_string('name', 'gradeimporter'), array('size' => '64'));
-        $mform->setType('name', PARAM_TEXT);
-        $mform->addRule('name', get_string('error_nameField', 'gradeimporter'), 'required', null, 'client');
-
-        // Description
-        $mform->addElement('editor', 'description_editor', get_string('submissionDescription', 'gradeimporter'), null, $descriptionoptions);
-        $mform->setType('description_editor', PARAM_RAW);
-
-        // Hidden fields
-        $mform->addElement('hidden', 'id');
-        $mform->setType('id', PARAM_INT);
-        $mform->addElement('hidden', 'cmid');
-        $mform->setType('cmid', PARAM_INT);
-
-        // Buttons
-        $this->add_action_buttons();
-
-        $this->set_data($submissiontype);
-    }
-}

+ 1 - 1
version.php

@@ -16,7 +16,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version = 20200219;
+$plugin->version = 20200220;
 $plugin->requires = 2014021100;
 $plugin->release = 'v1.0';
 $plugin->component = 'mod_gradeimporter';

+ 0 - 7
view.php

@@ -26,8 +26,6 @@ require_once('locallib.php');
   $id = optional_param('id', 0, PARAM_INT); // Course_module ID.
   $g  = optional_param('g', 0, PARAM_INT);  // Gradeimporter instance ID, should be named as the first character of the module.
   $action = optional_param('action', 0, PARAM_INT);
-  // $cmid = optional_param('cmid', 0, PARAM_INT);
-  $id       = optional_param('id', 0, PARAM_INT);
   $fileid     = optional_param('fileid', 0, PARAM_INT);
   $filename   = optional_param('filename', 'a', PARAM_TEXT);
 
@@ -99,7 +97,6 @@ if (has_capability('mod/gradeimporter:edit', $context)) {
     $newbutton = '<form action="'. $url . '">'.
           '<input type="hidden" name="id" value="'. $gradeimporter->id .'" />'.
           '<input type="hidden" name="cmid" value="'.$cm->id.'" />'.
-          '<input type="hidden" name="page" value="0" />'.
           '<input type="submit" Value="'.get_string('newsubmission', 'gradeimporter').'" />'.
           '</form>';
     echo $newbutton;
@@ -170,9 +167,5 @@ if (has_capability('mod/gradeimporter:edit', $context)) {
     echo html_writer::table($table);
 }
 
-$PAGE->requires->js_call_amd('mod_gradeimporter/helloworld', 'helloworld');
-$PAGE->requires->js_call_amd('mod_gradeimporter/hello', 'informal', array('marquinho'));
-
-
 // Finishes the page!
 echo $output->footer();