MDL-20808 "Create AMF test client" Some updates to client
[moodle.git] / question / export_form.php
bloba3c33af2d3f1a32d4bce20b033a78ee768b4eacc
1 <?php
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 $i = 0 ;
22 foreach ($fileformatnames as $shortname => $fileformatname) {
23 $currentgrp1 = array();
24 $currentgrp1[] = &$mform->createElement('radio','format','',$fileformatname,$shortname);
25 $mform->addGroup($currentgrp1,"formathelp[$i]",'',array('<br />'),false);
26 $mform->setHelpButton("formathelp[$i]", array("$shortname",$fileformatname,"qformat_$shortname"));
27 $i++ ;
29 $mform->addRule("formathelp[0]",null,'required',null,'client');
30 //--------------------------------------------------------------------------------
31 $mform->addElement('header','general', get_string('general', 'form'));
33 $mform->addElement('questioncategory', 'category', get_string('category','quiz'), compact('contexts'));
34 $mform->setDefault('category', $defaultcategory);
35 $mform->setHelpButton('category', array('exportcategory', get_string('exportcategory','question'), 'quiz'));
37 $categorygroup = array();
38 $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
39 $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
40 $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
41 $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
42 $mform->setDefault('cattofile', 1);
43 $mform->setDefault('contexttofile', 1);
46 // $fileformatnames = get_import_export_formats('export');
47 // $mform->addElement('select', 'format', get_string('fileformat','quiz'), $fileformatnames);
48 // $mform->setDefault('format', 'gift');
49 // $mform->setHelpButton('format', array('export', get_string('exportquestions', 'quiz'), 'quiz'));
51 $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size'=>40));
52 $mform->setDefault('exportfilename', $defaultfilename);
53 $mform->setType('exportfilename', PARAM_FILE);
55 // set a template for the format select elements
56 $renderer =& $mform->defaultRenderer();
57 $template = "{help} {element}\n";
58 $renderer->setGroupElementTemplate($template, 'format');
60 //--------------------------------------------------------------------------------
61 $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
62 //--------------------------------------------------------------------------------