public function get_statuses($onlyvisible = true) { if (!isset($this->statuses)) { $this->statuses = att_get_statuses($this->id, $onlyvisible); } return $this->statuses; }
public function get_statuses($onlyvisible = true, $allsets = false) { if (!isset($this->statuses)) { // Get the statuses for the current set only. $statusset = 0; if (isset($this->pageparams->statusset)) { $statusset = $this->pageparams->statusset; } else { if (isset($this->pageparams->sessionid)) { $sessioninfo = $this->get_session_info($this->pageparams->sessionid); $statusset = $sessioninfo->statusset; } } $this->statuses = att_get_statuses($this->id, $onlyvisible, $statusset); $this->allstatuses = att_get_statuses($this->id, $onlyvisible); } // Return all sets, if requested. if ($allsets) { return $this->allstatuses; } return $this->statuses; }
function 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, 'mod', '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('mod/attendance:canbelisted', $mod->context, $user->id)) { $statuses = att_get_statuses($attendance->id); $grade = att_get_user_grade(att_get_user_statuses_stat($attendance->id, $course->startdate, $user->id, $mod), $statuses); $maxgrade = att_get_user_max_grade(att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id, $mod), $statuses); $result->info = $grade . ' / ' . $maxgrade; } return $result; }
function attforblock_user_outline($course, $user, $mod, $attforblock) { /// Return a small object with summary information about what a /// user has done with a given particular instance of this module /// Used for user activity reports. /// $return->time = the time they did it /// $return->info = a short text description global $CFG; require_once dirname(__FILE__) . '/locallib.php'; require_once $CFG->libdir . '/gradelib.php'; $grades = grade_get_grades($course->id, 'mod', 'attforblock', $attforblock->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('mod/attforblock:canbelisted', $mod->context, $user->id)) { $statuses = att_get_statuses($attforblock->id); $grade = att_get_user_grade(get_user_statuses_stat($attforblock->id, $course->startdate, $user->id), $statuses); $maxgrade = att_get_user_max_grade(get_user_taken_sessions_count($attforblock->id, $course->startdate, $user->id), $statuses); $result->info = $grade . ' / ' . $maxgrade; } return $result; }
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 = 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 = att_get_statuses($ca->attid); $user_taken_sessions_count = att_get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid, $att->cm); $user_statuses_stat = att_get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid, $att->cm); $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] = 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] = 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; }
function construct_full_user_stat_html_table($attendance, $course, $user, $coursemodule) { global $CFG; $gradeable = $attendance->grade > 0; $statuses = att_get_statuses($attendance->id); $userstatusesstat = att_get_user_statuses_stat($attendance->id, $course->startdate, $user->id, $coursemodule); $stat['completed'] = att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id, $coursemodule); $stat['statuses'] = $userstatusesstat; if ($gradeable) { $grade = att_get_user_grade($userstatusesstat, $statuses); $maxgrade = att_get_user_max_grade(att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id, $coursemodule), $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); }
/** * Gets the available attcontrol statuses * @return array statuses for attcontrol taking */ public function get_statuses() { if (!isset($this->statuses)) { $this->statuses = att_get_statuses(); } return $this->statuses; }