MDL-78251 tiny: Reduce use of UI for setting test expectations
[moodle.git] / mod / lti / register_form.php
bloba108101ddcad7b50609e4d95a801cbcd6323db5e
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * This file defines the main tool registration configuration form
20 * @package mod_lti
21 * @copyright 2014 Vital Source Technologies http://vitalsource.com
22 * @author Stephen Vickers
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die;
28 require_once($CFG->libdir.'/formslib.php');
29 require_once($CFG->dirroot.'/mod/lti/locallib.php');
31 /**
32 * The mod_lti_register_types_form class.
34 * @package mod_lti
35 * @since Moodle 2.8
36 * @copyright 2014 Vital Source Technologies http://vitalsource.com
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 class mod_lti_register_types_form extends moodleform {
41 /**
42 * Set up the form definition.
44 public function definition() {
45 global $CFG;
47 $mform =& $this->_form;
49 $mform->addElement('header', 'setup', get_string('registration_options', 'lti'));
51 // Tool Provider name.
53 $strrequired = get_string('required');
54 $mform->addElement('text', 'lti_registrationname', get_string('registrationname', 'lti'));
55 $mform->setType('lti_registrationname', PARAM_TEXT);
56 $mform->addHelpButton('lti_registrationname', 'registrationname', 'lti');
57 $mform->addRule('lti_registrationname', $strrequired, 'required', null, 'client');
59 // Registration URL.
61 $mform->addElement('text', 'lti_registrationurl', get_string('registrationurl', 'lti'), array('size' => '64'));
62 $mform->setType('lti_registrationurl', PARAM_URL);
63 $mform->addHelpButton('lti_registrationurl', 'registrationurl', 'lti');
64 $mform->addRule('lti_registrationurl', $strrequired, 'required', null, 'client');
66 // LTI Capabilities.
68 $options = array_keys(lti_get_capabilities());
69 natcasesort($options);
70 $attributes = array( 'multiple' => 1, 'size' => min(count($options), 10) );
71 $mform->addElement('select', 'lti_capabilities', get_string('capabilities', 'lti'),
72 array_combine($options, $options), $attributes);
73 $mform->setType('lti_capabilities', PARAM_TEXT);
74 $mform->addHelpButton('lti_capabilities', 'capabilities', 'lti');
75 $mform->addRule('lti_capabilities', $strrequired, 'required', null, 'client');
77 // LTI Services.
79 $services = lti_get_services();
80 $options = array();
81 foreach ($services as $service) {
82 $options[$service->get_id()] = $service->get_name();
84 $attributes = array( 'multiple' => 1, 'size' => min(count($options), 10) );
85 $mform->addElement('select', 'lti_services', get_string('services', 'lti'), $options, $attributes);
86 $mform->setType('lti_services', PARAM_TEXT);
87 $mform->addHelpButton('lti_services', 'services', 'lti');
88 $mform->addRule('lti_services', $strrequired, 'required', null, 'client');
90 $mform->addElement('hidden', 'toolproxyid');
91 $mform->setType('toolproxyid', PARAM_INT);
93 $tab = optional_param('tab', '', PARAM_ALPHAEXT);
94 $mform->addElement('hidden', 'tab', $tab);
95 $mform->setType('tab', PARAM_ALPHAEXT);
97 $courseid = optional_param('course', 1, PARAM_INT);
98 $mform->addElement('hidden', 'course', $courseid);
99 $mform->setType('course', PARAM_INT);
101 // Add standard buttons, common to all modules.
103 $this->add_action_buttons();
107 * Set up rules for disabling fields.
109 public function disable_fields() {
111 $mform =& $this->_form;
113 $mform->disabledIf('lti_registrationurl', null);
114 $mform->disabledIf('lti_capabilities', null);
115 $mform->disabledIf('lti_services', null);