MDL-11051 grade export - do not use quickforms elements directly
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class grade_export_form extends moodleform {
|
||||
function definition (){
|
||||
function definition() {
|
||||
global $CFG, $COURSE, $USER;
|
||||
|
||||
$mform =& $this->_form;
|
||||
@@ -45,26 +45,21 @@ class grade_export_form extends moodleform {
|
||||
$mform->addElement('header', 'general', get_string('gradeitemsinc', 'grades')); // TODO: localize
|
||||
|
||||
$mform->addElement('hidden', 'id', $COURSE->id);
|
||||
|
||||
if ($grade_items = grade_item::fetch_all(array('courseid'=>$COURSE->id))) {
|
||||
$noidnumber = false;
|
||||
foreach ($grade_items as $grade_item) {
|
||||
|
||||
if ($plugin != 'xmlexport' || $grade_item->idnumber) {
|
||||
$element = new HTML_QuickForm_advcheckbox('itemids['.$grade_item->id.']', null, $grade_item->get_name(), array('selected'=>'selected'), array(0, $grade_item->id));
|
||||
$element->setChecked(1);
|
||||
$mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name());
|
||||
$mform->setDefault('itemids['.$grade_item->id.']', 1);
|
||||
|
||||
} else {
|
||||
$mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name(), get_string('noidnumber'));
|
||||
$mform->hardFreeze('itemids['.$grade_item->id.']');
|
||||
$noidnumber = true;
|
||||
$element = new HTML_QuickForm_advcheckbox('itemids['.$grade_item->id.']', null, $grade_item->get_name(), array('disabled'=>'disabled'), array(0, $grade_item->id));
|
||||
}
|
||||
|
||||
$mform->addElement($element);
|
||||
}
|
||||
}
|
||||
|
||||
if ($noidnumber) {
|
||||
$mform->addElement('static', 'noidnumber', '', get_string('noidnumber'));
|
||||
}
|
||||
|
||||
$options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
|
||||
$mform->addElement('select', 'previewrows', 'Preview rows', $options); // TODO: localize
|
||||
$mform->setType('previewrows', PARAM_INT);
|
||||
|
||||
@@ -53,7 +53,13 @@ $mform = new grade_export_form();
|
||||
// process post information
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data->itemids) {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
$items = array();
|
||||
foreach ($data->itemids as $itemid=>$selected) {
|
||||
if ($selected) {
|
||||
$items[] = $itemid;
|
||||
}
|
||||
}
|
||||
$itemidsurl = implode(",", $items);
|
||||
} else {
|
||||
//error?
|
||||
$itemidsurl = '';
|
||||
|
||||
@@ -5,7 +5,6 @@ class grade_export_txt_form extends moodleform {
|
||||
function definition (){
|
||||
global $CFG, $COURSE;
|
||||
|
||||
include_once($CFG->libdir.'/pear/HTML/QuickForm/advcheckbox.php');
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('advcheckbox', 'export_letters', get_string('exportletters', 'grades'));
|
||||
@@ -17,15 +16,13 @@ class grade_export_txt_form extends moodleform {
|
||||
$mform->addElement('hidden', 'id', $COURSE->id);
|
||||
if ($grade_items = grade_item::fetch_all(array('courseid'=>$COURSE->id))) {
|
||||
foreach ($grade_items as $grade_item) {
|
||||
$element = new HTML_QuickForm_advcheckbox('itemids['.$grade_item->id.']', null, $grade_item->get_name(), array('selected'=>'selected'), array(0, $grade_item->id));
|
||||
$element->setChecked(1);
|
||||
$mform->addElement($element);
|
||||
$mform->addElement('advcheckbox', 'itemids['.$grade_item->id.']', $grade_item->get_name());
|
||||
$mform->setDefault('itemids['.$grade_item->id.']', 1);
|
||||
}
|
||||
}
|
||||
$options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
|
||||
$mform->addElement('select', 'previewrows', 'Preview rows', $options); // TODO: localize
|
||||
$mform->setType('previewrows', PARAM_INT);
|
||||
include_once($CFG->libdir.'/pear/HTML/QuickForm/radio.php');
|
||||
$radio = array();
|
||||
$radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
|
||||
$radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
|
||||
|
||||
@@ -54,7 +54,13 @@ $mform = new grade_export_txt_form();
|
||||
// process post information
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data->itemids) {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
$items = array();
|
||||
foreach ($data->itemids as $itemid=>$selected) {
|
||||
if ($selected) {
|
||||
$items[] = $itemid;
|
||||
}
|
||||
}
|
||||
$itemidsurl = implode(",", $items);
|
||||
} else {
|
||||
//error?
|
||||
$itemidsurl = '';
|
||||
|
||||
@@ -53,7 +53,13 @@ $mform = new grade_export_form();
|
||||
// process post information
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data->itemids) {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
$items = array();
|
||||
foreach ($data->itemids as $itemid=>$selected) {
|
||||
if ($selected) {
|
||||
$items[] = $itemid;
|
||||
}
|
||||
}
|
||||
$itemidsurl = implode(",", $items);
|
||||
} else {
|
||||
//error?
|
||||
$itemidsurl = '';
|
||||
|
||||
@@ -53,7 +53,13 @@ $mform = new grade_export_form(null, array('plugin'=>'xmlexport'));
|
||||
// process post information
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data->itemids) {
|
||||
$itemidsurl = implode(",",$data->itemids);
|
||||
$items = array();
|
||||
foreach ($data->itemids as $itemid=>$selected) {
|
||||
if ($selected) {
|
||||
$items[] = $itemid;
|
||||
}
|
||||
}
|
||||
$itemidsurl = implode(",", $items);
|
||||
} else {
|
||||
//error?
|
||||
$itemidsurl = '';
|
||||
|
||||
Reference in New Issue
Block a user