Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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  /**
  18   * This file contains the form add/update a competency framework.
  19   *
  20   * @package   tool_lp
  21   * @copyright 2015 Damyon Wiese
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace tool_lp\form;
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  use core\form\persistent;
  29  
  30  /**
  31   * Learning plan template form.
  32   *
  33   * @package   tool_lp
  34   * @copyright 2015 Damyon Wiese
  35   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  36   */
  37  class template extends persistent {
  38  
  39      protected static $persistentclass = 'core_competency\\template';
  40  
  41      /**
  42       * Define the form - called by parent constructor
  43       */
  44      public function definition() {
  45          $mform = $this->_form;
  46  
  47          $context = $this->_customdata['context'];
  48  
  49          $mform->addElement('hidden', 'contextid');
  50          $mform->setType('contextid', PARAM_INT);
  51          $mform->setConstant('contextid', $context->id);
  52  
  53          $mform->addElement('header', 'generalhdr', get_string('general'));
  54  
  55          // Name.
  56          $mform->addElement('text', 'shortname', get_string('shortname', 'tool_lp'), 'maxlength="100"');
  57          $mform->setType('shortname', PARAM_TEXT);
  58          $mform->addRule('shortname', null, 'required', null, 'client');
  59          $mform->addRule('shortname', get_string('maximumchars', '', 100), 'maxlength', 100, 'client');
  60          // Description.
  61          $mform->addElement('editor', 'description',
  62                             get_string('description', 'tool_lp'), array('rows' => 4));
  63          $mform->setType('description', PARAM_CLEANHTML);
  64          $mform->addElement('selectyesno', 'visible',
  65                             get_string('visible', 'tool_lp'));
  66          $mform->addElement('date_time_selector',
  67                             'duedate',
  68                             get_string('duedate', 'tool_lp'),
  69                             array('optional' => true));
  70          $mform->addHelpButton('duedate', 'duedate', 'tool_lp');
  71  
  72          $mform->setDefault('visible', true);
  73          $mform->addHelpButton('visible', 'visible', 'tool_lp');
  74  
  75          $mform->addElement('static', 'context', get_string('category', 'tool_lp'));
  76          $mform->setDefault('context', $context->get_context_name(false));
  77          // Disable short forms.
  78          $mform->setDisableShortforms();
  79  
  80          $this->add_action_buttons(true, get_string('savechanges', 'tool_lp'));
  81  
  82      }
  83  
  84  }