Ejemplo n.º 1
0
 /**
  * Definition method.
  */
 public 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('pluginname', 'gradeimport_direct'));
     // Data upload from copy/paste.
     $mform->addElement('textarea', 'userdata', 'Data', array('rows' => 10, 'class' => 'gradeimport_data_area'));
     $mform->addRule('userdata', null, 'required');
     $mform->setType('userdata', PARAM_RAW);
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     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);
     $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'));
 }
Ejemplo n.º 2
0
 /**
  * The form's definition.
  */
 public function definition()
 {
     $mform =& $this->_form;
     $data = $this->_customdata;
     $mform->addElement('hidden', 'action', 'upload_group_data');
     $mform->setType('action', PARAM_ALPHA);
     $mform->addElement('hidden', 'id', $data['id']);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('html', get_string('upload_help', 'block_upload_group'));
     $mform->addElement('header', 'upload_group_data', get_string('upload_group_data', 'block_upload_group'));
     // Add a file manager.
     $mform->addElement('filepicker', 'group_data', '');
     // Add the encoding option.
     $choices = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'block_upload_group'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     // Add the delimiter option.
     $choices = csv_import_reader::get_delimiter_list();
     $mform->addElement('select', 'delimiter', get_string('delimiter', 'block_upload_group'), $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 = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
     $mform->addElement('select', 'preview_num', get_string('row_preview_num', 'block_upload_group'), $choices);
     $mform->setType('preview_num', PARAM_INT);
     $this->add_action_buttons(true, get_string('submit_group_data', 'block_upload_group'));
 }
 /**
  * Defines the form, which will have:
  *  - Input for courses csv.
  *  - Input for users csv.
  *  - Input for logs csv.
  *  - Select for csv delimiter.
  *  - Select for files encoding.
  */
 public function definition()
 {
     $mform = $this->_form;
     $mform->addElement('header', 'settingsheader', get_string('upload', 'block_mycourse_recommendations'));
     $mform->addElement('static', 'description', '', get_string('upload_desc', 'block_mycourse_recommendations'));
     $mform->addElement('static', 'description', get_string('coursefile', 'block_mycourse_recommendations'), get_string('coursefile_desc', 'block_mycourse_recommendations'));
     $mform->addElement('filepicker', 'courses', '');
     $mform->addRule('courses', null, 'required');
     $mform->addElement('static', 'description', get_string('usersfile', 'block_mycourse_recommendations'), get_string('usersfile_desc', 'block_mycourse_recommendations'));
     $mform->addElement('filepicker', 'users', '');
     $mform->addRule('users', null, 'required');
     $mform->addElement('static', 'description', get_string('logsfile', 'block_mycourse_recommendations'), get_string('logsfile_desc', 'block_mycourse_recommendations'));
     $mform->addElement('filepicker', 'logs', '');
     $mform->addRule('logs', 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 = \core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     $this->add_action_buttons(false, get_string('uploaddata', 'block_mycourse_recommendations'));
 }
Ejemplo n.º 4
0
 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', '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 = core_text::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);
     $this->add_action_buttons(false, get_string('uploadusers', 'tool_uploaduser'));
 }
Ejemplo n.º 5
0
 /**
  * Form definition
  */
 public function definition()
 {
     $mform = $this->_form;
     $data = (object) $this->_customdata;
     $mform->addElement('hidden', 'returnurl');
     $mform->setType('returnurl', PARAM_URL);
     $mform->addElement('header', 'cohortfileuploadform', get_string('uploadafile'));
     $filepickeroptions = array();
     $filepickeroptions['filetypes'] = '*';
     $filepickeroptions['maxbytes'] = get_max_upload_file_size();
     $mform->addElement('filepicker', 'cohortfile', get_string('file'), null, $filepickeroptions);
     $choices = csv_import_reader::get_delimiter_list();
     $mform->addElement('select', 'delimiter', get_string('csvdelimiter', 'tool_uploadcourse'), $choices);
     if (array_key_exists('cfg', $choices)) {
         $mform->setDefault('delimiter', 'cfg');
     } else {
         if (get_string('listsep', 'langconfig') == ';') {
             $mform->setDefault('delimiter', 'semicolon');
         } else {
             $mform->setDefault('delimiter', 'comma');
         }
     }
     $mform->addHelpButton('delimiter', 'csvdelimiter', 'tool_uploadcourse');
     $choices = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     $mform->addHelpButton('encoding', 'encoding', 'tool_uploadcourse');
     $options = $this->get_context_options();
     $mform->addElement('select', 'contextid', get_string('defaultcontext', 'cohort'), $options);
     $this->add_cohort_upload_buttons(true);
     $this->set_data($data);
 }
