<?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.'/course/moodleform_mod.php');
require_once($CFG->dirroot.'/mod/gradeimporter/lib.php');

class mod_gradeimporter_mod_form extends moodleform_mod {
  public function definition() {
    global $CFG, $COURSE, $USER, $DB, $OUTPUT;

    $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',
                                                                                  'maxlength' => "256")
                                                                                );
    $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'));

    $features = array('groups' => false, 'groupings' => false,
            'groupmembersonly' => false,  'outcomes' => false,
            'gradecat' => false, 'idnumber' => false
          );

    $this->standard_coursemodule_elements($features);

    // Hidden fields
    $mform->addElement('hidden', 'action');
    $mform->setType('action', PARAM_TEXT);
    $mform->addElement('hidden', 'id');
    $mform->setType('id', PARAM_TEXT);
    $mform->addElement('hidden', 'author_name');
    $mform->setType('author_name', PARAM_TEXT);
    $mform->addElement('hidden', 'author_modified_name');
    $mform->setType('author_modified_name', PARAM_TEXT);
    $mform->addElement('hidden', 'timecreated');
    $mform->setType('timecreated', PARAM_TEXT);
    $mform->addElement('hidden', 'position');
    $mform->setType('position', PARAM_TEXT);

    $this->add_action_buttons();
  }
}