MDL-33430 Set newcontextid and newitemid when sending file to the pool
[moodle.git] / question / export_form.php
blobb8a27ca7bfe81f8a1e6fa5cc651d3b8a1b621d1e
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.
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/>.
17 /**
18 * Defines the export questions form.
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
27 defined('MOODLE_INTERNAL') || die();
29 require_once($CFG->libdir . '/formslib.php');
32 /**
33 * Form to export questions from the question bank.
35 * @copyright 2007 Jamie Pratt me@jamiep.org
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class question_export_form extends moodleform {
40 protected function definition() {
41 $mform = $this->_form;
43 $defaultcategory = $this->_customdata['defaultcategory'];
44 $contexts = $this->_customdata['contexts'];
46 // Choice of format, with help.
47 $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
48 $fileformatnames = get_import_export_formats('export');
49 $radioarray = array();
50 $i = 0 ;
51 foreach ($fileformatnames as $shortname => $fileformatname) {
52 $currentgrp1 = array();
53 $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
54 $mform->addGroup($currentgrp1, "formathelp[$i]", '&#160;', array('<br />'), false);
56 if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) {
57 $mform->addHelpButton("formathelp[$i]", 'pluginname', 'qformat_' . $shortname);
60 $i++ ;
62 $mform->addRule("formathelp[0]", null, 'required', null, 'client');
64 // Export options.
65 $mform->addElement('header', 'general', get_string('general', 'form'));
67 $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
68 $mform->setDefault('category', $defaultcategory);
69 $mform->addHelpButton('category', 'exportcategory', 'question');
71 $categorygroup = array();
72 $categorygroup[] = $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
73 $categorygroup[] = $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
74 $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
75 $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
76 $mform->setDefault('cattofile', 1);
77 $mform->setDefault('contexttofile', 1);
79 // Set a template for the format select elements
80 $renderer = $mform->defaultRenderer();
81 $template = "{help} {element}\n";
82 $renderer->setGroupElementTemplate($template, 'format');
84 // Submit buttons.
85 $this->add_action_buttons(false, get_string('exportquestions', 'question'));