Ejemplo n.º 6
0
 /**
  *
  */
 protected function definition_expimp_settings()
 {
     $mform =& $this->_form;
     $mform->addElement('header', 'expimpsettingshdr', get_string('expimpsettings', 'dataformview_csv'));
     // Enable import  (param4).
     $mform->addElement('advcheckbox', 'param4', get_string('export', 'grades'), get_string('enable'), null, array(0, 1));
     $mform->setDefault('param4', 1);
     // Enable import  (param4).
     $mform->addElement('advcheckbox', 'param5', get_string('import'), get_string('enable'), null, array(0, 1));
     $mform->setDefault('param5', 1);
     // Allow update existing entries  (param4)
     // $mform->addElement('advcheckbox', 'updateexisting',  null, get_string('allowupdateexisting', 'dataformview_csv'), null, array(0, 1));
     // $mform->disabledIf('updateexisting', 'importenable', 'eq', 0);.
     // Delimiter.
     $delimiters = csv_import_reader::get_delimiter_list();
     $mform->addElement('select', 'delimiter', get_string('csvdelimiter', 'dataform'), $delimiters);
     $mform->setDefault('delimiter', 'comma');
     // Enclosure.
     $mform->addElement('text', 'enclosure', get_string('csvenclosure', 'dataform'), array('size' => '10'));
     $mform->setType('enclosure', PARAM_NOTAGS);
     $mform->setDefault('enclosure', '');
     // Encoding.
     $choices = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
 }
 /**
  * The standard form definiton.
  */
 public function definition()
 {
     $mform = $this->_form;
     $selectedfields = $this->_customdata['selectedfields'];
     $overrides = $this->_customdata['overrides'];
     $fields = tool_downloaddata_processor::get_valid_course_fields();
     if (empty($selectedfields)) {
         $selectedfields = array(get_string('noselectedfields', 'tool_downloaddata'));
     }
     $mform->addElement('header', 'generalhdr', get_string('downloadcourses', 'tool_downloaddata'));
     $formatchoices = array(tool_downloaddata_processor::FORMAT_CSV => get_string('formatcsv', 'tool_downloaddata'), tool_downloaddata_processor::FORMAT_XLS => get_string('formatxls', 'tool_downloaddata'));
     $mform->addElement('select', 'format', get_string('format', 'tool_downloaddata'), $formatchoices);
     $mform->setDefault('format', $this->_customdata['format']);
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'tool_downloaddata'), $encodings);
     $mform->setDefault('encoding', $this->_customdata['encoding']);
     $mform->disabledIf('encoding', 'format', 'noteq', tool_downloaddata_processor::FORMAT_CSV);
     $delimiters = csv_import_reader::get_delimiter_list();
     $mform->addElement('select', 'delimiter_name', get_string('csvdelimiter', 'tool_downloaddata'), $delimiters);
     $mform->setDefault('delimiter_name', $this->_customdata['delimiter_name']);
     $mform->disabledIf('delimiter_name', 'format', 'noteq', tool_downloaddata_processor::FORMAT_CSV);
     $useoverrides = array('true' => 'Yes', 'false' => 'No');
     $mform->addElement('select', 'useoverrides', get_string('useoverrides', 'tool_downloaddata'), $useoverrides);
     $mform->setDefault('useoverrides', $this->_customdata['useoverrides']);
     $mform->addHelpButton('useoverrides', 'useoverrides', 'tool_downloaddata');
     $sortbycategorypath = array('true' => 'Yes', 'false' => 'No');
     $mform->addElement('select', 'sortbycategorypath', get_string('sortbycategorypath', 'tool_downloaddata'), $sortbycategorypath);
     $mform->setDefault('sortbycategorypath', $this->_customdata['sortbycategorypath']);
     $mform->addHelpButton('sortbycategorypath', 'sortbycategorypath', 'tool_downloaddata');
     $mform->addElement('header', 'fieldshdr', get_string('fields', 'tool_downloaddata'));
     $mform->setExpanded('fieldshdr', true);
     // Creating the field selection elements.
     $objs = array();
     $objs[0] = $mform->createElement('select', 'availablefields', get_string('available', 'tool_downloaddata'), $fields, 'size="10"');
     $objs[0]->setMultiple(true);
     $objs[1] = $mform->createElement('select', 'selectedfields', get_string('selected', 'tool_downloaddata'), $selectedfields, 'size="10"');
     $objs[1]->setMultiple(true);
     $group = $mform->addElement('group', 'fieldsgroup', get_string('fields', 'tool_downloaddata'), $objs, '  ', false);
     $mform->addHelpButton('fieldsgroup', 'fields', 'tool_downloaddata');
     // Creating the buttons for the field selection elements.
     $objs = array();
     $objs[] = $mform->createElement('submit', 'addfieldselection', get_string('addfieldselection', 'tool_downloaddata'));
     $objs[] = $mform->createElement('submit', 'removefieldselection', get_string('removefieldselection', 'tool_downloaddata'));
     $objs[] = $mform->createElement('submit', 'addallfields', get_string('addallfields', 'tool_downloaddata'));
     $objs[] = $mform->createElement('submit', 'removeallfields', get_string('removeallfields', 'tool_downloaddata'));
     $group = $mform->addElement('group', 'buttonsgroup', '', $objs, array(' ', '<br/>'), false);
     $mform->addElement('header', 'overrideshdr', get_string('overrides', 'tool_downloaddata'));
     $mform->addElement('textarea', 'overrides', get_string('overrides', 'tool_downloaddata'), 'wrap="virtual" rows="3" cols="45"');
     $mform->setType('overrides', PARAM_RAW);
     $mform->setDefault('overrides', $overrides);
     $mform->addHelpButton('overrides', 'overrides', 'tool_downloaddata');
     if (empty($overrides)) {
         $mform->setExpanded('overrideshdr', false);
     } else {
         $mform->setExpanded('overrideshdr', true);
     }
     $this->add_action_buttons(false, get_string('download', 'tool_downloaddata'));
     $template = '<label class="qflabel" style="vertical-align:top">{label}</label> {element}';
     $mform->defaultRenderer()->setGroupElementTemplate($template, 'fieldsgroup');
 }
