Skip to content
Snippets Groups Projects
evaluserexport.php 2.89 KiB
Newer Older
  • Learn to ignore specific revisions
  • <?php
    // This file is part of Moodle - https://moodle.org/
    //
    // 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 <https://www.gnu.org/licenses/>.
    
    /**
     * Plugin version and other meta-data are defined here.
     *
     * @package     local_hshexport
     * @copyright   2024 Elke Kreim elke.kreim@hs-hannover.de
     * @license     https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
     */
    
    namespace local_hshexport\form;
    
    use moodleform;
    
    defined('MOODLE_INTERNAL') || die();
    
    class evaluserexport extends moodleform {
    
        public function definition()
        {
            $mform = $this->_form;
    
            $introtext = get_string('evaluserexport_form_into', 'local_hshexport');
            $mform->addElement('html', '<div id="intor">' . $introtext . '</div>');
    
            $courseid = $this->_customdata['courseid'];
            $coursecontext = $this->_customdata['coursecontext'];
    
            $viewableroles = get_roles_used_in_context($coursecontext, false);
    
            $roles = role_fix_names($viewableroles, $coursecontext, ROLENAME_ALIAS);
            $options = [];
            foreach ($roles as $role) {
                $options[$role->id] = $role->localname;
            }
    
            $mform->addElement('text', 'course_code', get_string('course_code', 'local_hshexport'), 'maxlength="100" size="50" placeholder="BBA-422-01"');
            $mform->setType('course_code', PARAM_ALPHANUMEXT);
            $mform->addHelpButton('course_code', 'course_code', 'local_hshexport');
            $mform->setDefault('course_code', null);
    
            $roles = role_fix_names($viewableroles, $coursecontext, ROLENAME_ALIAS);
            $options = [];
            foreach ($roles as $role) {
                $options[$role->id] = $role->localname;
            }
            $select = $mform->addElement('select', 'select_roles', get_string('select_roles', 'local_hshexport'), $options);
            $select->setMultiple(true);
            $mform->addHelpButton('select_roles', 'select_roles', 'local_hshexport');
            $mform->addRule('select_roles', get_string('noselectedroles', 'local_hshexport'), 'required', 'null', true);
    
            $mform->addElement('hidden', 'courseid', $courseid);
            $mform->setType('courseid', PARAM_INT);
    
            $mform->addElement('hidden', 'coursecontextid', $coursecontext->id);
            $mform->setType('coursecontextid', PARAM_INT);
    
            $submitlabel = get_string('csvdownload', 'local_hshexport');
            $this->add_action_buttons(false, $submitlabel);
    
        }
    
    }