[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/ -> export_form.php (source)

   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   * Defines the export questions form.
  19   *
  20   * @package    moodlecore
  21   * @subpackage questionbank
  22   * @copyright  2007 Jamie Pratt me@jamiep.org
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  require_once($CFG->libdir . '/formslib.php');
  30  
  31  
  32  /**
  33   * Form to export questions from the question bank.
  34   *
  35   * @copyright  2007 Jamie Pratt me@jamiep.org
  36   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class question_export_form extends moodleform {
  39  
  40      protected function definition() {
  41          global $OUTPUT;
  42  
  43          $mform = $this->_form;
  44  
  45          $defaultcategory = $this->_customdata['defaultcategory'];
  46          $contexts = $this->_customdata['contexts'];
  47  
  48          // Choice of format, with help.
  49          $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
  50  
  51          $fileformatnames = get_import_export_formats('export');
  52          $radioarray = array();
  53          $separators = array();
  54          foreach ($fileformatnames as $shortname => $fileformatname) {
  55              $radioarray[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
  56  
  57              $separator = '';
  58              if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) {
  59                  $separator .= $OUTPUT->help_icon('pluginname', 'qformat_' . $shortname);
  60              }
  61              $separator .= '<br>';
  62              $separators[] = $separator;
  63          }
  64  
  65          $radioarray[] = $mform->createElement('static', 'makelasthelpiconshowup', '');
  66          $mform->addGroup($radioarray, "formatchoices", '', $separators, false);
  67          $mform->addRule("formatchoices", null, 'required', null, 'client');
  68  
  69          // Export options.
  70          $mform->addElement('header', 'general', get_string('general', 'form'));
  71  
  72          $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
  73          $mform->setDefault('category', $defaultcategory);
  74          $mform->addHelpButton('category', 'exportcategory', 'question');
  75  
  76          $categorygroup = array();
  77          $categorygroup[] = $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
  78          $categorygroup[] = $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
  79          $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
  80          $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
  81          $mform->setDefault('cattofile', 1);
  82          $mform->setDefault('contexttofile', 1);
  83  
  84          // Set a template for the format select elements
  85          $renderer = $mform->defaultRenderer();
  86          $template = "{help} {element}\n";
  87          $renderer->setGroupElementTemplate($template, 'format');
  88  
  89          // Submit buttons.
  90          $this->add_action_buttons(false, get_string('exportquestions', 'question'));
  91      }
  92  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1