diff --git a/attendances.php b/attendances.php index b88fceb..09a38ab 100644 --- a/attendances.php +++ b/attendances.php @@ -13,6 +13,7 @@ $id = required_param('id', PARAM_INT); $sessionid = required_param('sessionid', PARAM_INT); + $grouptype = required_param('grouptype', PARAM_INT); $group = optional_param('group', -1, PARAM_INT); // Group to show $sort = optional_param('sort','lastname', PARAM_ALPHA); @@ -102,17 +103,22 @@ $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); - if ($currentgroup) { - $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); + if ($grouptype === 0) { + if ($currentgroup) { + $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); + } else { + $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); + } } else { - $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); + $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $grouptype, '', false); } $sort = $sort == 'firstname' ? 'firstname' : 'lastname'; /// Now we need a menu for separategroups as well! - if ($groupmode == VISIBLEGROUPS || - ($groupmode && has_capability('moodle/site:accessallgroups', $context))) { - groups_print_activity_menu($cm, "attendances.php?id=$id&sessionid=$sessionid&sort=$sort"); + if ($grouptype === 0 && + ($groupmode == VISIBLEGROUPS || + ($groupmode && has_capability('moodle/site:accessallgroups', $context)))) { + groups_print_activity_menu($cm, "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&sort=$sort"); } $table->data[][] = ''.get_string('sessiondate','attforblock').': '.userdate($sessdata->sessdate, get_string('strftimedate').', '.get_string('strftimehm', 'attforblock')). diff --git a/lib.php b/lib.php index 97cdb59..eabf781 100644 --- a/lib.php +++ b/lib.php @@ -4,9 +4,6 @@ $attforblock_CONSTANT = 7; /// for example -define('COMMONSESSION', 0); -define('GROUPSESSION', 1); - function attforblock_install() { $result = true; diff --git a/locallib.php b/locallib.php index 742d609..817e1d5 100644 --- a/locallib.php +++ b/locallib.php @@ -5,6 +5,9 @@ require_once($CFG->libdir.'/gradelib.php'); define('ONE_DAY', 86400); // Seconds in one day define('ONE_WEEK', 604800); // Seconds in one week +define('COMMONSESSION', 0); +define('GROUPSESSION', 1); + function show_tabs($cm, $context, $currenttab='sessions') { $toprow = array(); diff --git a/manage.php b/manage.php index 9d78af0..ee37bc2 100644 --- a/manage.php +++ b/manage.php @@ -102,7 +102,7 @@ function print_sessions_list($course) { if($sessdata->lasttaken > 0) //attendance has taken { if ($allowchange) { - $desc = "id&sessionid={$sessdata->id}\">". + $desc = "id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">". ($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')). ''; } else { @@ -112,7 +112,7 @@ function print_sessions_list($course) { $desc = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description; if ($allowtake) { $title = get_string('takeattendance','attforblock'); - $actions = "id&sessionid={$sessdata->id}\">". + $actions = "id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">". "pixpath}/t/go.gif\" alt=\"$title\" /> "; } }