@ -39,7 +39,7 @@ class mod_attendance_export_form extends moodleform {
* @return void
* @return void
*/
*/
public function definition() {
public function definition() {
global $USER, $DB, $PAGE;
global $USER, $DB, $PAGE, $CFG ;
$mform =& $this->_form;
$mform =& $this->_form;
$course = $this->_customdata['course'];
$course = $this->_customdata['course'];
$cm = $this->_customdata['cm'];
$cm = $this->_customdata['cm'];
@ -102,19 +102,37 @@ class mod_attendance_export_form extends moodleform {
$PAGE->requires->yui_module('moodle-mod_attendance-groupfilter', 'M.mod_attendance.groupfilter.init', array($opts));
$PAGE->requires->yui_module('moodle-mod_attendance-groupfilter', 'M.mod_attendance.groupfilter.init', array($opts));
$ident = array();
$ident = array();
$ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance'));
$checkedfields = array();
$ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username'));
$adminsetfields = get_config('attendance', 'defaultexportfields');
if (in_array('id', explode(',', $adminsetfields))) {
$ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance'));
$checkedfields['ident[id]'] = true;
}
$extrafields = get_extra_user_fields($modcontext);
foreach ($extrafields as $field) {
$ident[] =& $mform->createElement('checkbox', $field, '', get_string( $field));
$mform->setType($field, PARAM_NOTAGS);
$checkedfields['ident['. $field .']'] = true;
}
$optional = array('idnumber', 'institution', 'department');
require_once($CFG->dirroot . '/user/profile/lib.php');
foreach ($optional as $opt) {
$customfields = profile_get_custom_fields();
$ident[] =& $mform->createElement('checkbox', $opt, '', get_string($opt));
$mform->setType($opt, PARAM_NOTAGS);
foreach ($customfields as $field) {
if ((is_siteadmin($USER) || $field->visible == PROFILE_VISIBLE_ALL)
& & in_array($field->shortname, explode(',', $adminsetfields))) {
$ident[] =& $mform->createElement('checkbox', $field->shortname, '', $field->name);
$mform->setType($field->shortname, PARAM_NOTAGS);
$checkedfields['ident['. $field->shortname .']'] = true;
}
}
}
$mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('< br / > '), true);
if (count($ident) > 0) {
$mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
$mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('< br / > '), true);
$mform->setDefaults($checkedfields);
}
$mform->setType('id', PARAM_INT);
$mform->setType('id', PARAM_INT);
$mform->setType('uname', PARAM_INT);
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
$mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes'));
$mform->setDefault('includeallsessions', true);
$mform->setDefault('includeallsessions', true);