MDL-14279: use get_file_url instead of checking $CFG->slashargument manually (merge...
[moodle.git] / question / export_form.php
CommitLineData
515ed4c3 1<?php //$Id$
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();
17 foreach ($fileformatnames as $id => $fileformatname) {
79e3dd8e 18 $radioelement = &MoodleQuickForm::createElement('radio','format','',$fileformatname,$id);
19 $radioelement->setHelpButton(array("format{$id}",$fileformatname,'quiz'));
20 $radioarray[] = $radioelement;
45b68eef 21 }
22 $mform->addGroup($radioarray,'format','',array('<br />'),false);
45b68eef 23 $mform->addRule('format',null,'required',null,'client');
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);
39
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);
48 $mform->setType('exportfilename', PARAM_CLEANFILE);
49
79e3dd8e 50 // set a template for the format select elements
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}
60?>