|
@@ -1,115 +1,138 @@
|
|
|
<?php
|
|
|
- if (!defined('MOODLE_INTERNAL')) {
|
|
|
- die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
|
|
- }
|
|
|
+// 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;
|
|
|
+ }
|
|
|
|
|
|
- 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{
|
|
|
-
|
|
|
- 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
|
|
|
- $submissionTypesRecords = $DB->get_records('gradeimporter_submissiontype', null, 'id', 'id, name, description');
|
|
|
- $submissionTypesRecords = array_values($submissionTypesRecords);
|
|
|
- $submissionType = array();
|
|
|
-
|
|
|
- foreach (array_keys($submissionTypesRecords) as $key){
|
|
|
- $submissionType[$submissionTypesRecords[$key]->id] = $submissionTypesRecords[$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
|
|
|
- $csv_delimiter = array();
|
|
|
- $csv_delimiter[1] = ',';
|
|
|
- /*$csv_delimiter[2] = ';';
|
|
|
- $csv_delimiter[3] = ':';
|
|
|
- $csv_delimiter[4] = '\t';
|
|
|
- */
|
|
|
-
|
|
|
- $mform->addElement('select', 'csv_delimiter', get_string('csvdelimiter', 'gradeimporter'), $csv_delimiter, array('onChange' => 'config_type(this.value);'));
|
|
|
- $mform->setDefault('csv_delimiter', 1); // default csv_delimiter = 3
|
|
|
- $mform->addHelpButton('csv_delimiter', '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('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->add_action_buttons();
|
|
|
|
|
|
- //--------------------------------------------------------------
|
|
|
- $this->set_data($submission);
|
|
|
- }
|
|
|
+ // --------------------------------------------------------------
|
|
|
+ $this->set_data($submission);
|
|
|
}
|
|
|
+}
|
|
|
|