* saves them in the report's plugin config. 
     * 
     * @param $data
     */
    public function process($data)
    {
        $data->roles = serialize($data->roles);
        $data->categories = serialize($data->categories);
        foreach ($data as $field => $value) {
            set_config($field, $value, 'report_targetgrades');
        }
    }
}
list($in_sql, $params) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles));
$customdata = array('fields' => array('', 'shortname' => get_string('shortname'), 'fullname' => get_string('fullname'), 'idnumber' => get_string('idnumber')), 'roles' => $DB->get_records_select_menu('role', 'id ' . $in_sql, $params), 'categories' => $DB->get_records_menu('course_categories'), 'userfields' => $DB->get_records_menu('user_info_field', null, '', 'id, name'));
if (empty($customdata['userfields'])) {
    throw new moodle_exception('err_nouserfields', 'report_targetgrades', new moodle_url('/user/profile/index.php'));
}
$form = new report_targetgrades_settingsform(null, $customdata);
if ($config = tg\get_config()) {
    $form->set_data($config);
}
if ($data = $form->get_data()) {
    $form->process($data);
    redirect(new moodle_url('/admin/report/targetgrades'), get_string('settingssaved', 'report_targetgrades'), 3);
    exit;
}
echo $OUTPUT->header();
echo tg\print_tabs(3);
$form->display();
echo $OUTPUT->footer();
                $quality_html[] = html_writer::tag('abbr', $status->display, array('class' => 'tg_' . $status->class . 'quality', 'title' => get_string($status->message, 'report_targetgrades', $alis->{$field})));
            }
        } else {
            $quality_html[] = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/tick_green_big'), 'title' => get_string('okquality', 'report_targetgrades')));
        }
        $row = new html_table_row();
        $row->cells[] = $alis->qualification;
        $row->cells[] = html_writer::tag('a', $alis->subject, array('name' => 'alis' . $alis->id));
        $row->cells[] = $form;
        $row->cells[] = $alis->gradient;
        $row->cells[] = $alis->intercept;
        $row->cells[] = implode('', $quality_html);
        $table->data[] = $row;
    }
}
echo $OUTPUT->header();
tg\print_tabs(1);
echo html_writer::tag('h2', get_string('alisdata', 'report_targetgrades'));
echo html_writer::tag('p', get_string('configalis', 'report_targetgrades'));
if (isset($output)) {
    echo $output;
}
$uploadform->display();
if (isset($table)) {
    echo html_writer::tag('p', get_string('explainpatterns', 'report_targetgrades', $config));
    echo html_writer::start_tag('form', array('action' => $PAGE->url->out(), 'method' => 'post'));
    echo html_writer::table($table);
    echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'savepatterns', 'value' => get_string('savechanges')));
    echo html_writer::end_tag('form');
}
echo $OUTPUT->footer();
                grade_regrade_final_grades($course->id);
                tg\sort_gradebook($course);
            }
        }
    }
    $output = html_writer::start_tag('p') . get_string('distribute_success', 'report_targetgrades', count($distributed_selector->find_users()) - count($empty_courses) - count($unconfigured_courses)) . html_writer::empty_tag('br') . get_string('distribute_empty', 'report_targetgrades', count($empty_courses)) . html_writer::empty_tag('br') . get_string('distribute_unconfigured', 'report_targetgrades', count($unconfigured_courses)) . html_writer::empty_tag('br') . get_string('distribute_noavgcse', 'report_targetgrades', count(array_unique($empty_students))) . html_writer::empty_tag('br') . get_string('distribute_failedcalc', 'report_targetgrades', count($failed_grade_calcs)) . html_writer::empty_tag('br') . $errors . html_writer::end_tag('p');
}
$table = new html_table('course_selector');
$row = new html_table_row();
$row->cells[] = $distributed_selector->display(true);
$cell = html_writer::empty_tag('input', array('id' => 'report_targetgrades_calcbutton', 'name' => 'calculate', 'type' => 'submit', 'value' => $OUTPUT->larrow() . ' ' . get_string('calculategrades', 'report_targetgrades')));
$cell .= $OUTPUT->help_icon('calculategrades', 'report_targetgrades');
$row->cells[] = $cell;
$row->cells[] = $potential_selector->display(true);
$table->data[] = $row;
$scales = $DB->get_records_menu('scale', null, null, 'id, name');
$defaultscale = isset($config->defaultscale) ? $config->defaultscale : null;
echo $OUTPUT->header();
tg\print_tabs(2);
if (isset($output)) {
    echo $output;
}
echo html_writer::start_tag('form', array('action' => $PAGE->url->out(), 'method' => 'post'));
echo html_writer::tag('label', get_string('defaultscale', 'report_targetgrades'), array('for' => 'defaultscale'));
echo html_writer::select($scales, 'report_targetgrades', $defaultscale);
echo $OUTPUT->help_icon('defaultscale', 'report_targetgrades');
echo html_writer::table($table);
echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'recalculate', 'value' => get_string('recalculate', 'report_targetgrades')));
echo $OUTPUT->help_icon('recalculate', 'report_targetgrades');
echo html_writer::end_tag('form');
echo $OUTPUT->footer();