Exemplo n.º 1
0
function autoattend_update_session_users($courseid, $sessid, $ntime = '')
{
    global $DB;
    if ($sessid <= 0) {
        return null;
    }
    if (empty($ntime)) {
        $ntime = time();
    }
    $sess = $DB->get_record('autoattend_sessions', array('id' => $sessid));
    if (!$sess) {
        return null;
    }
    $context = jbxl_get_course_context($courseid);
    $stdnts = jbxl_get_course_students($context);
    if ($sess->state != 'C' and $ntime > $sess->starttime) {
        foreach ($stdnts as $stdnt) {
            $user = $DB->get_record('autoattend_students', array('attsid' => $sess->id, 'studentid' => $stdnt->id));
            if (empty($user)) {
                autoattend_add_user_insession($sess->id, $stdnt->id);
            }
        }
    }
    return $sess;
}
Exemplo n.º 2
0
}
require_login($course->id);
$context = jbxl_get_course_context($course->id);
$isstudent = jbxl_is_student($USER->id, $context);
// for Student
if ($isstudent) {
    $userid = $USER->id;
    $classinfo = autoattend_get_user_class($userid, $course->id);
    //
    if ($classinfo->classid >= 0) {
        $ntime = time();
        $sessions = autoattend_get_nowopen_sessions($course->id, $userid, 'S', $ntime);
        // get semiauto sessions
        if ($sessions) {
            foreach ($sessions as $session) {
                $session = autoattend_update_session_state($courseid, $session, $ntime, false);
                // not regist student
                if ($session->classid == 0 or $session->classid == $classinfo->classid) {
                    $student = $DB->get_record('autoattend_students', array('attsid' => $session->id, 'studentid' => $userid));
                    if (empty($student)) {
                        $student = autoattend_add_user_insession($session->id, $userid);
                    }
                    if ($student and $student->status == 'Y') {
                        redirect('semiautoattend.php?course=' . $course->id . '&amp;attsid=' . $session->id);
                    }
                }
            }
        }
    }
}
redirect('index.php?course=' . $course->id);