mod_form.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.
  13. //
  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/>.
  16. /**
  17. * The main colab configuration form.
  18. *
  19. * @package colab
  20. * @copyright 2020 Your Name <you@example.com>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. require_once($CFG->dirroot.'/course/moodleform_mod.php');
  25. /**
  26. * Module instance settings form.
  27. *
  28. * @package colab
  29. * @copyright 2020 Your Name <you@example.com>
  30. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  31. */
  32. class mod_colab_mod_form extends moodleform_mod {
  33. /**
  34. * Defines forms elements
  35. */
  36. public function definition() {
  37. global $CFG;
  38. $mform = $this->_form;
  39. // Adding the "general" fieldset, where all the common settings are showed.
  40. $mform->addElement('header', 'general', get_string('general', 'form'));
  41. // Adding the standard "name" field.
  42. $mform->addElement('text', 'name', get_string('colabname', 'colab'), array('size' => '64'));
  43. if (!empty($CFG->formatstringstriptags)) {
  44. $mform->setType('name', PARAM_TEXT);
  45. } else {
  46. $mform->setType('name', PARAM_CLEANHTML);
  47. }
  48. $mform->addRule('name', null, 'required', null, 'client');
  49. $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
  50. $mform->addHelpButton('name', 'colabname', 'colab');
  51. // Adding the standard "intro" and "introformat" fields.
  52. if ($CFG->branch >= 29) {
  53. $this->standard_intro_elements();
  54. } else {
  55. $this->add_intro_editor();
  56. }
  57. // Adding the rest of colab settings, spreading all them into this fieldset
  58. // ... or adding more fieldsets ('header' elements) if needed for better logic.
  59. $mform->addElement('static', 'label1', 'colabsettings', get_string('colabsettings', 'colab'));
  60. $mform->addElement('header', 'colabfieldset', get_string('colabfieldset', 'colab'));
  61. // Add standard grading elements.
  62. $this->standard_grading_coursemodule_elements();
  63. // Add standard elements.
  64. $this->standard_coursemodule_elements();
  65. // Add standard buttons.
  66. $this->add_action_buttons();
  67. }
  68. }