MDL-14431
[moodle.git] / question / export_form.php
1 <?php  //$Id$
3 require_once($CFG->libdir.'/formslib.php');
5 class question_export_form extends moodleform {
7     function definition() {
8         $mform    =& $this->_form;
10         $defaultcategory   = $this->_customdata['defaultcategory'];
11         $contexts   = $this->_customdata['contexts'];
12         $defaultfilename = $this->_customdata['defaultfilename'];
13 //--------------------------------------------------------------------------------
14         $mform->addElement('header','fileformat',get_string('fileformat','quiz'));
15         $fileformatnames = get_import_export_formats('export');
16         $radioarray = array();
17         foreach ($fileformatnames as $id => $fileformatname) {
18             $radioelement = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id);
19             $radioelement->setHelpButton(array("format{$id}",$fileformatname,'quiz'));
20             $radioarray[] = $radioelement;
21         }
22         $mform->addGroup($radioarray,'format','',array('<br />'),false);
23         $mform->addRule('format',null,'required',null,'client'); 
25 //--------------------------------------------------------------------------------
26         $mform->addElement('header','general', get_string('general', 'form'));
28         $mform->addElement('questioncategory', 'category', get_string('category','quiz'), compact('contexts'));
29         $mform->setDefault('category', $defaultcategory);
30         $mform->setHelpButton('category', array('exportcategory', get_string('exportcategory','question'), 'quiz'));
32         $categorygroup = array();
33         $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
34         $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
35         $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
36         $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
37         $mform->setDefault('cattofile', 1);
38         $mform->setDefault('contexttofile', 1);
39         
41 //        $fileformatnames = get_import_export_formats('export');
42 //        $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames);
43 //        $mform->setDefault('format', 'gift');
44 //        $mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz'));
46         $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size'=>40));
47         $mform->setDefault('exportfilename', $defaultfilename);
48         $mform->setType('exportfilename', PARAM_CLEANFILE);
50         // set a template for the format select elements   
51         $renderer =& $mform->defaultRenderer();
52         $template = "{help} {element}\n";
53         $renderer->setGroupElementTemplate($template, 'format');
55 //--------------------------------------------------------------------------------
56         $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
57 //--------------------------------------------------------------------------------
58     }
59 }
60 ?>