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)
ORDER BY ats.sessdate ASC";
} 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
FROM {attendance_sessions} ats
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";
}
$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
FROM {attendance_sessions} ats
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['invalidaction'] = 'You must select an action';
$string['jumpto'] = 'Jump to';
$string['maxpossiblepoints'] = 'Maximum possible points';
$string['maxpossiblepercentage'] = 'Maximum possible percentage';
$string['mergeuser'] = 'Merge user';
$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.
@ -165,6 +167,8 @@ $string['olddate'] = 'Old date';
$string['onlyselectedusers'] = 'Export specific users';
$string['participant'] = 'Participant';
$string['percentage'] = 'Percentage';
$string['percentagesessionscompleted'] = 'Percentage over taked sessions';
$string['percentageallsessions'] = 'Percentage over all sessions';
$string['pluginname'] = 'Attendance';
$string['pluginadministration'] = 'Attendance administration';
$string['remark'] = 'Remark for: {$a}';
@ -221,7 +225,8 @@ $string['sessiondays'] = 'Session Days';
$string['sessiondeleted'] = 'Session successfully deleted';
$string['sessionexist'] = 'Session not added (already exists)!';
$string['sessions'] = 'Sessions';
$string['sessionscompleted'] = 'Sessions completed';
$string['sessionscompleted'] = 'Taked sessions';
$string['sessionstotal'] = 'Total number of sessions';
$string['sessionsids'] = 'IDs of sessions: ';
$string['sessiongenerated'] = 'One session was 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['export'] = 'Export';
$string['points'] = 'Points';
$string['pointssessionscompleted'] = 'Points over taked sessions';
$string['pointsallsessions'] = 'Points over all sessions';
$string['unknowngroup'] = 'Unknown group';
$string['notmember'] = 'not member';

52
renderables.php

@ -340,13 +340,7 @@ class attendance_user_data implements renderable {
public $statuses;
public $gradable;
public $grade;
public $maxgrade;
public $decimalpoints;
public $summary;
public $filtercontrols;
@ -360,26 +354,14 @@ class attendance_user_data implements renderable {
private $urlparams;
public function __construct(mod_attendance_structure $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 == mod_attendance_view_page_params::MODE_THIS_COURSE) {
$this->statuses = $att->get_statuses(true, true);
$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->summary = new mod_attendance_summary($att->id, array($userid), $att->pageparams->startdate, $att->pageparams->enddate);
$this->filtercontrols = new attendance_filter_controls($att);
@ -389,10 +371,7 @@ class attendance_user_data implements renderable {
} else {
$this->coursesatts = attendance_get_user_courses_attendances($userid);
$this->statuses = array();
$this->stat = array();
$this->gradable = array();
$this->grade = array();
$this->maxgrade = array();
$this->summary = array();
foreach ($this->coursesatts as $atid => $ca) {
// Check to make sure the user can view this cm.
if (!get_fast_modinfo($ca->courseid)->instances['attendance'][$ca->attid]->uservisible) {
@ -400,29 +379,8 @@ class attendance_user_data implements renderable {
continue;
}
$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;
$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->summary[$ca->attid] = new mod_attendance_summary($ca->attid, array($userid));
}
}
$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) {
$o .= html_writer::empty_tag('hr');
$o .= construct_user_data_stat($userdata->stat, $userdata->statuses,
$userdata->gradable, $userdata->grade, $userdata->maxgrade, $userdata->decimalpoints);
$o .= construct_user_data_stat($userdata->summary->get_all_sessions_summary_for($userdata->user->id), $userdata->pageparams->view);
$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 .= construct_user_data_stat($userdata->stat[$ca->attid], $userdata->statuses[$ca->attid],
$userdata->gradable[$ca->attid], $userdata->grade[$ca->attid],
$userdata->maxgrade[$ca->attid], $userdata->decimalpoints);
if (isset($userdata->summary[$ca->attid])) {
$usersummary = $userdata->summary[$ca->attid]->get_all_sessions_summary_for($userdata->user->id);
} 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('description', 'attendance'),
get_string('status', 'attendance'),
get_string('points', 'attendance'),
get_string('remarks', 'attendance')
);
$table->align = array('', '', '', 'left', 'left', 'center', 'left', 'center');
$table->size = array('1px', '1px', '1px', '1px', '*', '1px', '1px', '*');
$table->align = array('', '', '', 'left', 'left', 'center', 'center', 'center');
$table->size = array('1px', '1px', '1px', '1px', '*', '*', '1px', '*');
$statussetmaxpoints = attendance_get_statusset_maxpoints($userdata->statuses);
$i = 0;
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[] = $sess->description;
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;
} else if ($sess->sessdate < $userdata->user->enrolmentstart) {
$cell = new html_table_cell(get_string('enrolmentstart', 'attendance',
@ -815,6 +823,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$row->cells[] = $cell;
} else { // Student cannot mark their own attendace.
$row->cells[] = '?';
$row->cells[] = '? / ' . attendance_format_float($statussetmaxpoints[$sess->statusset]);
$row->cells[] = '';
}
}
@ -1008,7 +1017,7 @@ class mod_attendance_renderer extends plugin_renderer_base {
$table->head = array('#',
get_string('acronym', 'attendance'),
get_string('description'),
get_string('grade'),
get_string('points', 'attendance'),
get_string('action'));
$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;
}
function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade, $decimalpoints) {
function construct_user_data_stat($usersummary, $view) {
global $OUTPUT;
if (empty($usersummary)) {
return 'no data';
}
$stattable = new html_table();
$stattable->attributes['class'] = 'attlist';
$row = new html_table_row();
$row->cells[] = get_string('sessionscompleted', 'attendance').':';
$row->cells[] = $stat['completed'];
$row->attributes['class'] = 'normal';
$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;
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->cells[] = $st->description . ':';
$row->cells[] = array_key_exists($st->id, $stat['statuses']) ? $stat['statuses'][$st->id]->stcnt : 0;
$row->attributes['class'] = 'highlight';
$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;
}
if ($gradable) {
$row = new html_table_row();
$row->cells[] = get_string('attendancegrade', 'attendance') .
$OUTPUT->help_icon('gradebookexplanation', 'attendance') . ':';
$row->cells[] = format_float($grade) . ' / ' . format_float($maxgrade);
$row->attributes['class'] = 'highlight';
$row->cells[] = get_string('percentageallsessions', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->allsessionspercentage * 100, false) . '%';
$stattable->data[] = $row;
$row = new html_table_row();
$row->cells[] = get_string('attendancepercent', 'attendance') . ':';
if ($maxgrade == 0) {
$percent = 0;
} else {
$percent = $grade / $maxgrade * 100;
}
$row->cells[] = format_float(sprintf("%0.{$decimalpoints}f", $percent));
$row->attributes['class'] = 'normal';
$row->cells[] = get_string('maxpossiblepoints', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->maxpossiblepoints) . ' / ' . attendance_format_float($usersummary->allsessionsmaxpoints);
$stattable->data[] = $row;
$row = new html_table_row();
$row->attributes['class'] = 'normal';
$row->cells[] = get_string('maxpossiblepercentage', 'attendance') . ':';
$row->cells[] = attendance_format_float($usersummary->maxpossiblepercentage * 100, false) . '%';
$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) {
global $CFG;
$gradeable = $attendance->grade > 0;
$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);
$summary = new mod_attendance_summary($attendance->id, $user->id);
return construct_user_data_stat($summary->get_all_sessions_summary_for($user->id), ATT_VIEW_ALL);
}

Loading…
Cancel
Save