Moving setHelpButton('format',.. after addgroup($radioarray,'format' so it applies...
[moodle.git] / question / export_form.php
CommitLineData
aeb15530 1<?php
515ed4c3 2
3require_once($CFG->libdir.'/formslib.php');
4
5class question_export_form extends moodleform {
6
7 function definition() {
8 $mform =& $this->_form;
9
10 $defaultcategory = $this->_customdata['defaultcategory'];
11 $contexts = $this->_customdata['contexts'];
12 $defaultfilename = $this->_customdata['defaultfilename'];
45b68eef 13//--------------------------------------------------------------------------------
14 $mform->addElement('header','fileformat',get_string('fileformat','quiz'));
15 $fileformatnames = get_import_export_formats('export');
16 $radioarray = array();
f94902db 17 foreach ($fileformatnames as $shortname => $fileformatname) {
18 $radioelement = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$shortname);
79e3dd8e 19 $radioarray[] = $radioelement;
45b68eef 20 }
21 $mform->addGroup($radioarray,'format','',array('<br />'),false);
f942cd72 22 $mform->setHelpButton('format', array("$shortname",$fileformatname,"qformat_$shortname"));
aeb15530 23 $mform->addRule('format',null,'required',null,'client');
45b68eef 24
515ed4c3 25//--------------------------------------------------------------------------------
26 $mform->addElement('header','general', get_string('general', 'form'));
27
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'));
31
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);
aeb15530 39
515ed4c3 40
45b68eef 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'));
515ed4c3 45
46 $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size'=>40));
47 $mform->setDefault('exportfilename', $defaultfilename);
bed79931 48 $mform->setType('exportfilename', PARAM_FILE);
515ed4c3 49
aeb15530 50 // set a template for the format select elements
79e3dd8e 51 $renderer =& $mform->defaultRenderer();
52 $template = "{help} {element}\n";
53 $renderer->setGroupElementTemplate($template, 'format');
515ed4c3 54
55//--------------------------------------------------------------------------------
56 $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
57//--------------------------------------------------------------------------------
58 }
59}
aeb15530 60