MDL-53728 question import/export: improve form structure

This commit is contained in:
Tim Hunt 2016-04-06 15:31:35 +01:00
parent aeccf4bd94
commit f06eacd99d
2 changed files with 25 additions and 17 deletions

View File

@ -38,6 +38,8 @@ require_once($CFG->libdir . '/formslib.php');
class question_export_form extends moodleform {
protected function definition() {
global $OUTPUT;
$mform = $this->_form;
$defaultcategory = $this->_customdata['defaultcategory'];
@ -45,21 +47,24 @@ class question_export_form extends moodleform {
// Choice of format, with help.
$mform->addElement('header', 'fileformat', get_string('fileformat', 'question'));
$fileformatnames = get_import_export_formats('export');
$radioarray = array();
$i = 0 ;
$separators = array();
foreach ($fileformatnames as $shortname => $fileformatname) {
$currentgrp1 = array();
$currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
$mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('<br />'), false);
$radioarray[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
$separator = '';
if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) {
$mform->addHelpButton("formathelp[{$i}]", 'pluginname', 'qformat_' . $shortname);
$separator .= $OUTPUT->help_icon('pluginname', 'qformat_' . $shortname);
}
$i++ ;
$separator .= '<br>';
$separators[] = $separator;
}
$mform->addRule("formathelp[0]", null, 'required', null, 'client');
$radioarray[] = $mform->createElement('static', 'makelasthelpiconshowup', '');
$mform->addGroup($radioarray, "formatchoices", '', $separators, false);
$mform->addRule("formatchoices", null, 'required', null, 'client');
// Export options.
$mform->addElement('header', 'general', get_string('general', 'form'));

View File

@ -38,7 +38,8 @@ require_once($CFG->libdir . '/formslib.php');
class question_import_form extends moodleform {
protected function definition() {
global $COURSE;
global $OUTPUT;
$mform = $this->_form;
$defaultcategory = $this->_customdata['defaultcategory'];
@ -49,19 +50,21 @@ class question_import_form extends moodleform {
$fileformatnames = get_import_export_formats('import');
$radioarray = array();
$i = 0 ;
$separators = array();
foreach ($fileformatnames as $shortname => $fileformatname) {
$currentgrp1 = array();
$currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
$mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('<br />'), false);
$radioarray[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname);
$separator = '';
if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) {
$mform->addHelpButton("formathelp[{$i}]", 'pluginname', 'qformat_' . $shortname);
$separator .= $OUTPUT->help_icon('pluginname', 'qformat_' . $shortname);
}
$i++ ;
$separator .= '<br>';
$separators[] = $separator;
}
$mform->addRule("formathelp[0]", null, 'required', null, 'client');
$radioarray[] = $mform->createElement('static', 'makelasthelpiconshowup', '');
$mform->addGroup($radioarray, "formatchoices", '', $separators, false);
$mform->addRule("formatchoices", null, 'required', null, 'client');
// Import options.
$mform->addElement('header','general', get_string('general', 'form'));