} 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
$studentslist = !empty($students) ? $dbc->get_students_matrix($flextable, $students, $status_id, $notstatus_ids) : false;
//get the default status item which will be used as the status for students who
//have not entered their ilp and have not had a status assigned
$defaultstatusitem_id = get_config('block_ilp', 'defaultstatusitem');
//get the status item record
$defaultstatusitem = $dbc->get_status_item_by_id($defaultstatusitem_id);
$status_item = !empty($defaultstatusitem) ? $defaultstatusitem->name : get_string('unknown', 'block_ilp');
//this is needed if the current user has capabilities in the course context, it allows view_main page to view the user
//in the course context
$course_param = !empty($course_id) ? "&course_id={$course_id}" : '';
$coursearg = $course_id ? "&course={$course_id}" : '';
if (!empty($studentslist)) {
    foreach ($studentslist as $student) {
        $data = array();
        $userprofile = stripos($CFG->release, "2.") === false ? 'view.php' : 'profile.php';
        $data['picture'] = $OUTPUT->user_picture($student, array('return' => true, 'size' => 50));