Exemplo n.º 1
0
    } else {
        $DB->insert_record('local_attendance_attendance', array('sessionid' => $session->id, 'userid' => $USER->id));
        echo '<div class="alert alert-success">' . get_string('attendancemarkedon', 'local_attendance') . ' ' . $session->fullname . '</div>';
    }
    $action = 'startpage';
}
if ($action == 'startpage') {
    $sessions = $DB->get_records_sql('SELECT c.id,c.fullname,u.id as userid,s.id as sessionid FROM {user} u INNER JOIN {user_enrolments} ue ON (ue.userid = u.id) INNER JOIN {enrol} e ON (e.id = ue.enrolid) INNER JOIN {course} c ON (e.courseid = c.id) INNER JOIN {local_attendance_session} s ON (c.id=s.courseid) WHERE ue.userid = ' . $USER->id . ' AND s.open=1');
    if (empty($sessions)) {
        echo '<div class="alert alert-info">' . get_string('nosessions', 'local_attendance') . '</div>';
    } else {
        $n = 0;
        foreach ($sessions as $session) {
            $sessionContext = context_course::instance($session->id);
            if (!has_capability('local/attendance:teacherview', $sessionContext)) {
                $n++;
            }
        }
        if ($n > 0) {
            echo '<h3>' . get_string('followingopensessions', 'local_attendance') . '</h3>';
            $table = tables::getOpenSessions($sessions);
            echo html_writer::table($table);
        } else {
            echo '<div class="alert alert-info">' . get_string('nosessions', 'local_attendance') . '</div>';
        }
    }
}
echo $OUTPUT->single_button(new moodle_url('/'), get_string('back', 'local_attendance'));
echo $OUTPUT->footer();
?>
<link rel="stylesheet" type="text/css"  href= "scripts/style.css"/>