$nosorting[] = 'lastupdated';
$flextable->define_fragment('studentlist');
$flextable->collapsible(true);
//define the columns and the headers in the flextable
$flextable->define_columns($columns);
$flextable->define_headers($headers);
$flextable->column_nosort = $nosorting;
$flextable->sortable(true, 'lastname', 'DESC');
$flextable->set_attribute('summary', get_string('studentslist', 'block_ilp'));
$flextable->set_attribute('cellspacing', '0');
$flextable->set_attribute('class', 'generaltable fit');
$flextable->set_attribute('id', "student_listcourse_id={$course_id}tutor={$tutor}status_id={$status_id}");
$flextable->initialbars(true);
$flextable->setup();
if (!empty($course_id)) {
    $users = $dbc->get_course_users($course_id, $group_id);
} else {
    $users = $dbc->get_user_tutees($USER->id);
}
$students = array();
foreach ($users as $u) {
    $students[] = $u->id;
}
$notstatus_ids = false;
if (!empty($status_id)) {
    $defaultstatusid = get_config('block_ilp', 'defaultstatusitem');
    if ($defaultstatusid == $status_id) {
        $notstatus_ids = true;
    }
}
//we only want to get the student matrix if students have been provided
} else {
    $title = get_string('mytutees', 'block_ilp');
}
//block name
$PAGE->navbar->add($title, null, 'title');
// setup the page title and heading
$SITE = $dbc->get_course_by_id(SITEID);
$PAGE->set_title($SITE->fullname . " : " . get_string('blockname', 'block_ilp'));
$PAGE->set_heading($SITE->fullname);
$PAGE->set_pagetype('ilp-reportlist');
$PAGE->set_pagelayout('ilp');
$PAGE->set_url($CFG->wwwroot . "/blocks/ilp/actions/view_studentlist.php", $PARSER->get_params());
//we need to list all of the students in the course with the given id
if (!empty($course_id)) {
    //get all of the students in this class
    $students = $dbc->get_course_users($course_id, $group_id);
    $course = $dbc->get_course_by_id($course_id);
    $groups = groups_get_all_groups($course->id);
    if (!empty($groups)) {
        $groupmode = groups_get_course_groupmode($course);
        // Groups are being used
        $isseparategroups = $course->groupmode == SEPARATEGROUPS && !has_capability('moodle/site:accessallgroups', $context);
    } else {
        $group_id = 0;
    }
    $groupexists = groups_get_group($group_id);
    if (empty($groupexists)) {
        $group_id = 0;
    } else {
        $groupincourse = groups_get_group_by_name($course_id, $groupexists->name);
        if (empty($groupincourse)) {