Ejemplo n.º 1
0
function construct_local_full_user_stat_html_table($attendance, $course, $user) {
    global $CFG;
    $gradeable = $attendance->grade > 0;
    $statuses = local_att_get_statuses($attendance->id);
    $userstatusesstat = local_att_get_user_statuses_stat($attendance->id, $course->startdate, $user->id);
    $stat['completed'] = local_att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id);
    $stat['statuses'] = $userstatusesstat;
    if ($gradeable) {
        $grade = local_att_get_user_grade($userstatusesstat, $statuses);
        $maxgrade = local_att_get_user_max_grade(local_att_get_user_taken_sessions_count($attendance->id, $course->startdate,
                                                                             $user->id), $statuses);
        if (!$decimalpoints = grade_get_setting($course->id, 'decimalpoints')) {
            $decimalpoints = $CFG->grade_decimalpoints;
        }
    } else {
        $grade = 0;
        $maxgrade = 0;
        $decimalpoints = 0;
    }

    return construct_user_data_stat($stat, $statuses,
                $gradeable, $grade, $maxgrade, $decimalpoints);
}
Ejemplo n.º 2
0
function local_attendance_user_outline($course, $user, $mod, $attendance) {

    global $CFG;
    require_once(dirname(__FILE__) . '/locallib.php');
    require_once($CFG->libdir . '/gradelib.php');

    $grades = grade_get_grades($course->id, 'local', 'attendance', $attendance->id, $user->id);

    $result = new stdClass();
    if (!empty($grades->items[0]->grades)) {
        $grade = reset($grades->items[0]->grades);
        $result->time = $grade->dategraded;
    } else {
        $result->time = 0;
    }
    if (has_capability('local/attendance:canbelisted', $mod->context, $user->id)) {
        $statuses = local_att_get_statuses($attendance->id);
        $grade = local_att_get_user_grade(local_att_get_user_statuses_stat($attendance->id, $course->startdate, $user->id, $mod), $statuses);
        $maxgrade = local_att_get_user_max_grade(local_att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id, $mod), $statuses);

        $result->info = $grade . ' / ' . $maxgrade;
    }

    return $result;
}
Ejemplo n.º 3
0
    public function get_statuses($onlyvisible = true) {
        if (!isset($this->statuses)) {
            $this->statuses = local_att_get_statuses($this->id, $onlyvisible);
        }

        return $this->statuses;
    }
Ejemplo n.º 4
0
    public function __construct(attendance $att, $userid) {
        global $CFG;

        $this->user = $att->get_user($userid);

        $this->pageparams = $att->pageparams;

        if (!$this->decimalpoints = grade_get_setting($att->course->id, 'decimalpoints')) {
            $this->decimalpoints = $CFG->grade_decimalpoints;
        }

        if ($this->pageparams->mode == att_view_page_params::MODE_THIS_COURSE) {
            $this->statuses = $att->get_statuses();

            $this->stat = $att->get_user_stat($userid);

            $this->gradable = $att->grade > 0;
            if ($this->gradable) {
                $this->grade = $att->get_user_grade($userid);
                $this->maxgrade = $att->get_user_max_grade($userid);
            }

            $this->filtercontrols = new attendance_filter_controls($att);

            $this->sessionslog = $att->get_user_filtered_sessions_log_extended($userid);

            $this->groups = groups_get_all_groups($att->course->id);
        } else {
            $this->coursesatts = local_att_get_user_courses_attendances($userid);

            $this->statuses = array();
            $this->stat = array();
            $this->gradable = array();
            $this->grade = array();
            $this->maxgrade = array();
            foreach ($this->coursesatts as $ca) {
                $statuses = local_att_get_statuses($ca->attid);
                $user_taken_sessions_count = local_att_get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid);
                $user_statuses_stat = local_att_get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid);

                $this->statuses[$ca->attid] = $statuses;

                $this->stat[$ca->attid]['completed'] = $user_taken_sessions_count;
                $this->stat[$ca->attid]['statuses'] = $user_statuses_stat;

                $this->gradable[$ca->attid] = $ca->attgrade > 0;

                if ($this->gradable[$ca->attid]) {
                    $this->grade[$ca->attid] = local_att_get_user_grade($user_statuses_stat, $statuses);
                    // For getting sessions count implemented simplest method - taken sessions.
                    // It can have error if users don't have attendance info for some sessions.
                    // In the future we can implement another methods:
                    // * all sessions between user start enrolment date and now;
                    // * all sessions between user start and end enrolment date.
                    $this->maxgrade[$ca->attid] = local_att_get_user_max_grade($user_taken_sessions_count, $statuses);
                } else {
                    // For more comfortable and universal work with arrays.
                    $this->grade[$ca->attid] = null;
                    $this->maxgrade[$ca->attid] = null;
                }
            }
        }

        $this->urlpath = $att->url_view()->out_omit_querystring();
        $params = $att->pageparams->get_significant_params();
        $params['id'] = $att->cm->id;
        $this->urlparams = $params;
    }