Merge branch 'wip-MDL-28948-MOODLE_19_STABLE' of git://github.com/abgreeve/moodle...
[moodle.git] / question / export_form.php
blob95a71908931a822c453e48ed01c6b263c5a7515a
1 <?php // $Id$
3 if (!defined('MOODLE_INTERNAL')) {
4 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
7 require_once($CFG->libdir.'/formslib.php');
9 class question_export_form extends moodleform {
11 function definition() {
12 $mform =& $this->_form;
14 $defaultcategory = $this->_customdata['defaultcategory'];
15 $contexts = $this->_customdata['contexts'];
16 $defaultfilename = $this->_customdata['defaultfilename'];
17 //--------------------------------------------------------------------------------
18 $mform->addElement('header','fileformat',get_string('fileformat','quiz'));
19 $fileformatnames = get_import_export_formats('export');
20 $radioarray = array();
21 foreach ($fileformatnames as $id => $fileformatname) {
22 $radioarray[] = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id);
24 $mform->addGroup($radioarray,'format','',array('<br />'),false);
25 $mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz'));
26 $mform->addRule('format',null,'required',null,'client');
28 //--------------------------------------------------------------------------------
29 $mform->addElement('header','general', get_string('general', 'form'));
31 $mform->addElement('questioncategory', 'category', get_string('category','quiz'), compact('contexts'));
32 $mform->setDefault('category', $defaultcategory);
33 $mform->setHelpButton('category', array('exportcategory', get_string('exportcategory','question'), 'quiz'));
35 $categorygroup = array();
36 $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
37 $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
38 $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
39 $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
40 $mform->setDefault('cattofile', 1);
41 $mform->setDefault('contexttofile', 1);
44 // $fileformatnames = get_import_export_formats('export');
45 // $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames);
46 // $mform->setDefault('format', 'gift');
47 // $mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz'));
49 $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size'=>40));
50 $mform->setDefault('exportfilename', $defaultfilename);
51 $mform->setType('exportfilename', PARAM_CLEANFILE);
54 //--------------------------------------------------------------------------------
55 $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
56 //--------------------------------------------------------------------------------