MDL-29808 qbehaviours: update to use ->dependencies in version.php
[moodle.git] / question / export_form.php
CommitLineData
aeb15530 1<?php
f7c1dfaf
TH
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
a17b297d 27defined('MOODLE_INTERNAL') || die();
bfebaf64 28
f7c1dfaf
TH
29require_once($CFG->libdir . '/formslib.php');
30
515ed4c3 31
f7c1dfaf
TH
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 */
515ed4c3 38class question_export_form extends moodleform {
39
c7df5006 40 protected function definition() {
f7c1dfaf 41 $mform = $this->_form;
515ed4c3 42
f7c1dfaf
TH
43 $defaultcategory = $this->_customdata['defaultcategory'];
44 $contexts = $this->_customdata['contexts'];
45
46 // Choice of format, with help.
47 $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
45b68eef 48 $fileformatnames = get_import_export_formats('export');
49 $radioarray = array();
05f7f7c1 50 $i = 0 ;
f94902db 51 foreach ($fileformatnames as $shortname => $fileformatname) {
05f7f7c1 52 $currentgrp1 = array();
f7c1dfaf
TH
53 $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
54 $mform->addGroup($currentgrp1, "formathelp[$i]", '', array('<br />'), false);
55 $mform->addHelpButton("formathelp[$i]", $shortname, 'qformat_' . $shortname);
05f7f7c1 56 $i++ ;
45b68eef 57 }
f7c1dfaf
TH
58 $mform->addRule("formathelp[0]", null, 'required', null, 'client');
59
60 // Export options.
61 $mform->addElement('header', 'general', get_string('general', 'form'));
515ed4c3 62
5fcefc97 63 $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
515ed4c3 64 $mform->setDefault('category', $defaultcategory);
5fcefc97 65 $mform->addHelpButton('category', 'exportcategory', 'question');
515ed4c3 66
67 $categorygroup = array();
f7c1dfaf
TH
68 $categorygroup[] = $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
69 $categorygroup[] = $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
515ed4c3 70 $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
71 $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
72 $mform->setDefault('cattofile', 1);
73 $mform->setDefault('contexttofile', 1);
aeb15530 74
f7c1dfaf
TH
75 // Set a template for the format select elements
76 $renderer = $mform->defaultRenderer();
79e3dd8e 77 $template = "{help} {element}\n";
78 $renderer->setGroupElementTemplate($template, 'format');
515ed4c3 79
f7c1dfaf
TH
80 // Submit buttons.
81 $this->add_action_buttons(false, get_string('exportquestions', 'question'));
515ed4c3 82 }
83}