Browse Source

Adjusts student reports

MOODLE_31_STABLE
Antonio Carlos Mariani 9 years ago
parent
commit
5831a03010
  1. 4
      classes/structure.php
  2. 9
      lang/en/attendance.php
  3. 52
      renderables.php
  4. 27
      renderer.php
  5. 82
      renderhelpers.php

4
classes/structure.php

@ -930,7 +930,7 @@ class mod_attendance_structure {
WHERE $where AND (ats.groupid = 0 or gm.id is NOT NULL) WHERE $where AND (ats.groupid = 0 or gm.id is NOT NULL)
ORDER BY ats.sessdate ASC"; ORDER BY ats.sessdate ASC";
} else { } else {
$sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, $sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, ats.statusset,
al.statusid, al.remarks, ats.studentscanmark al.statusid, al.remarks, ats.studentscanmark
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
RIGHT JOIN {attendance_log} al RIGHT JOIN {attendance_log} al
@ -961,7 +961,7 @@ class mod_attendance_structure {
$where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate AND ats.groupid $gsql"; $where = "ats.attendanceid = :aid AND ats.sessdate >= :csdate AND ats.groupid $gsql";
} }
$sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, $sql = "SELECT $id, ats.id, ats.groupid, ats.sessdate, ats.duration, ats.description, ats.statusset,
al.statusid, al.remarks, ats.studentscanmark al.statusid, al.remarks, ats.studentscanmark
FROM {attendance_sessions} ats FROM {attendance_sessions} ats
LEFT JOIN {attendance_log} al LEFT JOIN {attendance_log} al

9
lang/en/attendance.php

@ -133,6 +133,8 @@ $string['indetail'] = 'In detail...';
$string['invalidsessionenddate'] = 'This date can not be earlier than the session date'; $string['invalidsessionenddate'] = 'This date can not be earlier than the session date';
$string['invalidaction'] = 'You must select an action'; $string['invalidaction'] = 'You must select an action';
$string['jumpto'] = 'Jump to'; $string['jumpto'] = 'Jump to';
$string['maxpossiblepoints'] = 'Maximum possible points';
$string['maxpossiblepercentage'] = 'Maximum possible percentage';
$string['mergeuser'] = 'Merge user'; $string['mergeuser'] = 'Merge user';
$string['modulename'] = 'Attendance'; $string['modulename'] = 'Attendance';
$string['modulename_help'] = 'The attendance activity module enables a teacher to take attendance during class and students to view their own attendance record. $string['modulename_help'] = 'The attendance activity module enables a teacher to take attendance during class and students to view their own attendance record.
@ -165,6 +167,8 @@ $string['olddate'] = 'Old date';
$string['onlyselectedusers'] = 'Export specific users'; $string['onlyselectedusers'] = 'Export specific users';
$string['participant'] = 'Participant'; $string['participant'] = 'Participant';
$string['percentage'] = 'Percentage'; $string['percentage'] = 'Percentage';
$string['percentagesessionscompleted'] = 'Percentage over taked sessions';
$string['percentageallsessions'] = 'Percentage over all sessions';
$string['pluginname'] = 'Attendance'; $string['pluginname'] = 'Attendance';
$string['pluginadministration'] = 'Attendance administration'; $string['pluginadministration'] = 'Attendance administration';
$string['remark'] = 'Remark for: {$a}'; $string['remark'] = 'Remark for: {$a}';
@ -221,7 +225,8 @@ $string['sessiondays'] = 'Session Days';
$string['sessiondeleted'] = 'Session successfully deleted'; $string['sessiondeleted'] = 'Session successfully deleted';
$string['sessionexist'] = 'Session not added (already exists)!'; $string['sessionexist'] = 'Session not added (already exists)!';
$string['sessions'] = 'Sessions'; $string['sessions'] = 'Sessions';
$string['sessionscompleted'] = 'Sessions completed'; $string['sessionscompleted'] = 'Taked sessions';
$string['sessionstotal'] = 'Total number of sessions';
$string['sessionsids'] = 'IDs of sessions: '; $string['sessionsids'] = 'IDs of sessions: ';
$string['sessiongenerated'] = 'One session was successfully generated'; $string['sessiongenerated'] = 'One session was successfully generated';
$string['sessionsgenerated'] = '{$a} sessions were successfully generated'; $string['sessionsgenerated'] = '{$a} sessions were successfully generated';
@ -302,6 +307,8 @@ $string['submitattendance'] = 'Submit attendance';
$string['attendancenotset'] = 'You must set your attendance'; $string['attendancenotset'] = 'You must set your attendance';
$string['export'] = 'Export'; $string['export'] = 'Export';
$string['points'] = 'Points'; $string['points'] = 'Points';
$string['pointssessionscompleted'] = 'Points over taked sessions';
$string['pointsallsessions'] = 'Points over all sessions';
$string['unknowngroup'] = 'Unknown group'; $string['unknowngroup'] = 'Unknown group';
$string['notmember'] = 'not member'; $string['notmember'] = 'not member';

