MDL-9780 Groups 181 cleanup - part 1
This commit is contained in:
@@ -132,7 +132,7 @@ class block_blog_tags extends block_base {
|
||||
|
||||
case BLOG_GROUP_LEVEL:
|
||||
$filtertype = 'group';
|
||||
$filterselect = get_current_group($this->instance->pageid);
|
||||
$filterselect = get_and_set_current_group($COURSE, groupmode($COURSE));
|
||||
break;
|
||||
|
||||
case BLOG_COURSE_LEVEL:
|
||||
|
||||
@@ -29,46 +29,29 @@ class block_news_items extends block_base {
|
||||
$text = '';
|
||||
|
||||
if (!$forum = forum_get_course_forum($COURSE->id, 'news')) {
|
||||
return $this->content;
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
/// First work out whether we can post to this group and if so, include a link
|
||||
$groupmode = groupmode($COURSE, $cm);
|
||||
$currentgroup = get_and_set_current_group($COURSE, $groupmode);
|
||||
|
||||
|
||||
if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $COURSE->id))) { /// Teachers can always post
|
||||
$visiblegroups = -1;
|
||||
|
||||
if (forum_user_can_post_discussion($forum, $currentgroup, $groupmode, $cm, $context)) {
|
||||
$text .= '<div class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
|
||||
get_string('addanewtopic', 'forum').'</a>...</div>';
|
||||
|
||||
} else { /// Check the group situation
|
||||
$currentgroup = get_current_group($COURSE->id);
|
||||
|
||||
if (forum_user_can_post_discussion($forum, $currentgroup)) {
|
||||
$text .= '<div align="center" class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
|
||||
get_string('addanewtopic', 'forum').'</a>...</div>';
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) {
|
||||
$this->content->text = $text;
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$groupmode = groupmode($COURSE, $cm);
|
||||
|
||||
/// Decides if current user is allowed to see ALL the current discussions or not
|
||||
|
||||
if (!$currentgroup and ($groupmode != SEPARATEGROUPS) ) {
|
||||
$visiblegroups = -1;
|
||||
} else {
|
||||
$visiblegroups = $currentgroup;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all the recent discussions we're allowed to see
|
||||
|
||||
if (! $discussions = forum_get_discussions($forum->id, 'p.modified DESC', 0, false,
|
||||
$visiblegroups, $COURSE->newsitems) ) {
|
||||
$currentgroup, $COURSE->newsitems) ) {
|
||||
$text .= '('.get_string('nonews', 'forum').')';
|
||||
$this->content->text = $text;
|
||||
return $this->content;
|
||||
|
||||
@@ -43,7 +43,7 @@ class block_online_users extends block_base {
|
||||
&& !has_capability('moodle/site:accessallgroups', $context));
|
||||
|
||||
//Get the user current group
|
||||
$currentgroup = $isseparategroups ? get_current_group($COURSE->id) : NULL;
|
||||
$currentgroup = $isseparategroups ? get_and_set_current_group($COURSE, groupmode($COURSE)) : NULL;
|
||||
|
||||
$groupmembers = "";
|
||||
$groupselect = "";
|
||||
@@ -51,7 +51,7 @@ class block_online_users extends block_base {
|
||||
//Add this to the SQL to show only group users
|
||||
if ($currentgroup !== NULL) {
|
||||
$groupmembers = ', '.groups_members_from_sql(); //TODO: ", {$CFG->prefix}groups_members gm ";
|
||||
$groupselect .= groups_members_where_sql($currentgroup, 'u.id'); //" AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||
$groupselect = ' AND '.groups_members_where_sql($currentgroup, 'u.id'); //" AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||
}
|
||||
|
||||
if ($COURSE->id == SITEID) { // Site-level
|
||||
|
||||
+2
-6
@@ -22,11 +22,8 @@
|
||||
$stractivityreport = get_string("activityreport");
|
||||
|
||||
/// Check to see if groups are being used in this course
|
||||
if ($groupmode = groupmode($course)) { // Groups are being used
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
|
||||
} else {
|
||||
$currentgroup = false;
|
||||
}
|
||||
$groupmode = groupmode($course);
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
|
||||
|
||||
/// Get a list of all students
|
||||
if ($currentgroup) {
|
||||
@@ -308,7 +305,6 @@
|
||||
$options["download"] = "xls";
|
||||
print_single_button("grades.php", $options, get_string("downloadexcel"));
|
||||
echo "<td>";
|
||||
$options = array();
|
||||
$options["download"] = "txt";
|
||||
print_single_button("grades.php", $options, get_string("downloadtext"));
|
||||
echo "</table>";
|
||||
|
||||
+2
-1
@@ -1418,7 +1418,8 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
|
||||
}
|
||||
|
||||
if ($isediting) {
|
||||
if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource') {
|
||||
// TODO: we must define this as mod property!
|
||||
if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') {
|
||||
if (! $mod->groupmodelink = $groupbuttonslink) {
|
||||
$mod->groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class moodleform_mod extends moodleform {
|
||||
$mform =& $this->_form;
|
||||
$mform->addElement('header', 'modstandardelshdr', get_string('modstandardels', 'form'));
|
||||
if ($supportsgroups){
|
||||
// TODO: we must define this as mod property!
|
||||
$mform->addElement('modgroupmode', 'groupmode', get_string('groupmode'));
|
||||
}
|
||||
$mform->addElement('modvisible', 'visible', get_string('visible'));
|
||||
|
||||
@@ -14,11 +14,13 @@
|
||||
|
||||
require_capability('moodle/course:managegrades', get_context_instance(CONTEXT_MODULE, $id));
|
||||
|
||||
$group = get_current_group($course->id);
|
||||
|
||||
print_header("$course->shortname: ".get_string('grades'), $course->fullname, grade_nav($course, $action));
|
||||
|
||||
grade_preferences_menu($action, $course, $group);
|
||||
$groupmode = groupmode($course);
|
||||
$group = setup_and_print_groups($course, $groupmode, 'exceptions.php?id=' . $course->id);
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
grade_preferences_menu($action, $course);
|
||||
|
||||
grade_set_uncategorized();
|
||||
|
||||
|
||||
+6
-31
@@ -5,7 +5,6 @@
|
||||
$id = required_param('id'); // course id
|
||||
$download = optional_param('download');
|
||||
$user = optional_param('user', -1);
|
||||
$group = optional_param('group', -1);
|
||||
$action = optional_param('action', 'grades');
|
||||
$cview = optional_param('cview', -1);
|
||||
|
||||
@@ -14,15 +13,7 @@
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
/*
|
||||
if (has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
$group = get_and_set_current_group($course, $course->groupmode, $group);
|
||||
} else {
|
||||
$group = get_current_group($course->id);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// if the user set new prefs make sure they happen now
|
||||
if ($action == 'set_grade_preferences' && $prefs = data_submitted()) {
|
||||
if (!confirm_sesskey()) {
|
||||
@@ -50,29 +41,13 @@
|
||||
}
|
||||
|
||||
print_header($course->shortname.': '.get_string('grades'), $course->fullname, grade_nav($course, $action));
|
||||
|
||||
grade_preferences_menu($action, $course, $group);
|
||||
|
||||
/// copied code from assignment module, if this is not the way to do this please change it
|
||||
/// the above code does not work
|
||||
/// set_and_print_groups() is not fully implemented as function groups_instance_print_grouping_selector()
|
||||
/// and function groups_instance_print_group_selector() are missing.
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$changegroup = optional_param('group', -1, PARAM_INT); // choose the current group
|
||||
/// find out current groups mode
|
||||
$groupmode = groupmode($course);
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
|
||||
|
||||
/// Now we need a menu for separategroups as well!
|
||||
if ($groupmode == VISIBLEGROUPS || ($groupmode
|
||||
&& has_capability('moodle/site:accessallgroups', $context))) {
|
||||
|
||||
//the following query really needs to change
|
||||
if ($groups = groups_get_groups_names($course->id)) { //TODO:
|
||||
print_box_start('groupmenu');
|
||||
print_group_menu($groups, $groupmode, $currentgroup, 'index.php?id='.$course->id);
|
||||
print_box_end(); // groupmenu
|
||||
}
|
||||
}
|
||||
$currentgroup = setup_and_print_groups($course, $groupmode, 'index.php?id=' . $course->id);
|
||||
echo '<div class="clearer"></div>';
|
||||
|
||||
grade_preferences_menu($action, $course);
|
||||
|
||||
grade_set_uncategorized();
|
||||
|
||||
|
||||
+21
-37
@@ -311,12 +311,9 @@ function grade_get_formatted_grades() {
|
||||
}
|
||||
|
||||
|
||||
if (isset($_REQUEST['group'])) {
|
||||
$group = clean_param($_REQUEST['group'], PARAM_INT);
|
||||
}
|
||||
// if the user has selected a group to view by get the group members
|
||||
if (isset($group) && $group != 0) {
|
||||
$groupmembers = get_group_users($group);
|
||||
if ($currentgroup = get_current_group($course->id)) {
|
||||
$groupmembers = get_group_users($currentgroup);
|
||||
}
|
||||
|
||||
// this next block catches any students who do not have a grade for any item in a particular category
|
||||
@@ -1064,7 +1061,7 @@ function grade_set_preferences($course, $newprefs) {
|
||||
}
|
||||
|
||||
|
||||
function grade_preferences_menu($action, $course, $group=0) {
|
||||
function grade_preferences_menu($action, $course) {
|
||||
|
||||
if (!has_capability('moodle/course:managegrades', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
return;
|
||||
@@ -1206,17 +1203,7 @@ function grade_download($download, $id) {
|
||||
$stractivityreport = get_string("activityreport");
|
||||
|
||||
/// Check to see if groups are being used in this course
|
||||
if ($groupmode = groupmode($course)) { // Groups are being used
|
||||
if (isset($_GET['group'])) {
|
||||
$changegroup = $_GET['group']; /// 0 or higher
|
||||
} else {
|
||||
$changegroup = -1; /// This means no group change was specified
|
||||
}
|
||||
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
|
||||
} else {
|
||||
$currentgroup = false;
|
||||
}
|
||||
$currentgroup = get_current_group($course->id);
|
||||
|
||||
if ($currentgroup) {
|
||||
$students = get_group_students($currentgroup, "u.lastname ASC");
|
||||
@@ -1741,7 +1728,6 @@ function grade_view_category_grades($view_by_student) {
|
||||
global $course;
|
||||
global $USER;
|
||||
global $preferences;
|
||||
global $group;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
@@ -1783,11 +1769,11 @@ function grade_view_category_grades($view_by_student) {
|
||||
$student_heading_link = get_string('student','grades');
|
||||
//only set sorting links if more than one student displayed.
|
||||
if ($view_by_student == -1) {
|
||||
$student_heading_link .='<br /><a href="?id='.$course->id.'&group='.$group.'&action=vcats&cview='.$cview.'&sort=lastname">'.get_string('sortbylastname','grades').'</a>';
|
||||
$student_heading_link .= '<br /><a href="?id='.$course->id.'&group='.$group.'&action=vcats&cview='.$cview.'&sort=firstname">'.get_string('sortbyfirstname','grades').'</a>';
|
||||
$student_heading_link .='<br /><a href="?id='.$course->id.'&action=vcats&cview='.$cview.'&sort=lastname">'.get_string('sortbylastname','grades').'</a>';
|
||||
$student_heading_link .= '<br /><a href="?id='.$course->id.'&action=vcats&cview='.$cview.'&sort=firstname">'.get_string('sortbyfirstname','grades').'</a>';
|
||||
}
|
||||
else {
|
||||
$student_heading_link .= '<br /><a href="?id='.$course->id.'&group='.$group.'&action=vcats&cview='.$cview.'">'.get_string('showallstudents','grades').'</a>';
|
||||
$student_heading_link .= '<br /><a href="?id='.$course->id.'&action=vcats&cview='.$cview.'">'.get_string('showallstudents','grades').'</a>';
|
||||
}
|
||||
}
|
||||
echo '<table align="center" class="grades">';
|
||||
@@ -1848,7 +1834,7 @@ function grade_view_category_grades($view_by_student) {
|
||||
$student_link = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$student.'&course='.$course->id.'">';
|
||||
}
|
||||
else {
|
||||
$student_link = '<a href="?id='.$course->id.'&group='.$group.'&action=vcats&user='.$student.'&cview='.$cview.'">';
|
||||
$student_link = '<a href="?id='.$course->id.'&action=vcats&user='.$student.'&cview='.$cview.'">';
|
||||
}
|
||||
$student_link .= $grades_by_student[$student]['student_data']['lastname'].', '.$grades_by_student[$student]['student_data']['firstname'].'</a>';
|
||||
$row .= '<th class="fullname" scope="row">'.$student_link.'</th>';
|
||||
@@ -1933,14 +1919,14 @@ function grade_view_category_grades($view_by_student) {
|
||||
|
||||
if ($first == 0) {
|
||||
if (has_capability('moodle/course:viewcoursegrades', $context) && $view_by_student == -1) {
|
||||
$total_sort_link = '<a href="?id='.$course->id.'&group='.$group.'&action=vcats&cview='.$cview.'&sort=highgrade_category"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('highgradedescending','grades').'" /></a>';
|
||||
$total_sort_link .= '<a href="?id='.$course->id.'&group='.$group.'&action=vcats&cview='.$cview.'&sort=highgrade_category_asc"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('highgradeascending','grades').'" /></a>';
|
||||
$total_sort_link = '<a href="?id='.$course->id.'&action=vcats&cview='.$cview.'&sort=highgrade_category"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('highgradedescending','grades').'" /></a>';
|
||||
$total_sort_link .= '<a href="?id='.$course->id.'&action=vcats&cview='.$cview.'&sort=highgrade_category_asc"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('highgradeascending','grades').'" /></a>';
|
||||
}
|
||||
else {
|
||||
$total_sort_link = '';
|
||||
}
|
||||
|
||||
$stats_link = '<a href="javascript:void(0)" onclick="window.open(\'?id='.$course->id.'&action=stats&group='.$group.'&category='.$cview.'\',\''.get_string('statslink','grades').'\',\'height=200,width=300,scrollbars=no\')">'.get_string('statslink','grades').'</a>';
|
||||
$stats_link = '<a href="javascript:void(0)" onclick="window.open(\'?id='.$course->id.'&action=stats&category='.$cview.'\',\''.get_string('statslink','grades').'\',\'height=200,width=300,scrollbars=no\')">'.get_string('statslink','grades').'</a>';
|
||||
if ($all_categories[$cview]['stats']['drop'] != 0) {
|
||||
$header .= '<th class="'.$class.'" colspan="'.$grade_columns.'" scope="col">'.get_string('total','grades').' (Lowest '. $all_categories[$cview]['stats']['drop']. ' Dropped)'.$total_sort_link.' '.$stats_link.'</th>';
|
||||
}
|
||||
@@ -2039,7 +2025,6 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a
|
||||
global $CFG;
|
||||
global $course;
|
||||
global $USER;
|
||||
global $group; // yu: fix for 5814
|
||||
global $preferences;
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_COURSE, $course->id)) {
|
||||
@@ -2078,8 +2063,8 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a
|
||||
if (has_capability('moodle/course:viewcoursegrades', $context)) {
|
||||
$student_heading_link = get_string('student','grades');
|
||||
if ($view_by_student == -1) {
|
||||
$student_heading_link .='<a href="?id='.$course->id.'&action=grades&sort=lastname&group='.$group.'"><br /><font size="-2">'.get_string('sortbylastname','grades').'</font></a>';
|
||||
$student_heading_link .= '<a href="?id='.$course->id.'&action=grades&sort=firstname&group='.$group.'"><br /><font size="-2">'.get_string('sortbyfirstname','grades').'</font></a>';
|
||||
$student_heading_link .='<a href="?id='.$course->id.'&action=grades&sort=lastname"><br /><font size="-2">'.get_string('sortbylastname','grades').'</font></a>';
|
||||
$student_heading_link .= '<a href="?id='.$course->id.'&action=grades&sort=firstname"><br /><font size="-2">'.get_string('sortbyfirstname','grades').'</font></a>';
|
||||
}
|
||||
else {
|
||||
$student_heading_link .= '<br /><a href="?id='.$course->id.'&&action=grades"><font size="-2">'.get_string('showallstudents','grades').'</font></a>';
|
||||
@@ -2184,14 +2169,14 @@ function grade_view_all_grades($view_by_student) { // if mode=='grade' then we a
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:viewcoursegrades', $context) && $view_by_student == -1) {
|
||||
$grade_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=highgrade&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('highgradedescending','grades').'" /></a>';
|
||||
$grade_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=highgrade_asc&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('highgradeascending','grades').'" /></a>';
|
||||
$points_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=points&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('pointsdescending','grades').'" /></a>';
|
||||
$points_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=points_asc&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('pointsascending','grades').'" /></a>';
|
||||
$weighted_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=weighted&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('weighteddescending','grades').'" /></a>';
|
||||
$weighted_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=weighted_asc&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('weightedascending','grades').'" /></a>';
|
||||
$percent_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=percent&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('percentdescending','grades').'" /></a>';
|
||||
$percent_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=percent_asc&group='.$group.'"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('percentascending','grades').'" /></a>';
|
||||
$grade_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=highgrade"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('highgradedescending','grades').'" /></a>';
|
||||
$grade_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=highgrade_asc"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('highgradeascending','grades').'" /></a>';
|
||||
$points_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=points"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('pointsdescending','grades').'" /></a>';
|
||||
$points_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=points_asc"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('pointsascending','grades').'" /></a>';
|
||||
$weighted_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=weighted"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('weighteddescending','grades').'" /></a>';
|
||||
$weighted_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=weighted_asc"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('weightedascending','grades').'" /></a>';
|
||||
$percent_sort_link = '<a href="?id='.$course->id.'&action=grades&sort=percent"><img src="'.$CFG->wwwroot.'/pix/t/down.gif" alt="'.get_string('percentdescending','grades').'" /></a>';
|
||||
$percent_sort_link .= '<a href="?id='.$course->id.'&action=grades&sort=percent_asc"><img src="'.$CFG->wwwroot.'/pix/t/up.gif" alt="'.get_string('percentascending','grades').'" /></a>';
|
||||
}
|
||||
$stats_link = '<a href="javascript:void(0)" onclick="window.open(\'?id='.$course->id.'&action=stats&category=all\',\''.get_string('statslink','grades').'\',\'height=200,width=300,scrollbars=no\')"><font size="-2">'.get_string('statslink','grades').'</font></a>';
|
||||
$header .= '<th colspan="'.$total_columns.'" scope="col">'.get_string('total','grades').' '.$stats_link.'</th>';
|
||||
@@ -3010,7 +2995,6 @@ function grade_download_form($type='both') {
|
||||
$url .= '&cview='.$cview;
|
||||
}
|
||||
}
|
||||
setup_and_print_groups($course, $course->groupmode, $url);
|
||||
echo '</td>';
|
||||
|
||||
echo '</tr></table>';
|
||||
|
||||
+22
-2
@@ -16,12 +16,17 @@ require_once('lib.php');
|
||||
require_once('edit_form.php');
|
||||
|
||||
/// get url variables
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$id = optional_param('id', false, PARAM_INT);
|
||||
$groupingid = optional_param('grouping', false, PARAM_INT);
|
||||
$newgrouping = optional_param('newgrouping', false, PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$delete = optional_param('delete', 0, PARAM_BOOL);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$delete = optional_param('delete', false, PARAM_BOOL);
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPINGS YET!
|
||||
$groupingid = GROUP_NOT_IN_GROUPING;
|
||||
}
|
||||
|
||||
/// Course must be valid
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
@@ -33,6 +38,18 @@ if ($delete && !$id) {
|
||||
error(get_string('errorinvalidgroup'));
|
||||
}
|
||||
|
||||
if ($delete && !$confirm) {
|
||||
print_header(get_string('deleteselectedgroup', 'group'), get_string('deleteselectedgroup', 'group'));
|
||||
$optionsyes = array('id'=>$id, 'delete'=>1, 'courseid'=>$courseid, 'sesskey'=>sesskey(), 'confirm'=>1);
|
||||
$optionsno = array('id'=>$courseid);
|
||||
if (!$group = get_record('groups', 'id', $id)) {
|
||||
error('Group ID was incorrect');
|
||||
}
|
||||
notice_yesno(get_string('deletegroupconfirm', 'group', $group->name), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
|
||||
print_footer();
|
||||
die;
|
||||
}
|
||||
|
||||
/// basic access control checks
|
||||
if ($id) {
|
||||
if (!$group = get_record('groups', 'id', $id)) {
|
||||
@@ -62,6 +79,9 @@ if (!empty($group)) {
|
||||
|
||||
// Process delete action
|
||||
if ($delete) {
|
||||
if (!confirm_sesskey()) {
|
||||
error('Sesskey error');
|
||||
}
|
||||
if (groups_delete_group($id)) {
|
||||
redirect(groups_home_url($course->id, null, $groupingid, false));
|
||||
} else {
|
||||
|
||||
+8
-3
@@ -47,12 +47,16 @@ class group_edit_form extends moodleform {
|
||||
$mform->setHelpButton('imagefile', array ('picture', get_string('helppicture')), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($group) {
|
||||
$buttonstr = get_string('save', 'group');
|
||||
$mform->addElement('hidden','id', null);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPINGS YET!
|
||||
$mform->addElement('hidden', 'newgrouping', GROUP_NOT_IN_GROUPING);
|
||||
$mform->setType('newgrouping', PARAM_INT);
|
||||
} else {
|
||||
// Options to move group to another grouping
|
||||
$groupingids = groups_get_groupings($courseid);
|
||||
|
||||
@@ -67,8 +71,9 @@ class group_edit_form extends moodleform {
|
||||
$mform->addElement('select', 'newgrouping', get_string('addgroupstogrouping', 'group'), $listgroupings);
|
||||
$mform->setDefault('newgrouping', $groupingid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($groupingid) {
|
||||
$mform->addElement('hidden', 'grouping', $groupingid);
|
||||
$mform->setType('grouping', PARAM_INT);
|
||||
|
||||
@@ -18,6 +18,11 @@ $id = optional_param('id', false, PARAM_INT);
|
||||
|
||||
$delete = optional_param('delete', false, PARAM_BOOL);
|
||||
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPIGS YET!
|
||||
error('No groupings yet');
|
||||
}
|
||||
|
||||
// Get the course information so we can print the header and
|
||||
// check the course id is valid
|
||||
$course = groups_get_course_info($courseid);
|
||||
|
||||
+30
-5
@@ -27,6 +27,11 @@ $groupid = optional_param('group', false, PARAM_INT);
|
||||
$userid = optional_param('user', false, PARAM_INT);
|
||||
$action = groups_param_action();
|
||||
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPINGS YET!
|
||||
$groupingid = GROUP_NOT_IN_GROUPING;
|
||||
}
|
||||
|
||||
if ($groupid) {
|
||||
$groupingsforgroup = groups_get_groupings_for_group($groupid);
|
||||
if ($groupingsforgroup) {
|
||||
@@ -100,7 +105,7 @@ if ($success) {
|
||||
redirect(groups_grouping_edit_url($courseid, null, false));
|
||||
break;
|
||||
case 'printerfriendly':
|
||||
redirect('groupui/printgrouping.php?courseid='. $courseid .'&groupingid='. $groupingid);
|
||||
redirect('printgrouping.php?courseid='. $courseid .'&groupingid='. $groupingid);
|
||||
break;
|
||||
|
||||
case 'showgroupsettingsform':
|
||||
@@ -201,6 +206,11 @@ if ($success) {
|
||||
*/
|
||||
echo '<table cellpadding="6" class="generaltable generalbox groupmanagementtable boxaligncenter" summary="">'."\n";
|
||||
echo '<tr>'."\n";
|
||||
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPIGS YET!
|
||||
$sel_groupingid = -1;
|
||||
} else {
|
||||
echo '<td class="generalboxcontent">'."\n";
|
||||
echo '<p><label for="groupings">' . get_string('groupings', 'group') . '<span id="dummygrouping"> </span></label></p>'."\n";
|
||||
echo '<select name="grouping" id="groupings" size="15" class="select"';
|
||||
@@ -265,8 +275,15 @@ if ($success) {
|
||||
|
||||
echo '<p><input type="submit" ' . $printerfriendly_disabled . ' name="act_printerfriendly" id="printerfriendly" value="'
|
||||
. get_string('printerfriendly', 'group') . '" /></p>'."\n";
|
||||
echo "</td>\n<td>\n";
|
||||
echo "</td>\n";
|
||||
}
|
||||
echo "<td>\n";
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPINGS YET!
|
||||
echo '<p><label for="groups"><span id="groupslabel">'.get_string('groups').':</span><span id="thegrouping"> </span></label></p>'."\n";
|
||||
} else {
|
||||
echo '<p><label for="groups"><span id="groupslabel">'.get_string('groupsinselectedgrouping', 'group').' </span><span id="thegrouping">'.get_string('grouping', 'group').'</span></label></p>'."\n";
|
||||
}
|
||||
echo '<select name="group" id="groups" size="15" class="select" onchange="membersCombo.refreshMembers(this.options[this.selectedIndex].value);"'."\n";
|
||||
echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";
|
||||
|
||||
@@ -307,7 +324,14 @@ if ($success) {
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_removegroup" '
|
||||
. 'id="removegroup" value="' . get_string('removegroupfromselectedgrouping', 'group') . '" /></p>'."\n";
|
||||
}
|
||||
|
||||
|
||||
if (empty($CFG->enablegroupings)) {
|
||||
// NO GROUPIGS YET!
|
||||
echo '<p><input type="submit" name="act_showcreateorphangroupform" id="showcreateorphangroupform" value="'
|
||||
. get_string('creategroup', 'group') . '" /></p>'."\n";
|
||||
echo '<p><input type="submit" name="act_printerfriendly" id="printerfriendly" value="'
|
||||
. get_string('printerfriendly', 'group') . '" /></p>'."\n";
|
||||
} else {
|
||||
echo '<p><input type="submit" ' . $showcreategroupform_disabled . ' name="act_showcreategroupform" id="showcreategroupform" value="'
|
||||
. get_string('creategroupinselectedgrouping', 'group') . '" /></p>'."\n";
|
||||
|
||||
@@ -318,10 +342,11 @@ if ($success) {
|
||||
echo '<p><input type="submit" '.$disabled.' name="act_addgroupstogroupingform" '
|
||||
. 'id="showaddgroupstogroupingform" value="' . get_string('addgroupstogrouping', 'group') . '" /></p>'."\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</td>'."\n";
|
||||
echo '<td>'."\n";
|
||||
echo '<p><label for="members"><span id="memberslabel">'.get_string('membersofselectedgroup', 'group').' </span><span id="thegroup">'.get_string('group', 'group').'</span></label></p>'."\n";
|
||||
echo '<p><label for="members"><span id="memberslabel">'.get_string('membersofselectedgroup', 'group').' </span><span id="thegroup"> </span></label></p>'."\n";
|
||||
//NOTE: the SELECT was, multiple="multiple" name="user[]" - not used and breaks onclick.
|
||||
echo '<select name="user" id="members" size="15" class="select"'."\n";
|
||||
echo ' onclick="window.status=this.options[this.selectedIndex].title;" onmouseout="window.status=\'\';">'."\n";
|
||||
|
||||
+55
-31
@@ -201,25 +201,29 @@ function set_current_group($courseid, $groupid) {
|
||||
function get_current_group($courseid, $full = false) {
|
||||
global $SESSION;
|
||||
|
||||
if (isset($SESSION->currentgroup[$courseid])) {
|
||||
if ($full) {
|
||||
return groups_get_group($SESSION->currentgroup[$courseid], false);
|
||||
} else {
|
||||
return $SESSION->currentgroup[$courseid];
|
||||
}
|
||||
}
|
||||
|
||||
$mygroupid = mygroupid($courseid);
|
||||
if (is_array($mygroupid)) {
|
||||
$mygroupid = array_shift($mygroupid);
|
||||
}
|
||||
|
||||
if (isset($SESSION->currentgroup[$courseid])) {
|
||||
$currentgroup = $SESSION->currentgroup[$courseid];
|
||||
} else {
|
||||
$currentgroup = $mygroupid;
|
||||
}
|
||||
|
||||
if ($currentgroup) {
|
||||
$SESSION->currentgroup[$courseid] = $mygroupid;
|
||||
set_current_group($courseid, $mygroupid);
|
||||
if ($full) {
|
||||
return groups_get_group($mygroupid, false);
|
||||
} else {
|
||||
return $mygroupid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($full) {
|
||||
return groups_groupid_to_group($currentgroup);
|
||||
return false;
|
||||
} else {
|
||||
return $currentgroup;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,12 +269,11 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) {
|
||||
/*)}else {
|
||||
$currentgroupid = $group->id;*/
|
||||
} elseif ($groupmode == SEPARATEGROUPS) { // student in separate groups switching
|
||||
if (ismember($group->id)) { //check if is a member
|
||||
if (ismember($groupid)) { //check if is a member
|
||||
$currentgroupid = set_current_group($course->id, $groupid); //might need to set_current_group?
|
||||
}
|
||||
else {
|
||||
echo($group->id);
|
||||
notify('You do not belong to this group!', 'error');
|
||||
notify('You do not belong to this group! ('.$groupid.')', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,8 +283,8 @@ function get_and_set_current_group($course, $groupmode, $groupid=-1) {
|
||||
if (has_capability('moodle/site:accessallgroups', $context)) { // Sets current default group
|
||||
$currentgroupid = set_current_group($course->id, 0);
|
||||
|
||||
} elseif ($groupmode == VISIBLEGROUPS) { // All groups are visible
|
||||
$currentgroupid = 0;
|
||||
} else if ($groupmode == VISIBLEGROUPS) { // All groups are visible
|
||||
$currentgroupid = set_current_group($course->id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,24 +320,45 @@ function setup_and_print_groups($course, $groupmode, $urlroot) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS
|
||||
or ($groupmode and has_capability('moodle/site:accessallgroups', $context))) {
|
||||
groups_instance_print_grouping_selector();
|
||||
}//added code here to allow non-editting teacher to swap in-between his own groups
|
||||
//added code for students in separategrous to swtich groups
|
||||
else if ($groupmode == SEPARATEGROUPS and has_capability('moodle/course:view', $context)) {
|
||||
groups_instance_print_group_selector();
|
||||
if ($groupmode == SEPARATEGROUPS and !$currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
|
||||
//we are in separate groups and the current group is group 0, as last set.
|
||||
//this can mean that either, this guy has no group
|
||||
//or, this guy just came from a visible all forum, and he left when he set his current group to 0 (show all)
|
||||
|
||||
if ($usergroups = user_group($course->id, $USER->id)){
|
||||
//for the second situation, we need to perform the trick and get him a group.
|
||||
$first = reset($usergroups);
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $first->id);
|
||||
|
||||
} else {
|
||||
//else he has no group in this course
|
||||
print_heading(get_string('notingroup'));
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS or ($groupmode and has_capability('moodle/site:accessallgroups', $context))) {
|
||||
|
||||
if ($groups = get_groups($course->id)) {
|
||||
|
||||
echo '<div class="groupselector">';
|
||||
print_group_menu($groups, $groupmode, $currentgroup, $urlroot, 1);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
} else if ($groupmode == SEPARATEGROUPS and has_capability('moodle/course:view', $context)) {
|
||||
//get all the groups this guy is in in this course
|
||||
if ($usergroups = user_group($course->id, $USER->id)){
|
||||
echo '<div class="groupselector">';
|
||||
//print them in the menu
|
||||
print_group_menu($usergroups, $groupmode, $currentgroup, $urlroot, 0);
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $currentgroup;
|
||||
}
|
||||
|
||||
|
||||
function groups_instance_print_grouping_selector() {
|
||||
//TODO: ??
|
||||
}
|
||||
function groups_instance_print_group_selector() {
|
||||
//TODO: ??
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -420,7 +420,7 @@ function groups_m_get_current($cm, $full=false) {
|
||||
$SESSION->currentgroupinggroup[$cm->course][$cm->groupingid] = $currentgroup;
|
||||
}
|
||||
if ($full) {
|
||||
return groups_groupid_to_group($currentgroup);
|
||||
return groups_get_group($currentgroup, false);
|
||||
} else {
|
||||
return $currentgroup;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Print groups in groupings, and members of groups.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author J.White AT open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package groups
|
||||
*/
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
$success = true;
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
|
||||
// Get the course information so we can print the header and
|
||||
// check the course id is valid
|
||||
$course = groups_get_course_info($courseid);
|
||||
if (! $course) {
|
||||
$success = false;
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
|
||||
|
||||
if ($success) {
|
||||
// Make sure that the user has permissions to manage groups.
|
||||
require_login($courseid);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
if (! has_capability('moodle/course:managegroups', $context)) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
//( confirm_sesskey checks that this is a POST request.)
|
||||
|
||||
// Print the page and form
|
||||
$strgroups = get_string('groups');
|
||||
$strparticipants = get_string('participants');
|
||||
print_header("$course->shortname: $strgroups", $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
|
||||
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
|
||||
"-> <a href=\"$CFG->wwwroot/group/index.php?id=$courseid\">$strgroups</a>".
|
||||
"-> ".get_string('printerfriendly', 'group'), "", "", true, '', user_login_string($course, $USER));
|
||||
|
||||
$groupingname = groups_get_grouping_name($groupingid);
|
||||
if (! $groupingname) {
|
||||
print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
|
||||
} else {
|
||||
// Print the name of the grouping
|
||||
if (!empty($CFG->enablegroupings)) {
|
||||
// NO GROUPINGS YET!
|
||||
echo "<h1>$groupingname</h1>\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Get the groups and group members for the grouping.
|
||||
if (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
$groupids = groups_get_groups_not_in_any_grouping($courseid);
|
||||
} else {
|
||||
$groupids = groups_get_groups_in_grouping($groupingid);
|
||||
}
|
||||
|
||||
if ($groupids) {
|
||||
// Make sure the groups are in the right order
|
||||
$group_names = groups_groupids_to_group_names($groupids);
|
||||
|
||||
// Go through each group in turn and print the group name and then the members
|
||||
foreach ($group_names as $group) {
|
||||
|
||||
echo "<h2>{$group->name}</h2>\n";
|
||||
$userids = groups_get_members($group->id);
|
||||
if ($userids != false) {
|
||||
// Make sure the users are in the right order
|
||||
$user_names = groups_userids_to_user_names($userids, $courseid);
|
||||
|
||||
echo "<ol>\n";
|
||||
foreach ($user_names as $user) {
|
||||
|
||||
echo "<li>{$user->name}</li>\n";
|
||||
}
|
||||
echo "</ol>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
}
|
||||
|
||||
?>
|
||||
+12
-5
@@ -4295,21 +4295,28 @@ function update_groups_button($courseid) {
|
||||
function print_group_menu($groups, $groupmode, $currentgroup, $urlroot, $showall=1, $return=false) {
|
||||
|
||||
$output = '';
|
||||
$groupsmenu = array();
|
||||
|
||||
/// Add an "All groups" to the start of the menu
|
||||
if ($showall){
|
||||
$groupsmenu[0] = get_string('allparticipants');
|
||||
}
|
||||
foreach ($groups as $key => $groupname) {
|
||||
$groupsmenu[$key] = $groupname;
|
||||
foreach ($groups as $key => $group) {
|
||||
$groupsmenu[$key] = format_string($group->name);
|
||||
}
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS) {
|
||||
$grouplabel = get_string('groupsvisible').':';
|
||||
$grouplabel = get_string('groupsvisible');
|
||||
} else {
|
||||
$grouplabel = get_string('groupsseparate').':';
|
||||
$grouplabel = get_string('groupsseparate');
|
||||
}
|
||||
|
||||
if (count($groupsmenu) == 1) {
|
||||
$groupname = reset($groupsmenu);
|
||||
$output .= $grouplabel.': '.$groupname;
|
||||
} else {
|
||||
$output .= popup_form($urlroot.'&group=', $groupsmenu, 'selectgroup', $currentgroup, '', '', '', true, 'self', $grouplabel);
|
||||
}
|
||||
$output .= popup_form($urlroot.'&group=', $groupsmenu, 'selectgroup', $currentgroup, '', '', '', true, 'self', $grouplabel);
|
||||
|
||||
if ($return) {
|
||||
return $output;
|
||||
|
||||
@@ -120,6 +120,12 @@ img.grouppicture {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.groupselector {
|
||||
float: left;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
#addmembersform table {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
@@ -2632,6 +2638,13 @@ body#user-index .rolesform {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#mod-chat-view #enterlink {
|
||||
text-align: center;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.chat-event .picture,
|
||||
.chat-message .picture {
|
||||
width:40px;
|
||||
|
||||
+3
-7
@@ -192,13 +192,9 @@
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS or ($groupmode and has_capability('moodle/site:accessallgroups', $context))) {
|
||||
if ($groups_names = groups_get_groups_names($course->id)) { //TODO:
|
||||
echo '<td class="left">';
|
||||
print_group_menu($groups_names, $groupmode, $currentgroup, $baseurl);
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
echo '<td class="left">';
|
||||
setup_and_print_groups($course, $groupmode, $baseurl);
|
||||
echo '</td>';
|
||||
|
||||
// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
|
||||
// this might not work anymore because you always going to get yourself as the most recent entry? added $USER!=$user ch
|
||||
|
||||
Reference in New Issue
Block a user