[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/question/type/random/ -> edit_random_form.php (source)

   1  <?php
   2  /**
   3   * Defines the editing form for the random question type.
   4   *
   5   * @copyright &copy; 2007 Jamie Pratt
   6   * @author Jamie Pratt me@jamiep.org
   7   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
   8   * @package questionbank
   9   * @subpackage questiontypes
  10   */
  11  
  12  /**
  13   * random editing form definition.
  14   */
  15  class question_edit_random_form extends question_edit_form {
  16      /**
  17       * Build the form definition.
  18       *
  19       * This adds all the form files that the default question type supports.
  20       * If your question type does not support all these fields, then you can
  21       * override this method and remove the ones you don't want with $mform->removeElement().
  22       */
  23      function definition() {
  24          global $COURSE, $CFG;
  25  
  26          $qtype = $this->qtype();
  27          $langfile = "qtype_$qtype";
  28  
  29          $mform =& $this->_form;
  30  
  31          // Standard fields at the start of the form.
  32          $mform->addElement('header', 'generalheader', get_string("general", 'form'));
  33  
  34          $mform->addElement('questioncategory', 'category', get_string('category', 'quiz'), 
  35                  array('contexts' => $this->contexts->having_cap('moodle/question:useall')));
  36  
  37          $mform->addElement('advcheckbox', 'questiontext', get_string("recurse", "quiz"), null, null, array(0, 1));
  38  
  39          // Standard fields at the end of the form.
  40          $mform->addElement('hidden', 'questiontextformat', 0);
  41          $mform->setType('questiontextformat', PARAM_INT);
  42  
  43          $mform->addElement('hidden', 'id');
  44          $mform->setType('id', PARAM_INT);
  45  
  46          $mform->addElement('hidden', 'qtype');
  47          $mform->setType('qtype', PARAM_ALPHA);
  48  
  49          $mform->addElement('hidden', 'inpopup');
  50          $mform->setType('inpopup', PARAM_INT);
  51  
  52          $mform->addElement('hidden', 'versioning');
  53          $mform->setType('versioning', PARAM_BOOL);
  54  
  55          $mform->addElement('hidden', 'cmid');
  56          $mform->setType('cmid', PARAM_INT);
  57          $mform->setDefault('cmid', 0);
  58  
  59          $mform->addElement('hidden', 'courseid');
  60          $mform->setType('courseid', PARAM_INT);
  61          $mform->setDefault('courseid', 0);
  62  
  63          $mform->addElement('hidden', 'returnurl');
  64          $mform->setType('returnurl', PARAM_LOCALURL);
  65          $mform->setDefault('returnurl', 0);
  66  
  67          $buttonarray = array();
  68          $buttonarray[] = &$mform->createElement('submit', 'submitbutton', get_string('savechanges'));
  69  
  70          $buttonarray[] = &$mform->createElement('cancel');
  71          $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
  72          $mform->closeHeaderBefore('buttonar');
  73      }
  74      function validation($fromform, $files) {
  75          //validation of category
  76          //is not relevant for this question type
  77          return array();
  78      }
  79      function qtype() {
  80          return 'random';
  81      }
  82  }
  83  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7