Ejemplo n.º 8
0
 /**
  * Define this form - called by the parent constructor
  */
 public function definition()
 {
     global $COURSE, $USER;
     $mform = $this->_form;
     $params = $this->_customdata;
     $mform->addElement('header', 'uploadgrades', get_string('uploadgrades', 'assignfeedback_offline'));
     $fileoptions = array('subdirs' => 0, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => 'csv', 'maxfiles' => 1, 'return_types' => FILE_INTERNAL);
     $mform->addElement('filepicker', 'gradesfile', get_string('uploadafile'), null, $fileoptions);
     $mform->addRule('gradesfile', get_string('uploadnofilefound'), 'required', null, 'client');
     $mform->addHelpButton('gradesfile', 'gradesfile', 'assignfeedback_offline');
     $encodings = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     $mform->addHelpButton('encoding', 'encoding', 'grades');
     $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->addHelpButton('separator', 'separator', 'grades');
     $mform->setDefault('separator', 'comma');
     $mform->addElement('checkbox', 'ignoremodified', '', get_string('ignoremodified', 'assignfeedback_offline'));
     $mform->addHelpButton('ignoremodified', 'ignoremodified', 'assignfeedback_offline');
     $mform->addElement('hidden', 'id', $params['cm']);
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'action', 'viewpluginpage');
     $mform->setType('action', PARAM_ALPHA);
     $mform->addElement('hidden', 'pluginaction', 'uploadgrades');
     $mform->setType('pluginaction', PARAM_ALPHA);
     $mform->addElement('hidden', 'plugin', 'offline');
     $mform->setType('plugin', PARAM_PLUGIN);
     $mform->addElement('hidden', 'pluginsubtype', 'assignfeedback');
     $mform->setType('pluginsubtype', PARAM_PLUGIN);
     $this->add_action_buttons(true, get_string('uploadgrades', 'assignfeedback_offline'));
 }
 /**
  * Form definition
  */
 public function definition()
 {
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $config = get_config('local_mass_enroll');
     $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 = \core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     $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', 'mailreport', get_string('mailreport', 'local_mass_enroll'));
     $mform->setDefault('mailreport', (int) $config->mailreportdefault);
     // Buttons.
     $this->add_action_buttons(true, get_string('unenroll', 'local_mass_enroll'));
     $mform->addElement('hidden', 'id', $course->id);
     $mform->setType('id', PARAM_INT);
 }
