Merge branch 'wip-MDL-23532-master' of git://github.com/samhemelryk/moodle
[moodle.git] / question / export_form.php
blobf76a991b6fbb6b6c3acb35886fd38fe73ec9301d
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 //--------------------------------------------------------------------------------
17 $mform->addElement('header','fileformat',get_string('fileformat','quiz'));
18 $fileformatnames = get_import_export_formats('export');
19 $radioarray = array();
20 $i = 0 ;
21 foreach ($fileformatnames as $shortname => $fileformatname) {
22 $currentgrp1 = array();
23 $currentgrp1[] = &$mform->createElement('radio','format','',$fileformatname,$shortname);
24 $mform->addGroup($currentgrp1,"formathelp[$i]",'',array('<br />'),false);
25 $mform->addHelpButton("formathelp[$i]", $shortname, 'qformat_'.$shortname);
26 $i++ ;
28 $mform->addRule("formathelp[0]",null,'required',null,'client');
29 //--------------------------------------------------------------------------------
30 $mform->addElement('header','general', get_string('general', 'form'));
32 $mform->addElement('questioncategory', 'category', get_string('exportcategory', 'question'), compact('contexts'));
33 $mform->setDefault('category', $defaultcategory);
34 $mform->addHelpButton('category', 'exportcategory', 'question');
36 $categorygroup = array();
37 $categorygroup[] =& $mform->createElement('checkbox', 'cattofile', '', get_string('tofilecategory', 'question'));
38 $categorygroup[] =& $mform->createElement('checkbox', 'contexttofile', '', get_string('tofilecontext', 'question'));
39 $mform->addGroup($categorygroup, 'categorygroup', '', '', false);
40 $mform->disabledIf('categorygroup', 'cattofile', 'notchecked');
41 $mform->setDefault('cattofile', 1);
42 $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');
48 // set a template for the format select elements
49 $renderer =& $mform->defaultRenderer();
50 $template = "{help} {element}\n";
51 $renderer->setGroupElementTemplate($template, 'format');
53 //--------------------------------------------------------------------------------
54 $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
55 //--------------------------------------------------------------------------------