Esempio n. 1
0
 /**
  * Hook for export the next data record in-place
  *
  * @return array The next record to be exported
  */
 public function next()
 {
     // Fetch the current record.
     $record = $this->recordset->current();
     // Set up our grade item.
     $grade_item = new stdClass();
     if ($record->mdlcrsid !== null) {
         $grade_item->courseid = $record->mdlcrsid;
     } else {
         $grade_item->courseid = SITEID;
     }
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     // Write the line out of a file.
     $csvrecord = array($record->firstname, $record->lastname, $record->username, $record->idnumber, $record->crsidnumber, date('M/d/Y', $record->enrolmenttime), date('M/d/Y', $record->completetime), $this->completestatusstring, $record->grade, grade_format_gradevalue($record->grade, $grade_item, true, GRADE_DISPLAY_TYPE_LETTER, 5));
     // Add additional data for extra fields.
     $additional_data = rlipexport_version1elis_extrafields::get_all_data($record);
     $csvrecord = array_merge($csvrecord, $additional_data);
     // Move on to the next data record.
     $this->recordset->next();
     return $csvrecord;
 }
 /**
  * Test that when a custom field is configured, then deleted, the field is removed from configuration.
  */
 public function test_rlipexport_version1elis_extrafieldsetcustomfieldbase_handledeleted()
 {
     $this->load_csv_data();
     $fieldid1 = $this->create_custom_field('testcf1', 0, false, CONTEXT_ELIS_USER, 'text');
     $this->create_field_mapping('testcustomfields', 'field_' . $fieldid1, 'Field One');
     $this->create_field_data($fieldid1, 'Test Text One');
     $field = new field($fieldid1);
     $field->load();
     $field->delete();
     $enabledfields = rlipexport_version1elis_extrafields::get_enabled_fields();
     $fieldset = new rlipexport_version1elis_extrafieldset_testcustomfields($enabledfields['testcustomfields']);
     $columns = $fieldset->get_columns();
     $this->assertInternalType('array', $columns);
     $this->assertEmpty($columns);
     $record = new stdClass();
     $data = $fieldset->get_data($record);
     $this->assertInternalType('array', $data);
     $this->assertEmpty($data);
 }
Esempio n. 3
0
require_capability('moodle/site:config', $context);
// Handle submitted actions.
$baseurl = $CFG->wwwroot . '/local/datahub/exportplugins/version1elis/config_fields.php';
$data_submitted = optional_param('data_submitted', false, PARAM_INT);
if (!empty($data_submitted)) {
    require_sesskey();
    $submitted_fields = optional_param_array('fields', array(), PARAM_SAFEPATH);
    // Safepath needed for '/'.
    $submitted_fieldnames = optional_param_array('fieldnames', array(), PARAM_ALPHANUM);
    $submitted_data = array('fields' => $submitted_fields, 'fieldnames' => $submitted_fieldnames);
    $processed_formdata = rlipexport_version1elis_extrafields::process_config_formdata($submitted_data);
    rlipexport_version1elis_extrafields::update_config($processed_formdata);
    redirect($baseurl);
}
$available_fields = rlipexport_version1elis_extrafields::get_available_fields();
$enabled_fields = rlipexport_version1elis_extrafields::get_enabled_fields();
$fieldsets = array();
$fields_by_fieldset = array();
$active_fields_by_fieldset_unordered = array();
$active_fields_by_fieldset_order = array();
$name_overrides = array();
foreach ($available_fields as $fieldset => $fields) {
    $fieldset_class = rlipexport_version1elis_extrafields::FIELDSET_PREFIX . $fieldset;
    $fieldsets[$fieldset] = $fieldset_class::get_label();
    foreach ($fields as $field => $header) {
        if (isset($enabled_fields[$fieldset][$field])) {
            $enabled_field_rec = $enabled_fields[$fieldset][$field];
            if ($enabled_field_rec->header !== '' && $enabled_field_rec->header !== null) {
                $name_overrides[$fieldset . '/' . $field] = $enabled_field_rec->header;
            }
            $active_fields_by_fieldset_unordered[$fieldset . '/' . $field] = $header;