Browse Source

Page "Report" (report.php) considers two types of sessions

MOODLE_23_STABLE
Artem Andreev 15 years ago
parent
commit
03ecbda6e8
  1. 4
      manage.php
  2. 25
      report.php

4
manage.php

@ -94,6 +94,7 @@ function print_sessions_list($course) {
$allowtake = has_capability('mod/attforblock:takeattendances', $context); $allowtake = has_capability('mod/attforblock:takeattendances', $context);
$allowchange = has_capability('mod/attforblock:changeattendances', $context); $allowchange = has_capability('mod/attforblock:changeattendances', $context);
$allowmanage = has_capability('mod/attforblock:manageattendances', $context); $allowmanage = has_capability('mod/attforblock:manageattendances', $context);
$groups = groups_get_all_groups($course->id);
foreach($qry as $key=>$sessdata) foreach($qry as $key=>$sessdata)
{ {
$i++; $i++;
@ -127,8 +128,7 @@ function print_sessions_list($course) {
} }
$table->data[$sessdata->id][] = $i; $table->data[$sessdata->id][] = $i;
$groups = groups_get_all_groups($course->id); $table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
$table->data[$sessdata->id][] = $sessdata->groupid == 0 ? get_string('commonsession', 'attforblock') : $groups[$sessdata->groupid]->name;
$table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock')); $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock'));
$table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock')); $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock'));
$hours = floor($sessdata->duration / HOURSECS); $hours = floor($sessdata->duration / HOURSECS);

25
report.php

@ -135,6 +135,8 @@
} else { } else {
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate <= ".time(); $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate <= ".time();
} }
if ($currentgroup)
$where .= " AND (groupid=0 OR groupid=".$currentgroup.")";
if ($students and if ($students and
($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) { ($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) {
@ -154,24 +156,28 @@
$table->size[] = ''; $table->size[] = '';
$allowtake = has_capability('mod/attforblock:takeattendances', $context); $allowtake = has_capability('mod/attforblock:takeattendances', $context);
$allowchange = has_capability('mod/attforblock:changeattendances', $context); $allowchange = has_capability('mod/attforblock:changeattendances', $context);
$groups = groups_get_all_groups($course->id);
foreach($course_sess as $sessdata) { foreach($course_sess as $sessdata) {
if (count_records('attendance_log', 'sessionid', $sessdata->id)) { if (count_records('attendance_log', 'sessionid', $sessdata->id)) {
if ($allowchange) { if ($allowchange) {
$table->head[] = "<a href=\"attendances.php?id=$id&amp;sessionid={$sessdata->id}\">". $sessdate = "<a href=\"attendances.php?id=$id&amp;sessionid={$sessdata->id}&amp;grouptype={$sessdata->groupid}\">".
userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')'). userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')').
'</a>'; '</a>';
} else { } else {
$table->head[] = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')'); $sessdate = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')');
} }
$sesstype = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
$table->head[] = $sessdate.'<br />'.$sesstype;
} else { } else {
if ($allowtake) { if ($allowtake) {
$table->head[] = "<a href=\"attendances.php?id=$id&amp;sessionid={$sessdata->id}\">". $sessdate = "<a href=\"attendances.php?id=$id&amp;sessionid={$sessdata->id}&amp;grouptype={$sessdata->groupid}\">".
userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')'). userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')').
'</a>'; '</a>';
} else { } else {
$table->head[] = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')'); $sessdate = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'<br />('.get_string('strftimehm', 'attforblock').')');
} }
$sesstype = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
$table->head[] = $sessdate.'<br />'.$sesstype;
} }
$table->align[] = 'center'; $table->align[] = 'center';
$table->size[] = '1px'; $table->size[] = '1px';
@ -184,15 +190,19 @@
foreach($statuses as $st) { foreach($statuses as $st) {
$table->head[] = $st->acronym; $table->head[] = $st->acronym;
} }
if ($attforblock->grade) {
$table->head[] = get_string('grade');//.'&nbsp;/&nbsp;'.$maxgrade; $table->head[] = get_string('grade');//.'&nbsp;/&nbsp;'.$maxgrade;
$table->align[] = 'right'; $table->align[] = 'right';
$table->size[] = '1px'; $table->size[] = '1px';
$table->head[] = '%'; $table->head[] = '%';
}
foreach($students as $student) { foreach($students as $student) {
$table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true); $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true);
$table->data[$student->id][] = "<a href=\"view.php?id=$id&amp;student={$student->id}\">".fullname($student).'</a>'; $table->data[$student->id][] = "<a href=\"view.php?id=$id&amp;student={$student->id}\">".fullname($student).'</a>';
$studgroups = groups_get_all_groups($COURSE->id, $student->id);
foreach($course_sess as $sessdata) { foreach($course_sess as $sessdata) {
if ($att = get_record('attendance_log', 'sessionid', $sessdata->id, 'studentid', $student->id)) { if ($att = get_record('attendance_log', 'sessionid', $sessdata->id, 'studentid', $student->id)) {
if (isset($statuses[$att->statusid])) { if (isset($statuses[$att->statusid])) {
@ -201,14 +211,19 @@
$table->data[$student->id][] = '<font color="red"><b>'.$allstatuses[$att->statusid]->acronym.'</b></font>'; $table->data[$student->id][] = '<font color="red"><b>'.$allstatuses[$att->statusid]->acronym.'</b></font>';
} }
} else { } else {
if ($sessdata->groupid && !$studgroups[$sessdata->groupid])
$table->data[$student->id][] = '';
else
$table->data[$student->id][] = '-'; $table->data[$student->id][] = '-';
} }
} }
foreach($statuses as $st) { foreach($statuses as $st) {
$table->data[$student->id][] = get_attendance($student->id, $course, $st->id); $table->data[$student->id][] = get_attendance($student->id, $course, $st->id);
} }
if ($attforblock->grade) {
$table->data[$student->id][] = get_grade($student->id, $course).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course); $table->data[$student->id][] = get_grade($student->id, $course).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course);
$table->data[$student->id][] = get_percent($student->id, $course).'%'; $table->data[$student->id][] = get_percent($student->id, $course).'%';
}
} }
echo '<br />'; echo '<br />';
print_table($table); print_table($table);

Loading…
Cancel
Save