MDL-23479 backup - chat revised & old code deleted (but non-existing restore logs)
[moodle.git] / question / export_form.php
CommitLineData
aeb15530 1<?php
515ed4c3 2
bfebaf64
MD
3if (!defined('MOODLE_INTERNAL')) {
4 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
5}
6
515ed4c3 7require_once($CFG->libdir.'/formslib.php');
8
9class question_export_form extends moodleform {
10
11 function definition() {
12 $mform =& $this->_form;
13
14 $defaultcategory = $this->_customdata['defaultcategory'];
15 $contexts = $this->_customdata['contexts'];
16 $defaultfilename = $this->_customdata['defaultfilename'];
45b68eef 17//--------------------------------------------------------------------------------
18 $mform->addElement('header','fileformat',get_string('fileformat','quiz'));
19 $fileformatnames = get_import_export_formats('export');
20 $radioarray = array();
05f7f7c1 21 $i = 0 ;
f94902db 22 foreach ($fileformatnames as $shortname => $fileformatname) {
05f7f7c1
PP
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++ ;
45b68eef 28 }
5a5487ff 29 $mform->addRule("formathelp[0]",null,'required',null,'client');
515ed4c3 30//--------------------------------------------------------------------------------
31 $mform->addElement('header','general', get_string('general', 'form'));
32
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'));
36
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);
aeb15530 44
515ed4c3 45
45b68eef 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'));
515ed4c3 50
51 $mform->addElement('text', 'exportfilename', get_string('exportname', 'quiz'), array('size'=>40));
52 $mform->setDefault('exportfilename', $defaultfilename);
bed79931 53 $mform->setType('exportfilename', PARAM_FILE);
515ed4c3 54
aeb15530 55 // set a template for the format select elements
79e3dd8e 56 $renderer =& $mform->defaultRenderer();
57 $template = "{help} {element}\n";
58 $renderer->setGroupElementTemplate($template, 'format');
515ed4c3 59
60//--------------------------------------------------------------------------------
61 $this->add_action_buttons(false, get_string('exportquestions', 'quiz'));
62//--------------------------------------------------------------------------------
63 }
64}
aeb15530 65