MDL-20636 Fix @package names and PHPdoc layout.
[moodle.git] / question / export_form.php
CommitLineData
aeb15530 1<?php
515ed4c3 2
f7c1dfaf
TH
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * Defines the export questions form.
20 *
21 * @package moodlecore
22 * @subpackage questionbank
23 * @copyright 2007 Jamie Pratt me@jamiep.org
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27
bfebaf64 28if (!defined('MOODLE_INTERNAL')) {
f7c1dfaf 29 die('Direct access to this script is forbidden.');
bfebaf64
MD
30}
31
f7c1dfaf
TH
32require_once($CFG->libdir . '/formslib.php');
33
515ed4c3 34
f7c1dfaf
TH
35/**
36 * Form to export questions from the question bank.
37 *
38 * @copyright 2007 Jamie Pratt me@jamiep.org
39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40 */
515ed4c3 41class question_export_form extends moodleform {
42
43 function definition() {
f7c1dfaf 44 $mform = $this->_form;
515ed4c3 45
f7c1dfaf
TH
46 $defaultcategory = $this->_customdata['defaultcategory'];
47 $contexts = $this->_customdata['contexts'];
48
49 // Choice of format, with help.
50 $mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
45b68eef 51 $fileformatnames = get_import_export_formats('export');
52 $radioarray = array();
05f7f7c1 53 $i = 0 ;
f94902db 54 foreach ($fileformatnames as $shortname => $fileformatname) {
05f7f7c1 55 $currentgrp1 = array();
f7c1dfaf
TH
56 $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
57 $mform->addGroup($currentgrp1, "formathelp[$i]", '', array('<br />'), false);
58 $mform->addHelpButton("formathelp[$i]", $shortname, 'qformat_' . $shortname);
05f7f7c1 59 $i++ ;
45b68eef 60 }
f7c1dfaf
TH
61 $mform->addRule("formathelp[0]", null, 'required', null, 'client');
62
63 // Export options.
64 $mform->addElement('header', 'general', get_string('general', 'form'));
515ed4c3 65
5fcefc97 66 $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
515ed4c3 67 $mform->setDefault('category', $defaultcategory);
5fcefc97 68 $mform->addHelpButton('category', 'exportcategory', 'question');
515ed4c3 69
70 $categorygroup = array();
f7c1dfaf
TH
71 $categorygroup[] = $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
72 $categorygroup[] = $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
515ed4c3 73 $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
74 $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
75 $mform->setDefault('cattofile', 1);
76 $mform->setDefault('contexttofile', 1);
aeb15530 77
f7c1dfaf
TH
78 // Set a template for the format select elements
79 $renderer = $mform->defaultRenderer();
79e3dd8e 80 $template = "{help} {element}\n";
81 $renderer->setGroupElementTemplate($template, 'format');
515ed4c3 82
f7c1dfaf
TH
83 // Submit buttons.
84 $this->add_action_buttons(false, get_string('exportquestions', 'question'));
515ed4c3 85 }
86}