case BLOG_GROUP_LEVEL:
$filtertype = 'group';
- $filterselect = get_and_set_current_group($COURSE, groupmode($COURSE));
+ $filterselect = groups_get_course_group($COURSE);
break;
case BLOG_COURSE_LEVEL:
&& !has_capability('moodle/site:accessallgroups', $context));
//Get the user current group
- $currentgroup = $isseparategroups ? get_and_set_current_group($COURSE, groupmode($COURSE)) : NULL;
+ $currentgroup = $isseparategroups ? groups_get_course_group($COURSE) : NULL;
$groupmembers = "";
$groupselect = "";
if (!has_capability('moodle/blog:view', $coursecontext)) {
error('You do not have the required permissions to view blogs in this course/group');
}
- if (groupmode($course) == SEPARATEGROUPS
+ if (groups_get_course_groupmode($course) == SEPARATEGROUPS
and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
if (!groups_is_member($filterselect)) {
error ('You are not a member of this course group');
$usercourses = array_keys(get_my_courses($targetuserid));
$shared = array_intersect($mycourses, $usercourses);
foreach ($shared as $courseid) {
+ $course = get_record('course', 'id', $courseid);
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
if (has_capability('moodle/site:accessallgroups', $coursecontext)
- or groupmode($courseid) != SEPARATEGROUPS) {
+ or groups_get_course_groupmode($course) != SEPARATEGROUPS) {
return true;
} else {
if ($usergroups = groups_get_all_groups($courseid, $targetuserid)) {
if (!$course = get_record('course', 'id', $courseid)) {
error('Incorrect course ID');
}
- if ($groupmode = groupmode($course)) { // Groups are being used
- $changegroup = optional_param('group', -1, PARAM_INT);
- $groupid = get_and_set_current_group($course, $groupmode, $changegroup);
- } else {
- $groupid = 0;
- }
+
+ $groupid = groups_get_course_group($course);
echo '<h2>'.get_string('eventkind', 'calendar').':</h2>';
echo '<div id="selecteventtype">';
echo '<tr>';
- $groupmode = groupmode($course);
+ $groupmode = groups_get_course_groupmode($course);
if ($groupmode == VISIBLEGROUPS or ($groupmode and has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id)))) {
if ($groups = groups_get_all_groups($course->id)) {
$typestring.$instancename.'</a>';
}
if ($usetracking && $mod->modname == 'forum') {
- $groupmode = groupmode($course, $mod);
+ $groupmode = groups_get_course_groupmode($course, $mod);
$groupid = ($groupmode == SEPARATEGROUPS && !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) ?
- get_current_group($course->id) : false;
+ groups_get_course_group($course, true) : false;
if (forum_tp_can_track_forums() && !isset($untracked[$mod->instance])) {
$unread = forum_tp_count_forum_unread_posts($USER->id, $mod->instance, $groupid);
if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) {
error("This course module doesn't exist");
}
+ $groupmode = groups_get_activity_groupmode($cm);
} else {
$cm = null;
+ $groupmode = groups_get_course_groupmode($course);
}
- $groupmode = groupmode($course, $cm);
if ($course->groupmode or (!$course->groupmodeforce)) {
echo '<tr valign="top">';
echo '<td align="right"><b>'.get_string('groupmode').':</b></td>';
echo '<td align="left">';
- unset($choices);
+ $choices = array();
$choices[NOGROUPS] = get_string('groupsnone');
$choices[SEPARATEGROUPS] = get_string('groupsseparate');
$choices[VISIBLEGROUPS] = get_string('groupsvisible');
$form->section = $cw->section; // The section number itself - relative!!! (section column in course_sections)
$form->visible = $cm->visible; //?? $cw->visible ? $cm->visible : 0; // section hiding overrides
$form->cmidnumber = $cm->idnumber; // The cm IDnumber
- $form->groupmode = groupmode($COURSE,$cm); // locked later if forced
+ $form->groupmode = groups_get_activity_groupmode($cm); // locked later if forced
$form->groupingid = $cm->groupingid;
$form->groupmembersonly = $cm->groupmembersonly;
$form->course = $course->id;
$mod = $mods[$sectionmod];
$instance = get_record("$mod->modname", "id", "$mod->instance");
- $coursemod = get_record_sql("SELECT m.id, m.name, cm.groupmode, cm.visible
+ $coursemod = get_record_sql("SELECT m.id, m.name, cm.groupmode, cm.visible, cm.course, cm.groupingid
FROM {$CFG->prefix}course_modules cm,
{$CFG->prefix}modules m
WHERE course = '$course->id' $hiddenfilter
AND m.id = cm.module $activityfilter
AND cm.id = '$sectionmod'");
-
- $groupmode = groupmode($course, $coursemod);
+ $groupmode = groups_get_activity_groupmode($coursemod);
switch ($groupmode) {
- case SEPARATEGROUPS : $groupid = mygroupid($course->id); break;
+ case SEPARATEGROUPS :
+ $groupid = 0;
+ if ($mygroups = groups_get_all_groups($course->id, $USER->id, $coursemode->groupingid)) {
+ if (array_key_exists($selectedgroup, $mygroups)) {
+ $groupid = $selectedgroup;
+ }
+ }
+ break;
+
case VISIBLEGROUPS : $groupid = $selectedgroup; break;
case NOGROUPS :
default : $groupid = 0;
<?php //$Id$
/**
- * No groups used?
+ * Groups not used in course or activity
*/
define('NOGROUPS', 0);
/**
- * Groups used?
+ * Groups used, users do not see other groups
*/
define('SEPARATEGROUPS', 1);
/**
- * Groups visible?
+ * Groups used, students see other groups
*/
define('VISIBLEGROUPS', 2);
define('DEFAULT_PAGE_SIZE', 20);
define('SHOW_ALL_PAGE_SIZE', 5000);
- $group = optional_param('group', -1, PARAM_INT); // Group to show
$page = optional_param('page', 0, PARAM_INT); // which page to show
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page
$mode = optional_param('mode', NULL); // '0' for less details, '1' for more
/// Check to see if groups are being used in this forum
/// and if so, set $currentgroup to reflect the current group
- $groupmode = groupmode($course); // Groups are being used
- $currentgroup = get_and_set_current_group($course, $groupmode, $group);
+ $groupmode = groups_get_course_groupmode($course); // Groups are being used
+ $currentgroup = groups_get_course_group($course, true);
if (!$currentgroup) { // To make some other functions work better later
$currentgroup = NULL;
}
// Should use this variable so that we don't break stuff every time a variable is added or changed.
- $baseurl = $CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&roleid='.$roleid.'&id='.$course->id.'&group='.$currentgroup.'&perpage='.$perpage.'&accesssince='.$accesssince.'&search='.s($search);
+ $baseurl = $CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&roleid='.$roleid.'&id='.$course->id.'&perpage='.$perpage.'&accesssince='.$accesssince.'&search='.s($search);
/// Print headers
}
echo '<td class="left">';
- setup_and_print_groups($course, $groupmode, $baseurl);
+ groups_print_course_menu($course, $baseurl);
echo '</td>';
// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
echo '</td></tr></table>';
if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) { /// Display info about the group
- if ($group = groups_get_group($currentgroup)) { //TODO:
+ if ($group = groups_get_group($currentgroup)) {
if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) {
echo '<table class="groupinfobox"><tr><td class="left side picture">';
print_group_picture($group, $course->id, true, false, false);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
print_heading(format_string($course->fullname));
- $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$filterselect.'&group=0',
- get_string('participants')); //the groupid hack is necessary, otherwise the group in the session willbe used
+ $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$filterselect,
+ get_string('participants'));
if ($CFG->bloglevel >= 3) {
$toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=course&filterselect='.$filterselect, get_string('blogs','blog'));
**************************************/
} else if ($filtertype == 'group' && $filterselect) {
- $group_name = groups_get_group_name($filterselect); //TODO:
+ $group_name = groups_get_group_name($filterselect);
print_heading($group_name);
if ($CFG->bloglevel >= 2) {
// If groups are in use, make sure we can see that group
- if (groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
+ if (groups_get_course_groupmode($course) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
require_login();
///this is changed because of mygroupid
if ($usergroups = groups_get_all_groups($course->id, $user->id)){
$groupstr = '';
foreach ($usergroups as $group){
- $groupstr .= ' <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&group='.$group->id.'">'.$group->name.'</a>,';
+ $groupstr .= ' <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&group='.$group->id.'">'.format_string($group->name).'</a>,';
}
print_row(get_string("group").":", rtrim($groupstr, ', '));
}