예제 #1
0
 /**
  * Validate that the API call for obtaining the recordset of configured
  * export fields works as expected
  */
 public function test_version1exportreportsconfiguredfields()
 {
     global $CFG;
     $file = get_plugin_directory('dhexport', 'version1') . '/lib.php';
     require_once $file;
     // Set up the category and field, along with the export mapping.
     $categoryid = $this->create_custom_field_category();
     $firstfieldid = $this->create_profile_field('rliptext', 'text', $categoryid);
     $this->create_field_mapping($firstfieldid);
     // Set up a second field and mapping record.
     $secondfieldid = $this->create_profile_field('rliptext2', 'text', $categoryid);
     $this->create_field_mapping($secondfieldid, 'Header2', 2);
     // Track whether each expected record was found.
     $foundfirst = false;
     $foundsecond = false;
     // Look through the configured fields recordset.
     if ($recordset = rlipexport_version1_config::get_configured_fields()) {
         foreach ($recordset as $record) {
             // Conditions for matching the first and second expected records.
             $isfirst = $record->name == 'rliptext' && $record->header == 'Header' && $record->fieldorder == 1;
             $issecond = $record->name == 'rliptext2' && $record->header == 'Header2' && $record->fieldorder == 2;
             if ($isfirst) {
                 // First record found.
                 $foundfirst = true;
             } else {
                 if ($issecond) {
                     // Second record found.
                     $foundsecond = true;
                 } else {
                     // Invalid record found.
                     $this->assertEquals(true, false);
                 }
             }
         }
     } else {
         // Problem fetching recordset.
         $this->assertEquals(true, false);
     }
     // Validate that both records were found.
     $this->assertEquals($foundfirst, true);
     $this->assertEquals($foundsecond, true);
 }
예제 #2
0
require_capability('moodle/site:config', $context);
//handle submitted actions
$baseurl = $CFG->wwwroot . '/local/datahub/exportplugins/version1/config_fields.php';
rlipexport_version1_config::handle_field_action($baseurl);
//page header
rlipexport_version1_page_setup($baseurl);
echo $OUTPUT->header();
//initialize the display table
$table = new html_table();
$table->head = array(get_string('profilefieldname', 'dhexport_version1'), get_string('columnheader', 'dhexport_version1'), '', '', '');
$table->data = array();
//fill table rows with selected field information
//information used to track first / last rows
$first = true;
$max_order = $DB->get_field(RLIPEXPORT_VERSION1_FIELD_TABLE, 'MAX(fieldorder)', array());
if ($recordset = rlipexport_version1_config::get_configured_fields()) {
    foreach ($recordset as $record) {
        //text box for setting header
        $attributes = array('type' => 'text', 'name' => 'header_' . $record->id, 'value' => $record->header);
        $header = html_writer::empty_tag('input', $attributes);
        //"move up" link
        if (!$first) {
            $url = $baseurl . '?up=' . $record->id;
            $uplink = rlipexport_version1_linked_image($url, 't/up');
        } else {
            //first record
            $uplink = '';
        }
        //"move down" link
        if ($record->fieldorder != $max_order) {
            $url = $baseurl . '?down=' . $record->id;