function definition() { global $CFG; $mform = & $this->_form; $course = $this->_customdata['course']; $context = $this->_customdata['context']; // the upload manager is used directly in post precessing, moodleform::save_files() is not used yet //$this->set_upload_manager(new upload_manager('attachment')); $mform->addElement('header', 'general', ''); //fill in the data depending on page params //later using set_data $mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile')); $mform->addRule('attachment', null, 'required'); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices); if (array_key_exists('cfg', $choices)) { $mform->setDefault('delimiter_name', 'cfg'); } else if (get_string('listsep', 'langconfig') == ';') { $mform->setDefault('delimiter_name', 'semicolon'); } else { $mform->setDefault('delimiter_name', 'comma'); } $choices = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices); $mform->setDefault('encoding', 'UTF-8'); $roles = get_assignable_roles($context); $mform->addElement('select', 'roleassign', get_string('roleassign', 'local_mass_enroll'), $roles); $mform->setDefault('roleassign', 5); //student $ids = array ( 'idnumber' => get_string('idnumber', 'local_mass_enroll'), 'username' => get_string('username', 'local_mass_enroll'), 'email' => get_string('email') ); $mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'local_mass_enroll'), $ids); $mform->setDefault('firstcolumn', 'idnumber'); $mform->addElement('selectyesno', 'creategroups', get_string('creategroups', 'local_mass_enroll')); $mform->setDefault('creategroups', 1); $mform->addElement('selectyesno', 'creategroupings', get_string('creategroupings', 'local_mass_enroll')); $mform->setDefault('creategroupings', 1); $mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll')); $mform->setDefault('mailreport', 1); //------------------------------------------------------------------------------- // buttons $this->add_action_buttons(true, get_string('enroll', 'local_mass_enroll')); $mform->addElement('hidden', 'id', $course->id); $mform->setType('id', PARAM_INT); }
public function definition() { global $CFG, $USER; $mform =& $this->_form; $mform->addElement('header', 'settingsheader', get_string('upload')); $mform->addElement('filepicker', 'userfile', get_string('file')); $mform->addRule('userfile', null, 'required'); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices); if (array_key_exists('cfg', $choices)) { $mform->setDefault('delimiter_name', 'cfg'); } else { if (get_string('listsep', 'langconfig') == ';') { $mform->setDefault('delimiter_name', 'semicolon'); } else { $mform->setDefault('delimiter_name', 'comma'); } } $choices = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices); $mform->setDefault('encoding', 'UTF-8'); $choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000); $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'tool_uploaduser'), $choices); $mform->setType('previewrows', PARAM_INT); $choices = array(UU_ADDNEW => get_string('uuoptype_addnew', 'tool_uploaduser'), UU_ADDINC => get_string('uuoptype_addinc', 'tool_uploaduser'), UU_ADD_UPDATE => get_string('uuoptype_addupdate', 'tool_uploaduser'), UU_UPDATE => get_string('uuoptype_update', 'tool_uploaduser')); $mform->addElement('select', 'uutype', get_string('uuoptype', 'tool_uploaduser'), $choices); $this->add_action_buttons(false, get_string('uploadusers', 'tool_uploaduser')); }
function definition() { $mform = $this->_form; $mform->addElement('header', 'settingsheader', get_string('upload')); $mform->addElement('filepicker', 'userfile', get_string('file')); $mform->addRule('userfile', null, 'required'); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'local_users'), $choices); if (array_key_exists('cfg', $choices)) { $mform->setDefault('delimiter_name', 'cfg'); } else if (get_string('listsep', 'langconfig') == ';') { $mform->setDefault('delimiter_name', 'semicolon'); } else { $mform->setDefault('delimiter_name', 'comma'); } $choices = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'local_users'), $choices); $mform->setDefault('encoding', 'UTF-8'); $choices = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000); $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'local_users'), $choices); $mform->setType('previewrows', PARAM_INT); $this->add_action_buttons(true, get_string('upload')); }
function definition() { $mform =& $this->_form; $mform->addElement('file', 'userfile', get_string('csvtextfile', 'facetoface')); $mform->setType('userfile', PARAM_FILE); $mform->addRule('userfile', null, 'required'); $encodings = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings); $mform->addElement('checkbox', 'suppressemail', '', get_string('suppressemailforattendees', 'facetoface')); }
function definition() { global $COURSE; $mform =& $this->_form; if (isset($this->_customdata)) { // hardcoding plugin names here is hacky $features = $this->_customdata; } else { $features = array(); } // course id needs to be passed for auth purposes $mform->addElement('hidden', 'id', optional_param('id', 0, PARAM_INT)); $mform->setType('id', PARAM_INT); $mform->addElement('header', 'general', get_string('importfile', 'grades')); // Restrict the possible upload file types. if (!empty($features['acceptedtypes'])) { $acceptedtypes = $features['acceptedtypes']; } else { $acceptedtypes = '*'; } // File upload. $mform->addElement('filepicker', 'userfile', get_string('file'), null, array('accepted_types' => $acceptedtypes)); $mform->addRule('userfile', null, 'required'); $encodings = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings); if (!empty($features['includeseparator'])) { $radio = array(); $radio[] = $mform->createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab'); $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma'); $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepcolon', 'grades'), 'colon'); $radio[] = $mform->createElement('radio', 'separator', null, get_string('sepsemicolon', 'grades'), 'semicolon'); $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false); $mform->setDefault('separator', 'comma'); } if (!empty($features['verbosescales'])) { $options = array(1 => get_string('yes'), 0 => get_string('no')); $mform->addElement('select', 'verbosescales', get_string('verbosescales', 'grades'), $options); } $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000); $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options); // TODO: localize $mform->setType('previewrows', PARAM_INT); $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE)); $mform->setType('groupid', PARAM_INT); $this->add_action_buttons(false, get_string('uploadgrades', 'grades')); }
function definition() { global $CFG; $mform = & $this->_form; //$mform->addElement('header', 'general', get_string('bulkenrol','block_learning_plan')); //fill in the data depending on page params //later using set_data $mform->addElement('filepicker', 'attachment', get_string('location', 'enrol_flatfile')); $mform->addRule('attachment', null, 'required'); $choices = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_uploaduser'), $choices); if (array_key_exists('cfg', $choices)) { $mform->setDefault('delimiter_name', 'cfg'); } else if (get_string('listsep', 'langconfig') == ';') { $mform->setDefault('delimiter_name', 'semicolon'); } else { $mform->setDefault('delimiter_name', 'comma'); } $choices = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices); $mform->setDefault('encoding', 'UTF-8'); $mform->addElement('hidden','roleassign'); $mform->setDefault('roleassign', 5); //student $mform->setType('roleassign','int'); $ids = array ( 'username' => get_string('username', 'local_mass_enroll'), 'idnumber' => get_string('idnumber', 'local_mass_enroll'), 'email' => get_string('email') ); $mform->addElement('select', 'firstcolumn', get_string('firstcolumn', 'block_learning_plan'), $ids); $mform->setDefault('firstcolumn', 'username'); //$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_mass_enroll')); //$mform->setDefault('mailreport', 1); $this->add_action_buttons(true, get_string('enroll_lp', 'block_learning_plan')); }
function definition() { global $CFG; $mform =& $this->_form; $cmid = $this->_customdata['id']; $mform->addElement('filepicker', 'recordsfile', get_string('csvfile', 'data')); $delimiters = csv_import_reader::get_delimiter_list(); $mform->addElement('select', 'fielddelimiter', get_string('fielddelimiter', 'data'), $delimiters); $mform->setDefault('fielddelimiter', 'comma'); $mform->addElement('text', 'fieldenclosure', get_string('fieldenclosure', 'data')); $choices = textlib::get_encodings(); $mform->addElement('select', 'encoding', get_string('fileencoding', 'mod_data'), $choices); $mform->setDefault('encoding', 'UTF-8'); $submit_string = get_string('submit'); // data id $mform->addElement('hidden', 'd'); $mform->setType('d', PARAM_INT); $this->add_action_buttons(false, $submit_string); }
/** * Tests the static get_encodings method * @return void */ public function test_get_encodings() { $encodings = textlib::get_encodings(); $this->assertTrue(is_array($encodings)); $this->assertTrue(count($encodings) > 1); $this->assertTrue(isset($encodings['UTF-8'])); }
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Flatfile enrolments plugin settings and presets. * * @package enrol_flatfile * @copyright 2010 Eugene Venter * @author Eugene Venter - based on code by Petr Skoda and others * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; require_once __DIR__ . '/adminlib.php'; if ($ADMIN->fulltree) { //--- general settings ----------------------------------------------------------------------------------- $settings->add(new admin_setting_heading('enrol_flatfile_settings', '', get_string('pluginname_desc', 'enrol_flatfile'))); $settings->add(new admin_setting_configfile('enrol_flatfile/location', get_string('location', 'enrol_flatfile'), get_string('location_desc', 'enrol_flatfile'), '')); $options = textlib::get_encodings(); $settings->add(new admin_setting_configselect('enrol_flatfile/encoding', get_string('encoding', 'enrol_flatfile'), '', 'UTF-8', $options)); $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailstudents', get_string('notifyenrolled', 'enrol_flatfile'), '', 0)); $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailteachers', get_string('notifyenroller', 'enrol_flatfile'), '', 0)); $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailadmins', get_string('notifyadmin', 'enrol_flatfile'), '', 0)); $options = array(ENROL_EXT_REMOVED_UNENROL => get_string('extremovedunenrol', 'enrol'), ENROL_EXT_REMOVED_KEEP => get_string('extremovedkeep', 'enrol'), ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol')); $settings->add(new admin_setting_configselect('enrol_flatfile/unenrolaction', get_string('extremovedaction', 'enrol'), get_string('extremovedaction_help', 'enrol'), ENROL_EXT_REMOVED_SUSPENDNOROLES, $options)); // Note: let's reuse the ext sync constants and strings here, internally it is very similar, // it describes what should happen when users are not supposed to be enrolled any more. $options = array(ENROL_EXT_REMOVED_KEEP => get_string('extremovedkeep', 'enrol'), ENROL_EXT_REMOVED_SUSPENDNOROLES => get_string('extremovedsuspendnoroles', 'enrol'), ENROL_EXT_REMOVED_UNENROL => get_string('extremovedunenrol', 'enrol')); $settings->add(new admin_setting_configselect('enrol_flatfile/expiredaction', get_string('expiredaction', 'enrol_flatfile'), get_string('expiredaction_help', 'enrol_flatfile'), ENROL_EXT_REMOVED_SUSPENDNOROLES, $options)); //--- mapping ------------------------------------------------------------------------------------------- if (!during_initial_install()) { $settings->add(new admin_setting_heading('enrol_flatfile_mapping', get_string('mapping', 'enrol_flatfile'), '')); $roles = role_fix_names(get_all_roles()); foreach ($roles as $role) {