Ejemplo n.º 10
0
 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 = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
     $mform->addHelpButton('encoding', 'encoding', 'grades');
     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->addHelpButton('separator', 'separator', 'grades');
         $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);
         $mform->addHelpButton('verbosescales', 'verbosescales', 'grades');
     }
     $options = array('10' => 10, '20' => 20, '100' => 100, '1000' => 1000, '100000' => 100000);
     $mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options);
     // TODO: localize
     $mform->addHelpButton('previewrows', 'rowpreviewnum', 'grades');
     $mform->setType('previewrows', PARAM_INT);
     $mform->addElement('checkbox', 'forceimport', get_string('forceimport', 'grades'));
     $mform->addHelpButton('forceimport', 'forceimport', 'grades');
     $mform->setDefault('forceimport', false);
     $mform->setType('forceimport', PARAM_BOOL);
     $mform->addElement('hidden', 'groupid', groups_get_course_group($COURSE));
     $mform->setType('groupid', PARAM_INT);
     $this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
 }
Ejemplo n.º 11
0
 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'));
     $mform->setType('fieldenclosure', PARAM_CLEANHTML);
     $choices = core_text::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);
 }
Ejemplo n.º 12
0
 public function definition()
 {
     global $USER, $CFG, $COURSE;
     $mform =& $this->_form;
     $templateuser = $USER;
     $context = $this->_customdata['context'];
     $mform->addElement('header', 'settingsheader', get_string('toolsettings', 'local_ltiprovider'));
     $tools = array();
     $tools[$context->id] = get_string('course');
     $modinfo = get_fast_modinfo($this->_customdata['courseid']);
     $mods = $modinfo->get_cms();
     foreach ($mods as $mod) {
         $tools[$mod->context->id] = format_string($mod->name);
     }
     $mform->addElement('select', 'contextid', get_string('tooltobeprovide', 'local_ltiprovider'), $tools);
     $mform->setDefault('contextid', $context->id);
     $mform->addElement('checkbox', 'sendgrades', null, get_string('sendgrades', 'local_ltiprovider'));
     $mform->setDefault('sendgrades', 1);
     $mform->addElement('checkbox', 'forcenavigation', null, get_string('forcenavigation', 'local_ltiprovider'));
     $mform->setDefault('forcenavigation', 1);
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'local_ltiprovider'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', 0);
     $mform->addHelpButton('enrolperiod', 'enrolperiod', 'local_ltiprovider');
     $mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'local_ltiprovider'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'local_ltiprovider');
     $mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'local_ltiprovider'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->addHelpButton('enrolenddate', 'enrolenddate', 'local_ltiprovider');
     $mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'local_ltiprovider'));
     $mform->setDefault('maxenrolled', 0);
     $mform->addHelpButton('maxenrolled', 'maxenrolled', 'local_ltiprovider');
     $mform->setType('maxenrolled', PARAM_INT);
     $assignableroles = get_assignable_roles($context);
     $mform->addElement('select', 'croleinst', get_string('courseroleinstructor', 'local_ltiprovider'), $assignableroles);
     $mform->setDefault('croleinst', '3');
     $mform->setAdvanced('croleinst');
     $mform->addElement('select', 'crolelearn', get_string('courserolelearner', 'local_ltiprovider'), $assignableroles);
     $mform->setDefault('crolelearn', '5');
     $mform->setAdvanced('crolelearn');
     $mform->addElement('select', 'aroleinst', get_string('activityroleinstructor', 'local_ltiprovider'), $assignableroles);
     $mform->disabledIf('aroleinst', 'contextid', 'eq', $context->id);
     $mform->setDefault('aroleinst', '3');
     $mform->setAdvanced('aroleinst');
     $mform->addElement('select', 'arolelearn', get_string('activityrolelearner', 'local_ltiprovider'), $assignableroles);
     $mform->disabledIf('arolelearn', 'contextid', 'eq', $context->id);
     $mform->setDefault('arolelearn', '5');
     $mform->setAdvanced('arolelearn');
     $mform->addElement('header', 'remotesystem', get_string('remotesystem', 'local_ltiprovider'));
     $mform->addElement('text', 'secret', get_string('secret', 'local_ltiprovider'), 'maxlength="64" size="25"');
     $mform->setType('secret', PARAM_MULTILANG);
     $mform->setDefault('secret', md5(uniqid(rand(), 1)));
     $mform->addRule('secret', get_string('required'), 'required');
     if (class_exists('textlib')) {
         $textlib = new textlib();
     } else {
         try {
             // for older moodle instances
             $textlib = textlib_get_instance();
         } catch (Exception $e) {
             // updated to use new core_text lib as required by Moodle 2.9
             $textlib = new core_text();
         }
     }
     $choices = $textlib->get_encodings();
     $mform->addElement('select', 'encoding', get_string('remoteencoding', 'local_ltiprovider'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     $mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'local_ltiprovider'));
     $choices = array(0 => get_string('never'), 1 => get_string('always'));
     $mform->addElement('select', 'userprofileupdate', get_string('userprofileupdate', 'local_ltiprovider'), $choices);
     $userprofileupdate = get_config('local_ltiprovider', 'userprofileupdate');
     if ($userprofileupdate != -1) {
         $mform->setDefault('userprofileupdate', $userprofileupdate);
         $mform->freeze('userprofileupdate');
     } else {
         $mform->setDefault('userprofileupdate', 1);
     }
     $choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
     $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
     $mform->setDefault('maildisplay', 2);
     $mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
     $mform->setType('city', PARAM_MULTILANG);
     if (empty($CFG->defaultcity)) {
         $mform->setDefault('city', $templateuser->city);
     } else {
         $mform->setDefault('city', $CFG->defaultcity);
     }
     $mform->addRule('city', get_string('required'), 'required');
     $mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
     if (empty($CFG->country)) {
         $mform->setDefault('country', $templateuser->country);
     } else {
         $mform->setDefault('country', $CFG->country);
     }
     $mform->setAdvanced('country');
     $choices = get_list_of_timezones();
     $choices['99'] = get_string('serverlocaltime');
     $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     $mform->setDefault('timezone', $templateuser->timezone);
     $mform->setAdvanced('timezone');
     $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
     $mform->setDefault('lang', $templateuser->lang);
     $mform->setAdvanced('lang');
     $mform->addElement('text', 'institution', get_string('institution'), 'maxlength="40" size="25"');
     $mform->setType('institution', PARAM_MULTILANG);
     $mform->setDefault('institution', $templateuser->institution);
     $mform->setAdvanced('institution');
     $mform->addElement('header', 'memberships', get_string('membershipsettings', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'syncmembers', null, get_string('enablememberssync', 'local_ltiprovider'));
     $mform->disabledIf('syncmembers', 'contextid', 'neq', $context->id);
     $options = array();
     $options[30 * 60] = '30 ' . get_string('minutes');
     $options[60 * 60] = '1 ' . get_string('hour');
     $options[2 * 60 * 60] = '2 ' . get_string('hours');
     $options[6 * 60 * 60] = '6 ' . get_string('hours');
     $options[12 * 60 * 60] = '12 ' . get_string('hours');
     $options[24 * 60 * 60] = '24 ' . get_string('hours');
     $mform->addElement('select', 'syncperiod', get_string('syncperiod', 'local_ltiprovider'), $options);
     $mform->setDefault('syncperiod', 30 * 60);
     $mform->disabledIf('syncperiod', 'contextid', 'neq', $context->id);
     $options = array();
     $options[1] = get_string('enrolandunenrol', 'local_ltiprovider');
     $options[2] = get_string('enrolnew', 'local_ltiprovider');
     $options[3] = get_string('unenrolmissing', 'local_ltiprovider');
     $mform->addElement('select', 'syncmode', get_string('syncmode', 'local_ltiprovider'), $options);
     $mform->setDefault('syncmode', 1);
     $mform->disabledIf('syncmode', 'contextid', 'neq', $context->id);
     $mform->addElement('header', 'layoutandcss', get_string('layoutandcss', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hidepageheader', null, get_string('hidepageheader', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hidepagefooter', null, get_string('hidepagefooter', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hideleftblocks', null, get_string('hideleftblocks', 'local_ltiprovider'));
     $mform->addElement('checkbox', 'hiderightblocks', null, get_string('hiderightblocks', 'local_ltiprovider'));
     $mform->setAdvanced('hideleftblocks');
     $mform->setAdvanced('hiderightblocks');
     $editoroptions = array();
     $displayoptions = array('rows' => '4', 'cols' => '');
     $mform->addElement('textarea', 'customcss', get_string('customcss', 'local_ltiprovider'), $displayoptions, $editoroptions);
     $mform->setAdvanced('customcss');
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons();
 }
Ejemplo n.º 13
0
 /**
  * Tests the static get_encodings method.
  */
 public function test_get_encodings()
 {
     $encodings = core_text::get_encodings();
     $this->assertTrue(is_array($encodings));
     $this->assertTrue(count($encodings) > 1);
     $this->assertTrue(isset($encodings['UTF-8']));
 }
Ejemplo n.º 14
0
// 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 = core_text::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) {
Ejemplo n.º 15
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $post_max_size = ini_get('post_max_size');
     $post_max_size_bytes = core_text::substr($post_max_size, 0, core_text::strlen($post_max_size) - 1) * (1024 * 1024);
     $post_max_size_bytes = $CFG->maxbytes != 0 && $CFG->maxbytes < $post_max_size_bytes ? $CFG->maxbytes : $post_max_size_bytes;
     $post_max_size = $post_max_size_bytes / (1024 * 1024);
     $mform->addElement('filepicker', 'import_marsupial', get_string('keymanager_import_explanation', 'local_rcommon', $post_max_size), null, array('accepted_types' => 'text/csv', 'maxbytes' => $post_max_size_bytes));
     $mform->addRule('import_marsupial', 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 = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices);
     $mform->setDefault('encoding', 'UTF-8');
     // hidden fields
     $mform->addElement('hidden', 'iid');
     $mform->setType('iid', PARAM_INT);
     //buttons
     $this->add_action_buttons(true, get_string('keymanager_import_button', 'local_rcommon'));
 }
    echo get_string('invalidpasswordenforcingmode', 'tool_uploadusercli') . "\n";
    echo $help;
    die;
}
$processoroptions['forcepasswordchange'] = $forcepasswordchanges[$options['forcepasswordchange']];
// File.
if (!empty($options['file'])) {
    $options['file'] = realpath($options['file']);
}
if (!file_exists($options['file'])) {
    echo get_string('invalidcsvfile', 'tool_uploadusercli') . "\n";
    echo $help;
    die;
}
// Encoding.
$encodings = core_text::get_encodings();
if (!isset($encodings[$options['encoding']])) {
    echo get_string('invalidencoding', 'tool_uploadusercli') . "\n";
    echo $help;
    die;
}
// Emulate admin session.
cron_setup_user();
// Let's get started!
$content = file_get_contents($options['file']);
$importid = csv_import_reader::get_new_iid('uploaduser');
$cir = new csv_import_reader($importid, 'uploaduser');
$readcount = $cir->load_csv_content($content, $options['encoding'], $options['delimiter']);
if ($readcount === false) {
    print_error('csvfileerror', 'tool_uploadusercli', '', $cir->get_error());
} else {
Ejemplo n.º 17
0
	function definition() {
	 global $CFG, $hierarchy, $PAGE,$batches ;
	 $mform = & $this->_form;
	 $batchid = $this->_customdata['batchid'];
	 $mode = $this->_customdata['mode'];
		
	$PAGE->requires->yui_module('moodle-local_batches-batches', 'M.local_batches.init_batches', array(array('formid' => $mform->getAttribute('id'))));
        if($batchid>0)
	 $batchinfo=$batches->get_specific_batchinformation($batchid);
	
	$availablefromgroup=array();
        $availablefromgroup[] =& $mform->createElement('radio', 'enroll', '','Add newstudents to Batch', 0);
        $availablefromgroup[] =& $mform->createElement('radio', 'enroll','', 'Add existing student to Batch', 1);
        $mform->addGroup($availablefromgroup, 'availablefromgroup', '', '', false);
	// used enable bydefault based on parameter mode ( from index page  button)
	if(isset($mode) && $mode){
 	   if($mode=='exists')
	   $mform->setDefault('enroll',1);
	   else{
	   if($mode=='new')
	   $mform->setDefault('enroll',0);	
		
	   }
		
	}
	
	
        $school = $hierarchy->get_assignedschools();
        if (is_siteadmin()) {
            $school = $hierarchy->get_school_items();
        }
        $parents = $hierarchy->get_school_parent($school);
       // $mform->addElement('header', 'settingsheader', get_string('createbatch', 'local_batches'));
        $count = count($school);
        $mform->addElement('hidden', 'count', $count);
        $mform->setType('count', PARAM_INT);
        //if ($count == 1) {
        //    /* ---registrar is assigned to only one school, display as static--- */
        //    foreach ($school as $scl) {
        //        $key = $scl->id;
        //        $value = $scl->fullname;
        //    }
        //    $mform->addElement('static', 'schools', get_string('select', 'local_collegestructure'), $value);
        //    $mform->addElement('hidden', 'schoolid', $key);
        //    $program = $hierarchy->get_records_cobaltselect_menu('local_program', "schoolid=$key AND visible=1", null, '', 'id,fullname', '--Select--');
        //    $mform->addElement('select', 'programid', get_string('selectprogram', 'local_programs'), $program);
        //    $mform->addRule('programid', get_string('missingprogram', 'local_programs'), 'required', null, 'client');
        //} else {
            $mform->addElement('select', 'schoolid', get_string('select', 'local_collegestructure'), $parents);
            $mform->addRule('schoolid', get_string('missingschool', 'local_collegestructure'), 'required', null, 'client');
	    if(isset($batchinfo->schoolid) && $batchinfo->schoolid>0)
	    $mform->setDefault('schoolid',$batchinfo->schoolid);
	//}   
      
        $mform->addElement('hidden', 'addprogram');
        $mform->setType('addprogram', PARAM_RAW);
	
	$batcheslist=$batches->get_batches_list();
	$mform->addElement('select', 'batchid', get_string('batches', 'local_batches'), $batcheslist);
        $mform->addRule('batchid', get_string('missingbatches', 'local_batches'), 'required', null, 'client');
	if(isset($batchinfo->batchid) && $batchinfo->batchid>0)
	$mform->setDefault('batchid',$batchinfo->batchid);
		
	$mform->addElement('hidden', 'addcurriculum');
        $mform->setType('addcurriculum', PARAM_RAW);
	
	$mform->addElement('hidden', 'addbatches');
        $mform->setType('addbatches', PARAM_RAW);
       
        $mform->registerNoSubmitButton('updatecourseformat');
        $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate'));
	

       // $mform->disabledIf('availablefromgroup', 'availablefromenabled');
	
	
        //$mform->addElement('radio', 'deleteolditems', '', 'new', true);
        //
        //$mform->addElement('radio', 'deleteolditems', '', 'existst');
	
		//$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();
        $choices = core_text::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 (
//			'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', 'block_learning_plan'), $ids);
//		$mform->setDefault('firstcolumn', 'username');

		$mform->addElement('selectyesno', 'mailreport', get_string('mailreport', 'local_batches'));
		$mform->setDefault('mailreport', 1);

		$this->add_action_buttons(true, get_string('enroll_batch', 'local_batches'));
	}
Ejemplo n.º 18
0
 /**
  *
  */
 protected function definition_csv_settings()
 {
     $mform =& $this->_form;
     $view = $this->_view;
     $mform->addElement('header', 'csvsettingshdr', get_string('csvsettings', 'dataformview_csv'));
     $mform->setExpanded('csvsettingshdr');
     // Delimiter.
     $delimiters = csv_import_reader::get_delimiter_list();
     $mform->addElement('select', 'delimiter', get_string('csvdelimiter', 'dataform'), $delimiters);
     // Enclosure.
     $mform->addElement('text', 'enclosure', get_string('csvenclosure', 'dataform'), array('size' => '10'));
     $mform->setType('enclosure', PARAM_NOTAGS);
     // Encoding.
     $choices = core_text::get_encodings();
     $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $choices);
 }
 /**
  * Class constructor.
  *
  * @throws moodle_exception.
  * @param string[] $options Download options.
  * @param string[] $fields The fields that will be downloaded.
  * @param string[] $roles The requested user roles.
  * @param string[] $overrides Fields to be overridden.
  */
 public function __construct($options, $fields, $roles = null, $overrides = null)
 {
     if (!isset($options['data']) || !in_array($options['data'], array(self::DATA_COURSES, self::DATA_USERS))) {
         throw new moodle_exception('invaliddata', 'tool_downloaddata');
     }
     $this->coursesorusers = (int) $options['data'];
     if ($this->coursesorusers === self::DATA_USERS) {
         if (empty($roles)) {
             throw new moodle_exception('emptyroles', 'tool_downloaddata');
         }
     }
     $this->roles = $roles;
     $this->fields = $fields;
     if (isset($options['format'])) {
         if (!in_array($options['format'], array(self::FORMAT_CSV, self::FORMAT_XLS))) {
             throw new moodle_exception('invalidformat', 'tool_downloaddata');
         }
         $this->format = (int) $options['format'];
     }
     if ($this->format == self::FORMAT_CSV && isset($options['delimiter'])) {
         $delimiters = csv_import_reader::get_delimiter_list();
         if (!isset($delimiters[$options['delimiter']])) {
             throw new moodle_exception('invaliddelimiter', 'tool_downloaddata');
         }
         $this->delimiter = $options['delimiter'];
     }
     if (isset($options['encoding'])) {
         $encodings = core_text::get_encodings();
         if (!isset($encodings[$options['encoding']])) {
             throw new moodle_exception('invalidencoding', 'tool_uploadcourse');
         }
         $this->encoding = $options['encoding'];
     }
     if (isset($options['useoverrides']) && $options['useoverrides'] == true) {
         $this->useoverrides = $options['useoverrides'];
         if (empty($overrides)) {
             throw new moodle_exception('emptyoverrides', 'tool_downloaddata');
         }
         $this->overrides = $overrides;
     }
     if (isset($options['sortbycategorypath'])) {
         $this->sortbycategorypath = $options['sortbycategorypath'];
     }
 }