<?php 
    /// print table of outstanding appointer (groups)
    print_heading(get_string('schedulegroups', 'scheduler'));
    if (empty($groups)) {
        notify(get_string('nogroups', 'scheduler'));
    } else {
        $mtable->head = array('', $strname, $straction);
        $mtable->align = array('CENTER', 'LEFT', 'CENTER');
        $mtable->width = array('', '', '');
        $mtable->data = array();
        foreach ($groups as $group) {
            $members = get_group_users($group->id, 'lastname', '', 'u.id, lastname, firstname, email, picture');
            if (empty($members)) {
                continue;
            }
            if (!scheduler_has_slot(implode(',', array_keys($members)), $scheduler, true, $scheduler->schedulermode == 'onetime')) {
                $actions = '<span style="font-size: x-small;">';
                $actions .= "<a href=\"view.php?what=schedulegroup&amp;id={$cm->id}&amp;groupid={$group->id}&amp;page={$page}\">";
                $actions .= get_string('schedule', 'scheduler');
                $actions .= '</a></span>';
                $groupmembers = array();
                foreach ($members as $member) {
                    $groupmembers[] = fullname($member);
                }
                $groupcrew = '[' . implode(", ", $groupmembers) . ']';
                $mtable->data[] = array('', $groups[$group->id]->name . ' ' . $groupcrew, $actions);
            }
        }
        // print table of students who still have to make appointments
        if (!empty($mtable->data)) {
            print_table($mtable);
 */
if (!defined('MOODLE_INTERNAL')) {
    error("This file cannot be loaded directly");
}
if ($action) {
    include 'studentview.controller.php';
}
$teacher = get_record('user', 'id', $scheduler->teacher);
$mygroups = get_groups($course->id, $USER->id);
/// printing head information
print_heading($scheduler->name, 'center', 4, 'h1');
if (!empty($scheduler->description)) {
    print_simple_box($scheduler->description, 'center', '80%');
}
print_simple_box_start('center', '80%');
if (scheduler_has_slot($USER->id, $scheduler, true)) {
    print_string('welcomebackstudent', 'scheduler');
} else {
    print_string('welcomenewstudent', 'scheduler');
}
print_simple_box_end();
// clean all late slots (for every body, anyway, they are passed !!)
scheduler_free_late_unused_slots($scheduler->id);
/// get information about appointment attention
$sql = "\n        SELECT\n           COUNT(*)\n        FROM\n            {$CFG->prefix}scheduler_slots AS s,\n            {$CFG->prefix}scheduler_appointment AS a\n        WHERE\n            s.id = a.slotid AND\n            a.studentid = {$USER->id} AND\n            a.attended = 1 AND\n            s.schedulerid = {$scheduler->id}\n    ";
$hasattended = count_records_sql($sql);
/// get available slots
$haveunattendedappointments = false;
if ($slots = scheduler_get_available_slots($USER->id, $scheduler->id, true)) {
    $minhidedate = 0;
    // very far in the past