From 03ecbda6e8785c3c2aa49a879a4f486ad7a4d2b5 Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Tue, 13 Jul 2010 13:34:39 +0400 Subject: [PATCH] Page "Report" (report.php) considers two types of sessions --- manage.php | 4 ++-- report.php | 39 +++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/manage.php b/manage.php index ee37bc2..916a608 100644 --- a/manage.php +++ b/manage.php @@ -94,6 +94,7 @@ function print_sessions_list($course) { $allowtake = has_capability('mod/attforblock:takeattendances', $context); $allowchange = has_capability('mod/attforblock:changeattendances', $context); $allowmanage = has_capability('mod/attforblock:manageattendances', $context); + $groups = groups_get_all_groups($course->id); foreach($qry as $key=>$sessdata) { $i++; @@ -127,8 +128,7 @@ function print_sessions_list($course) { } $table->data[$sessdata->id][] = $i; - $groups = groups_get_all_groups($course->id); - $table->data[$sessdata->id][] = $sessdata->groupid == 0 ? get_string('commonsession', 'attforblock') : $groups[$sessdata->groupid]->name; + $table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock'); $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock')); $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock')); $hours = floor($sessdata->duration / HOURSECS); diff --git a/report.php b/report.php index 9d2a0fd..02d17c3 100644 --- a/report.php +++ b/report.php @@ -135,6 +135,8 @@ } else { $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate <= ".time(); } + if ($currentgroup) + $where .= " AND (groupid=0 OR groupid=".$currentgroup.")"; if ($students and ($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) { @@ -154,24 +156,28 @@ $table->size[] = ''; $allowtake = has_capability('mod/attforblock:takeattendances', $context); $allowchange = has_capability('mod/attforblock:changeattendances', $context); + $groups = groups_get_all_groups($course->id); foreach($course_sess as $sessdata) { if (count_records('attendance_log', 'sessionid', $sessdata->id)) { if ($allowchange) { - $table->head[] = "id}\">". + $sessdate = "id}&grouptype={$sessdata->groupid}\">". userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')'). '
'; } else { - $table->head[] = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')'); + $sessdate = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')'); } - + $sesstype = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock'); + $table->head[] = $sessdate.'
'.$sesstype; } else { if ($allowtake) { - $table->head[] = "id}\">". + $sessdate = "id}&grouptype={$sessdata->groupid}\">". userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')'). '
'; } else { - $table->head[] = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')'); + $sessdate = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')'); } + $sesstype = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock'); + $table->head[] = $sessdate.'
'.$sesstype; } $table->align[] = 'center'; $table->size[] = '1px'; @@ -184,15 +190,19 @@ foreach($statuses as $st) { $table->head[] = $st->acronym; } - $table->head[] = get_string('grade');//.' / '.$maxgrade; - $table->align[] = 'right'; - $table->size[] = '1px'; - $table->head[] = '%'; + if ($attforblock->grade) { + $table->head[] = get_string('grade');//.' / '.$maxgrade; + + $table->align[] = 'right'; + $table->size[] = '1px'; + $table->head[] = '%'; + } foreach($students as $student) { $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true); $table->data[$student->id][] = "id}\">".fullname($student).''; + $studgroups = groups_get_all_groups($COURSE->id, $student->id); foreach($course_sess as $sessdata) { if ($att = get_record('attendance_log', 'sessionid', $sessdata->id, 'studentid', $student->id)) { if (isset($statuses[$att->statusid])) { @@ -201,14 +211,19 @@ $table->data[$student->id][] = ''.$allstatuses[$att->statusid]->acronym.''; } } else { - $table->data[$student->id][] = '-'; + if ($sessdata->groupid && !$studgroups[$sessdata->groupid]) + $table->data[$student->id][] = ''; + else + $table->data[$student->id][] = '-'; } } foreach($statuses as $st) { $table->data[$student->id][] = get_attendance($student->id, $course, $st->id); } - $table->data[$student->id][] = get_grade($student->id, $course).' / '.get_maxgrade($student->id, $course); - $table->data[$student->id][] = get_percent($student->id, $course).'%'; + if ($attforblock->grade) { + $table->data[$student->id][] = get_grade($student->id, $course).' / '.get_maxgrade($student->id, $course); + $table->data[$student->id][] = get_percent($student->id, $course).'%'; + } } echo '
'; print_table($table);