52
renderables.php

@ -340,13 +340,7 @@ class attendance_user_data implements renderable {
public $statuses; public $statuses;
public $gradable; public $summary;
public $grade;
public $maxgrade;
public $decimalpoints;
public $filtercontrols; public $filtercontrols;
@ -360,26 +354,14 @@ class attendance_user_data implements renderable {
private $urlparams; private $urlparams;
public function __construct(mod_attendance_structure $att, $userid) { public function __construct(mod_attendance_structure $att, $userid) {
global $CFG;
$this->user = $att->get_user($userid); $this->user = $att->get_user($userid);
$this->pageparams = $att->pageparams; $this->pageparams = $att->pageparams;
if (!$this->decimalpoints = grade_get_setting($att->course->id, 'decimalpoints')) {
$this->decimalpoints = $CFG->grade_decimalpoints;
}
if ($this->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) { if ($this->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) {
$this->statuses = $att->get_statuses(true, true); $this->statuses = $att->get_statuses(true, true);
$this->stat = $att->get_user_stat($userid); $this->summary = new mod_attendance_summary($att->id, array($userid), $att->pageparams->startdate, $att->pageparams->enddate);
$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->filtercontrols = new attendance_filter_controls($att);
@ -389,10 +371,7 @@ class attendance_user_data implements renderable {
} else { } else {
$this->coursesatts = attendance_get_user_courses_attendances($userid); $this->coursesatts = attendance_get_user_courses_attendances($userid);
$this->statuses = array(); $this->statuses = array();
$this->stat = array(); $this->summary = array();
$this->gradable = array();
$this->grade = array();
$this->maxgrade = array();
foreach ($this->coursesatts as $atid => $ca) { foreach ($this->coursesatts as $atid => $ca) {
// Check to make sure the user can view this cm. // Check to make sure the user can view this cm.
if (!get_fast_modinfo($ca->courseid)->instances['attendance'][$ca->attid]->uservisible) { if (!get_fast_modinfo($ca->courseid)->instances['attendance'][$ca->attid]->uservisible) {
@ -400,29 +379,8 @@ class attendance_user_data implements renderable {
continue; continue;
} }
$statuses = attendance_get_statuses($ca->attid); $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->summary[$ca->attid] = new mod_attendance_summary($ca->attid, array($userid));
$this->statuses[$ca->attid] = $statuses;
$this->stat[$ca->attid]['completed'] = $usertakensessionscount;
$this->stat[$ca->attid]['statuses'] = $userstatusesstat;
$this->gradable[$ca->attid] = $ca->attgrade > 0;
if ($this->gradable[$ca->attid]) {
$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] = attendance_get_user_max_grade($usertakensessionscount, $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(); $this->urlpath = $att->url_view()->out_omit_querystring();

27
renderer.php

@ -735,8 +735,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
if ($userdata->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) { if ($userdata->pageparams->mode == mod_attendance_view_page_params::MODE_THIS_COURSE) {
$o .= html_writer::empty_tag('hr'); $o .= html_writer::empty_tag('hr');
$o .= construct_user_data_stat($userdata->stat, $userdata->statuses, $o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id), $userdata->pageparams->view);
$userdata->gradable, $userdata->grade, $userdata->maxgrade, $userdata->decimalpoints);
$o .= $this->render_attendance_filter_controls($userdata->filtercontrols); $o .= $this->render_attendance_filter_controls($userdata->filtercontrols);
@ -752,9 +751,12 @@ class mod_attendance_renderer extends plugin_renderer_base {
} }
$o .= html_writer::tag('h4', $ca->attname); $o .= html_writer::tag('h4', $ca->attname);
$o .= construct_user_data_stat($userdata->stat[$ca->attid], $userdata->statuses[$ca->attid], if (isset($userdata->summary[$ca->attid])) {
$userdata->gradable[$ca->attid], $userdata->grade[$ca->attid], $usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id);
$userdata->maxgrade[$ca->attid], $userdata->decimalpoints); } else {
$usersummary = null;
}
$o .= construct_user_data_stat($usersummary, ATT_VIEW_ALL);
} }
} }
@ -771,10 +773,13 @@ class mod_attendance_renderer extends plugin_renderer_base {
get_string('time'), get_string('time'),
get_string('description', 'attendance'), get_string('description', 'attendance'),
get_string('status', 'attendance'), get_string('status', 'attendance'),
get_string('points', 'attendance'),
get_string('remarks', 'attendance') get_string('remarks', 'attendance')
); );
$table->align = array('', '', '', 'left', 'left', 'center', 'left', 'center'); $table->align = array('', '', '', 'left', 'left', 'center', 'center', 'center');
$table->size = array('1px', '1px', '1px', '1px', '*', '1px', '1px', '*'); $table->size = array('1px', '1px', '1px', '1px', '*', '*', '1px', '*');
$statussetmaxpoints = attendance_get_statusset_maxpoints($userdata->statuses);
$i = 0; $i = 0;
foreach ($userdata->sessionslog as $sess) { foreach ($userdata->sessionslog as $sess) {
@ -793,7 +798,10 @@ class mod_attendance_renderer extends plugin_renderer_base {
$row->cells[] = $this->construct_time($sess->sessdate, $sess->duration); $row->cells[] = $this->construct_time($sess->sessdate, $sess->duration);
$row->cells[] = $sess->description; $row->cells[] = $sess->description;
if (isset($sess->statusid)) { if (isset($sess->statusid)) {
$row->cells[] = $userdata->statuses[$sess->statusid]->description; $status = $userdata->statuses[$sess->statusid];
$row->cells[] = $status->description;
$row->cells[] = attendance_format_float($status->grade) . ' / ' .
attendance_format_float($statussetmaxpoints[$status->setnumber]);
$row->cells[] = $sess->remarks; $row->cells[] = $sess->remarks;
} else if ($sess->sessdate < $userdata->user->enrolmentstart) { } else if ($sess->sessdate < $userdata->user->enrolmentstart) {
$cell = new html_table_cell(get_string('enrolmentstart', 'attendance', $cell = new html_table_cell(get_string('enrolmentstart', 'attendance',
@ -815,6 +823,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$row->cells[] = $cell; $row->cells[] = $cell;
} else { // Student cannot mark their own attendace. } else { // Student cannot mark their own attendace.
$row->cells[] = '?'; $row->cells[] = '?';
$row->cells[] = '? / ' . attendance_format_float($statussetmaxpoints[$sess->statusset]);
$row->cells[] = ''; $row->cells[] = '';
} }
} }
@ -1008,7 +1017,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->head = array('#', $table->head = array('#',
get_string('acronym', 'attendance'), get_string('acronym', 'attendance'),
get_string('description'), get_string('description'),
get_string('grade'), get_string('points', 'attendance'),
get_string('action')); get_string('action'));
$table->align = array('center', 'center', 'center', 'center', 'center', 'center'); $table->align = array('center', 'center', 'center', 'center', 'center', 'center');

82
renderhelpers.php

@ -228,39 +228,62 @@ function construct_session_full_date_time($datetime, $duration) {
return $sessinfo; return $sessinfo;
} }
function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade, $decimalpoints) { function construct_user_data_stat($usersummary, $view) {
global $OUTPUT; global $OUTPUT;
if (empty($usersummary)) {
return 'no data';
}
$stattable = new html_table(); $stattable = new html_table();
$stattable->attributes['class'] = 'attlist'; $stattable->attributes['class'] = 'attlist';
$row = new html_table_row(); $row = new html_table_row();
$row->cells[] = get_string('sessionscompleted', 'attendance').':'; $row->attributes['class'] = 'normal';
$row->cells[] = $stat['completed']; $row->cells[] = get_string('sessionscompleted', 'attendance') . ':';
$row->cells[] = $usersummary->numtakensessions;
$stattable->data[] = $row;
$row = new html_table_row();
$row->attributes['class'] = 'normal';
$row->cells[] = get_string('pointssessionscompleted', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . attendance_format_float($usersummary->takensessionsmaxpoints);
$stattable->data[] = $row; $stattable->data[] = $row;
foreach ($statuses as $st) { $row = new html_table_row();
$row->attributes['class'] = 'normal';
$row->cells[] = get_string('percentagesessionscompleted', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->takensessionspercentage * 100, false) . '%';
$stattable->data[] = $row;
if ($view == ATT_VIEW_ALL) {
$row = new html_table_row(); $row = new html_table_row();
$row->cells[] = $st->description . ':'; $row->attributes['class'] = 'highlight';
$row->cells[] = array_key_exists($st->id, $stat['statuses']) ? $stat['statuses'][$st->id]->stcnt : 0; $row->cells[] = get_string('sessionstotal', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->numallsessions);
$stattable->data[] = $row;
$row = new html_table_row();
$row->attributes['class'] = 'highlight';
$row->cells[] = get_string('pointsallsessions', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->takensessionspoints) . ' / ' . attendance_format_float($usersummary->allsessionsmaxpoints);
$stattable->data[] = $row; $stattable->data[] = $row;
}
if ($gradable) {
$row = new html_table_row(); $row = new html_table_row();
$row->cells[] = get_string('attendancegrade', 'attendance') . $row->attributes['class'] = 'highlight';
$OUTPUT->help_icon('gradebookexplanation', 'attendance') . ':'; $row->cells[] = get_string('percentageallsessions', 'attendance') . ':';
$row->cells[] = format_float($grade) . ' / ' . format_float($maxgrade); $row->cells[] = attendance_format_float($usersummary->allsessionspercentage * 100, false) . '%';
$stattable->data[] = $row; $stattable->data[] = $row;
$row = new html_table_row(); $row = new html_table_row();
$row->cells[] = get_string('attendancepercent', 'attendance') . ':'; $row->attributes['class'] = 'normal';
if ($maxgrade == 0) { $row->cells[] = get_string('maxpossiblepoints', 'attendance') . ':';
$percent = 0; $row->cells[] = attendance_format_float($usersummary->maxpossiblepoints) . ' / ' . attendance_format_float($usersummary->allsessionsmaxpoints);
} else { $stattable->data[] = $row;
$percent = $grade / $maxgrade * 100;
} $row = new html_table_row();
$row->cells[] = format_float(sprintf("%0.{$decimalpoints}f", $percent)); $row->attributes['class'] = 'normal';
$row->cells[] = get_string('maxpossiblepercentage', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->maxpossiblepercentage * 100, false) . '%';
$stattable->data[] = $row; $stattable->data[] = $row;
} }
@ -268,25 +291,6 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade
} }
function construct_full_user_stat_html_table($attendance, $course, $user, $coursemodule) { function construct_full_user_stat_html_table($attendance, $course, $user, $coursemodule) {
global $CFG; $summary = new mod_attendance_summary($attendance->id, $user->id);
$gradeable = $attendance->grade > 0; return construct_user_data_stat($summary->get_all_sessions_summary_for($user->id), ATT_VIEW_ALL);
$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 = 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;
}
} else {
$grade = 0;
$maxgrade = 0;
$decimalpoints = 0;
}
return construct_user_data_stat($stat, $statuses,
$gradeable, $grade, $maxgrade, $decimalpoints);
} }

Loading…
Cancel
Save