Browse Source

Use correct prefix on function names.

MOODLE_29_STABLE
Dan Marsden 9 years ago
parent
commit
78e8697039
  1. 2
      add_form.php
  2. 12
      classes/structure.php
  3. 10
      lib.php
  4. 26
      locallib.php
  5. 16
      renderables.php
  6. 12
      renderhelpers.php
  7. 2
      update_form.php

2
add_form.php

@ -109,7 +109,7 @@ class mod_attendance_add_form extends moodleform {
if ($maxstatusset > 0) {
$opts = array();
for ($i = 0; $i <= $maxstatusset; $i++) {
$opts[$i] = att_get_setname($this->_customdata['att']->id, $i);
$opts[$i] = attendance_get_setname($this->_customdata['att']->id, $i);
}
$mform->addElement('select', 'statusset', get_string('usestatusset', 'mod_attendance'), $opts);
} else {

12
classes/structure.php

@ -696,8 +696,8 @@ class mod_attendance_structure {
$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);
$this->statuses = attendance_get_statuses($this->id, $onlyvisible, $statusset);
$this->allstatuses = attendance_get_statuses($this->id, $onlyvisible);
}
// Return all sets, if requested.
@ -757,10 +757,10 @@ class mod_attendance_structure {
public function get_user_taken_sessions_count($userid) {
if (!array_key_exists($userid, $this->usertakensesscount)) {
if (!empty($this->pageparams->startdate) && !empty($this->pageparams->enddate)) {
$this->usertakensesscount[$userid] = att_get_user_taken_sessions_count($this->id, $this->course->startdate,
$this->usertakensesscount[$userid] = attendance_get_user_taken_sessions_count($this->id, $this->course->startdate,
$userid, $this->cm, $this->pageparams->startdate, $this->pageparams->enddate);
} else {
$this->usertakensesscount[$userid] = att_get_user_taken_sessions_count($this->id, $this->course->startdate,
$this->usertakensesscount[$userid] = attendance_get_user_taken_sessions_count($this->id, $this->course->startdate,
$userid, $this->cm);
}
}
@ -842,7 +842,7 @@ class mod_attendance_structure {
* @return type
*/
public function get_user_grade($userid, array $filters = null) {
return att_get_user_grade($this->get_user_statuses_stat($userid, $filters), $this->get_statuses(true, true));
return attendance_get_user_grade($this->get_user_statuses_stat($userid, $filters), $this->get_statuses(true, true));
}
// For getting sessions count implemented simplest method - taken sessions.
@ -853,7 +853,7 @@ class mod_attendance_structure {
// While implementing those methods we need recalculate grades of all users
// on session adding.
public function get_user_max_grade($userid) {
return att_get_user_max_grade($this->get_user_taken_sessions_count($userid), $this->get_statuses(true, true));
return attendance_get_user_max_grade($this->get_user_taken_sessions_count($userid), $this->get_statuses(true, true));
}
public function update_users_grade($userids) {

10
lib.php

@ -227,11 +227,11 @@ function attendance_user_outline($course, $user, $mod, $attendance) {
$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);
$statuses = attendance_get_statuses($attendance->id);
$grade = attendance_get_user_grade(attendance_get_user_statuses_stat($attendance->id, $course->startdate,
$user->id, $mod), $statuses);
$maxgrade = attendance_get_user_max_grade(attendance_get_user_taken_sessions_count($attendance->id, $course->startdate,
$user->id, $mod), $statuses);
$result->info = $grade.' / '.$maxgrade;
}

26
locallib.php

@ -37,7 +37,7 @@ define('ATT_VIEW_NOTPRESENT', 6);
define('ATT_SORT_LASTNAME', 1);
define('ATT_SORT_FIRSTNAME', 2);
function att_get_statuses($attid, $onlyvisible=true, $statusset = -1) {
function attendance_get_statuses($attid, $onlyvisible=true, $statusset = -1) {
global $DB;
// Set selector.
@ -67,10 +67,10 @@ function att_get_statuses($attid, $onlyvisible=true, $statusset = -1) {
* @param bool $includevalues
* @return string
*/
function att_get_setname($attid, $statusset, $includevalues = true) {
function attendance_get_setname($attid, $statusset, $includevalues = true) {
$statusname = get_string('statusset', 'mod_attendance', $statusset + 1);
if ($includevalues) {
$statuses = att_get_statuses($attid, true, $statusset);
$statuses = attendance_get_statuses($attid, true, $statusset);
$statusesout = array();
foreach ($statuses as $status) {
$statusesout[] = $status->acronym;
@ -88,7 +88,7 @@ function att_get_setname($attid, $statusset, $includevalues = true) {
return $statusname;
}
function att_get_user_taken_sessions_count($attid, $coursestartdate, $userid, $coursemodule, $startdate = '', $enddate = '') {
function attendance_get_user_taken_sessions_count($attid, $coursestartdate, $userid, $coursemodule, $startdate = '', $enddate = '') {
global $DB, $COURSE;
$groupmode = groups_get_activity_groupmode($coursemodule, $COURSE);
if (!empty($groupmode)) {
@ -123,7 +123,7 @@ function att_get_user_taken_sessions_count($attid, $coursestartdate, $userid, $c
return $DB->count_records_sql($qry, $params);
}
function att_get_user_statuses_stat($attid, $coursestartdate, $userid, $coursemodule) {
function attendance_get_user_statuses_stat($attid, $coursestartdate, $userid, $coursemodule) {
global $DB, $COURSE;
$groupmode = groups_get_activity_groupmode($coursemodule, $COURSE);
if (!empty($groupmode)) {
@ -154,7 +154,7 @@ function att_get_user_statuses_stat($attid, $coursestartdate, $userid, $coursemo
return $DB->get_records_sql($qry, $params);
}
function att_get_user_grade($userstatusesstat, $statuses) {
function attendance_get_user_grade($userstatusesstat, $statuses) {
$sum = 0;
foreach ($userstatusesstat as $stat) {
$sum += $stat->stcnt * $statuses[$stat->statusid]->grade;
@ -163,12 +163,12 @@ function att_get_user_grade($userstatusesstat, $statuses) {
return $sum;
}
function att_get_user_max_grade($sesscount, $statuses) {
function attendance_get_user_max_grade($sesscount, $statuses) {
reset($statuses);
return current($statuses)->grade * $sesscount;
}
function att_get_user_courses_attendances($userid) {
function attendance_get_user_courses_attendances($userid) {
global $DB;
$usercourses = enrol_get_users_courses($userid);
@ -219,7 +219,7 @@ function attendance_update_all_users_grades(mod_attendance_structure $attendance
if (!empty($attgrades->items[0]) and !empty($attgrades->items[0]->grades)) {
$usergrades = $attgrades->items[0]->grades;
}
$statuses = att_get_statuses($attendance->id);
$statuses = attendance_get_statuses($attendance->id);
foreach ($usergrades as $userid => $existinggrade) {
if (is_null($existinggrade->grade)) {
// Don't update grades where one doesn't exist yet.
@ -227,10 +227,10 @@ function attendance_update_all_users_grades(mod_attendance_structure $attendance
}
$grade = new stdClass;
$grade->userid = $userid;
$userstatusesstat = att_get_user_statuses_stat($attendance->id, $course->startdate, $userid, $coursemodule);
$usertakensesscount = att_get_user_taken_sessions_count($attendance->id, $course->startdate, $userid, $coursemodule);
$usergrade = att_get_user_grade($userstatusesstat, $statuses);
$usermaxgrade = att_get_user_max_grade($usertakensesscount, $statuses);
$userstatusesstat = attendance_get_user_statuses_stat($attendance->id, $course->startdate, $userid, $coursemodule);
$usertakensesscount = attendance_get_user_taken_sessions_count($attendance->id, $course->startdate, $userid, $coursemodule);
$usergrade = attendance_get_user_grade($userstatusesstat, $statuses);
$usermaxgrade = attendance_get_user_max_grade($usertakensesscount, $statuses);
$grade->rawgrade = attendance_calc_user_grade_fraction($usergrade, $usermaxgrade) * $attendance->grade;
$grades[$userid] = $grade;
}

16
renderables.php

@ -387,7 +387,7 @@ class attendance_user_data implements renderable {
$this->groups = groups_get_all_groups($att->course->id);
} else {
$this->coursesatts = att_get_user_courses_attendances($userid);
$this->coursesatts = attendance_get_user_courses_attendances($userid);
$this->statuses = array();
$this->stat = array();
$this->gradable = array();
@ -399,9 +399,9 @@ class attendance_user_data implements renderable {
unset($this->courseatts[$atid]);
continue;
}
$statuses = att_get_statuses($ca->attid);
$usertakensessionscount = att_get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid, $att->cm);
$userstatusesstat = att_get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid, $att->cm);
$statuses = attendance_get_statuses($ca->attid);
$usertakensessionscount = attendance_get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid, $att->cm);
$userstatusesstat = attendance_get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid, $att->cm);
$this->statuses[$ca->attid] = $statuses;
@ -411,13 +411,13 @@ class attendance_user_data implements renderable {
$this->gradable[$ca->attid] = $ca->attgrade > 0;
if ($this->gradable[$ca->attid]) {
$this->grade[$ca->attid] = att_get_user_grade($userstatusesstat, $statuses);
$this->grade[$ca->attid] = attendance_get_user_grade($userstatusesstat, $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($usertakensessionscount, $statuses);
$this->maxgrade[$ca->attid] = attendance_get_user_max_grade($usertakensessionscount, $statuses);
} else {
// For more comfortable and universal work with arrays.
$this->grade[$ca->attid] = null;
@ -498,7 +498,7 @@ class attendance_report_data implements renderable {
$this->decimalpoints = $CFG->grade_decimalpoints;
}
$maxgrade = att_get_user_max_grade(count($this->sessions), $this->statuses);
$maxgrade = attendance_get_user_max_grade(count($this->sessions), $this->statuses);
foreach ($this->users as $key => $user) {
$grade = 0;
@ -595,7 +595,7 @@ class attendance_set_selector implements renderable {
}
public function get_status_name($statusset) {
return att_get_setname($this->att->id, $statusset, true);
return attendance_get_setname($this->att->id, $statusset, true);
}
}

12
renderhelpers.php

@ -270,14 +270,14 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade
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);
$statuses = attendance_get_statuses($attendance->id);
$userstatusesstat = attendance_get_user_statuses_stat($attendance->id, $course->startdate, $user->id, $coursemodule);
$stat['completed'] = attendance_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);
$grade = attendance_get_user_grade($userstatusesstat, $statuses);
$maxgrade = attendance_get_user_max_grade(attendance_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;
}

2
update_form.php

@ -86,7 +86,7 @@ class mod_attendance_update_form extends moodleform {
$maxstatusset = attendance_get_max_statusset($this->_customdata['att']->id);
if ($maxstatusset > 0) {
$mform->addElement('static', 'statusset', get_string('usestatusset', 'mod_attendance'),
att_get_setname($this->_customdata['att']->id, $sess->statusset));
attendance_get_setname($this->_customdata['att']->id, $sess->statusset));
}
$mform->addElement('editor', 'sdescription', get_string('description', 'attendance'),

Loading…
Cancel
Save