/question/category_form.php

https://bitbucket.org/systime/screening2 · PHP · 43 lines · 32 code · 8 blank · 3 comment · 2 complexity · ae33a326db720525b5c68e697a756e9a MD5 · raw file

  1. <?php // $Id: category_form.php,v 1.4.2.3 2010/05/13 01:40:38 moodler Exp $
  2. if (!defined('MOODLE_INTERNAL')) {
  3. die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
  4. }
  5. require_once($CFG->libdir.'/formslib.php');
  6. class question_category_edit_form extends moodleform {
  7. function definition() {
  8. global $CFG;
  9. $mform =& $this->_form;
  10. $contexts = $this->_customdata['contexts'];
  11. $currentcat = $this->_customdata['currentcat'];
  12. //--------------------------------------------------------------------------------
  13. $mform->addElement('header', 'categoryheader', get_string('addcategory', 'quiz'));
  14. $questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parent', 'quiz'),
  15. array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat));
  16. $mform->setType('parent', PARAM_SEQUENCE);
  17. if (question_is_only_toplevel_category_in_context($currentcat)){
  18. $mform->hardFreeze('parent');
  19. }
  20. $mform->setHelpButton('parent', array('categoryparent', get_string('parent', 'quiz'), 'question'));
  21. $mform->addElement('text','name', get_string('name'),'maxlength="254" size="50"');
  22. $mform->setDefault('name', '');
  23. $mform->addRule('name', get_string('categorynamecantbeblank', 'quiz'), 'required', null, 'client');
  24. $mform->setType('name', PARAM_MULTILANG);
  25. $mform->addElement('textarea', 'info', get_string('categoryinfo', 'quiz'), array('rows'=> '10', 'cols'=>'45'));
  26. $mform->setDefault('info', '');
  27. $mform->setType('info', PARAM_MULTILANG);
  28. //--------------------------------------------------------------------------------
  29. $this->add_action_buttons(false, get_string('addcategory', 'quiz'));
  30. //--------------------------------------------------------------------------------
  31. $mform->addElement('hidden', 'id', 0);
  32. $mform->setType('id', PARAM_INT);
  33. }
  34. }
  35. ?>