Page "Report" (report.php) considers two types of sessions
authorArtem Andreev <andreev.artem@gmail.com>
Tue, 13 Jul 2010 09:34:39 +0000 (13:34 +0400)
committerArtem Andreev <andreev.artem@gmail.com>
Tue, 13 Jul 2010 09:34:39 +0000 (13:34 +0400)
manage.php
report.php

index ee37bc2..916a608 100644 (file)
@@ -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);
index 9d2a0fd..02d17c3 100644 (file)
                } 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'))) {
                        
                        $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[] = "<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').')').
                                          '</a>';
                     } 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 {
                     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').')').
                                          '</a>';
                     } 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->size[] = '1px';
                        foreach($statuses as $st) {
                                $table->head[] = $st->acronym;
                        }
-                       $table->head[] = get_string('grade');//.'&nbsp;/&nbsp;'.$maxgrade;
 
-                       $table->align[] = 'right';
-                       $table->size[] = '1px';
-                       $table->head[] = '%';
+            if ($attforblock->grade) {
+                $table->head[] = get_string('grade');//.'&nbsp;/&nbsp;'.$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][] = "<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) {
                                        if ($att = get_record('attendance_log', 'sessionid', $sessdata->id, 'studentid', $student->id)) {
                                                if (isset($statuses[$att->statusid])) {
                                                        $table->data[$student->id][] = '<font color="red"><b>'.$allstatuses[$att->statusid]->acronym.'</b></font>';
                                                }
                                        } 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).'&nbsp;/&nbsp;'.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).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course);
+                    $table->data[$student->id][] = get_percent($student->id, $course).'%';
+                }
                        }
                        echo '<br />';
                print_table($table);