Skip to content

Commit

Permalink
MDL-22033 groupings now enabled unconditionally, groupmembersonly kep…
Browse files Browse the repository at this point in the history
…t as experimental - this simplifies groups code logic a bit, user interface changes should not be significant because the groupings are not visible much until at least one created; hopefully the new description of groupmembersonly will have to preventsome gradebook complaints
  • Loading branch information
skodak committed Apr 7, 2010
1 parent e8c2189 commit 98da602
Show file tree
Hide file tree
Showing 31 changed files with 137 additions and 214 deletions.
1 change: 1 addition & 0 deletions admin/settings/development.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
$temp->add(new admin_setting_configcheckbox('experimentalsplitrestore', get_string('experimentalsplitrestore', 'admin'), get_string('configexperimentalsplitrestore', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0));
$temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('enablegroupmembersonly', get_string('enablegroupmembersonly', 'admin'), get_string('configenablegroupmembersonly', 'admin'), 0));

$ADMIN->add('experimental', $temp);

Expand Down
2 changes: 0 additions & 2 deletions admin/settings/subsystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page

$optionalsubsystems->add(new admin_setting_configcheckbox('enablegroupings', get_string('enablegroupings', 'admin'), get_string('configenablegroupings', 'admin'), 0));

$optionalsubsystems->add(new admin_setting_configcheckbox('enableoutcomes', get_string('enableoutcomes', 'grades'), get_string('configenableoutcomes', 'grades'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('usecomments', get_string('enablecomments', 'admin'), get_string('configenablecomments', 'admin'), 1));

Expand Down
19 changes: 5 additions & 14 deletions backup/restore_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@
}

if (!isset($restore_groups)) {
if (empty($CFG->enablegroupings)) {
$restore_groups = RESTORE_GROUPS_ONLY;
} else {
$restore_groups = RESTORE_GROUPS_GROUPINGS;
}
$restore_groups = RESTORE_GROUPS_GROUPINGS;
}

if (!isset($restore_logs)) {
Expand Down Expand Up @@ -466,15 +462,10 @@
$helplink = $OUTPUT->help_icon('grouprestore', get_string('groups'));
echo '<label for="menurestore_groups">'.get_string ("groups").'</label>'.$helplink;
echo "</b></td><td colspan=\"2\">";
if (empty($CFG->enablegroupings)) {
$group_options[RESTORE_GROUPS_NONE] = get_string('no');
$group_options[RESTORE_GROUPS_ONLY] = get_string('yes');
} else {
$group_options[RESTORE_GROUPS_NONE] = get_string('none');
$group_options[RESTORE_GROUPS_ONLY] = get_string('groupsonly', 'group');
$group_options[RESTORE_GROUPINGS_ONLY] = get_string('groupingsonly', 'group');
$group_options[RESTORE_GROUPS_GROUPINGS] = get_string('groupsgroupings', 'group'); //all.
}
$group_options[RESTORE_GROUPS_NONE] = get_string('none');
$group_options[RESTORE_GROUPS_ONLY] = get_string('groupsonly', 'group');
$group_options[RESTORE_GROUPINGS_ONLY] = get_string('groupingsonly', 'group');
$group_options[RESTORE_GROUPS_GROUPINGS] = get_string('groupsgroupings', 'group'); //all.
echo html_writer::select($group_options, 'restore_groups', $restore_groups, false);
echo "</td></tr>";

Expand Down
10 changes: 4 additions & 6 deletions course/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,10 @@ function definition() {
$mform->setHelpButton('groupmodeforce', array('groupmodeforce', get_string('groupmodeforce')), true);
$mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce);

if (!empty($CFG->enablegroupings)) {
//default groupings selector
$options = array();
$options[0] = get_string('none');
$mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);
}
//default groupings selector
$options = array();
$options[0] = get_string('none');
$mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options);

//--------------------------------------------------------------------------------
$mform->addElement('header','', get_string('availability'));
Expand Down
4 changes: 2 additions & 2 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
if ($accessiblebutdim || !$mod->uservisible) {
echo "</div>";
}
if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!isset($groupings)) {
$groupings = groups_get_all_groupings($course->id);
}
Expand Down Expand Up @@ -1417,7 +1417,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
'<img src="'.$icon.'" class="activityicon" alt="" /> '.
$accesstext.'<span>'.$instancename.$altname.'</span></a>';

if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (!isset($groupings)) {
$groupings = groups_get_all_groupings($course->id);
}
Expand Down
32 changes: 15 additions & 17 deletions course/moodleform_mod.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,26 +375,24 @@ function standard_coursemodule_elements(){
$mform->setHelpButton('groupmode', array('groupmode', get_string('groupmode')));
}

if (!empty($CFG->enablegroupings)) {
if ($this->_features->groupings or $this->_features->groupmembersonly) {
//groupings selector - used for normal grouping mode or also when restricting access with groupmembersonly
$options = array();
$options[0] = get_string('none');
if ($groupings = $DB->get_records('groupings', array('courseid'=>$COURSE->id))) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = format_string($grouping->name);
}
if ($this->_features->groupings or $this->_features->groupmembersonly) {
//groupings selector - used for normal grouping mode or also when restricting access with groupmembersonly
$options = array();
$options[0] = get_string('none');
if ($groupings = $DB->get_records('groupings', array('courseid'=>$COURSE->id))) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = format_string($grouping->name);
}
$mform->addElement('select', 'groupingid', get_string('grouping', 'group'), $options);
$mform->setHelpButton('groupingid', array('grouping', get_string('grouping', 'group')));
$mform->setAdvanced('groupingid');
}
$mform->addElement('select', 'groupingid', get_string('grouping', 'group'), $options);
$mform->setHelpButton('groupingid', array('grouping', get_string('grouping', 'group')));
$mform->setAdvanced('groupingid');
}

if ($this->_features->groupmembersonly) {
$mform->addElement('checkbox', 'groupmembersonly', get_string('groupmembersonly', 'group'));
$mform->setHelpButton('groupmembersonly', array('groupmembersonly', get_string('groupmembersonly', 'group')));
$mform->setAdvanced('groupmembersonly');
}
if ($this->_features->groupmembersonly) {
$mform->addElement('checkbox', 'groupmembersonly', get_string('groupmembersonly', 'group'));
$mform->setHelpButton('groupmembersonly', array('groupmembersonly', get_string('groupmembersonly', 'group')));
$mform->setAdvanced('groupmembersonly');
}

$mform->addElement('modvisible', 'visible', get_string('visible'));
Expand Down
12 changes: 5 additions & 7 deletions course/reset_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ function definition (){
$mform->setAdvanced('reset_groups_members');
$mform->disabledIf('reset_groups_members', 'reset_groups_remove', 'checked');

if (!empty($CFG->enablegroupings)) {
$mform->addElement('checkbox', 'reset_groupings_remove', get_string('deleteallgroupings', 'group'));
$mform->setAdvanced('reset_groupings_remove');
$mform->addElement('checkbox', 'reset_groupings_members', get_string('removegroupingsmembers', 'group'));
$mform->setAdvanced('reset_groupings_members');
$mform->disabledIf('reset_groupings_members', 'reset_groupings_remove', 'checked');
}
$mform->addElement('checkbox', 'reset_groupings_remove', get_string('deleteallgroupings', 'group'));
$mform->setAdvanced('reset_groupings_remove');
$mform->addElement('checkbox', 'reset_groupings_members', get_string('removegroupingsmembers', 'group'));
$mform->setAdvanced('reset_groupings_members');
$mform->disabledIf('reset_groupings_members', 'reset_groupings_remove', 'checked');

$unsupported_mods = array();
if ($allmods = $DB->get_records('modules') ) {
Expand Down
28 changes: 13 additions & 15 deletions group/autogroup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,21 @@ function definition() {
$mform->setDefault('namingscheme', $template);
}

if (!empty($CFG->enablegroupings)) {
$options = array('0' => get_string('no'),
'-1'=> get_string('newgrouping', 'group'));
if ($groupings = groups_get_all_groupings($COURSE->id)) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
}
$mform->addElement('select', 'grouping', get_string('createingrouping', 'group'), $options);
if ($groupings) {
$mform->setDefault('grouping', '-1');
$options = array('0' => get_string('no'),
'-1'=> get_string('newgrouping', 'group'));
if ($groupings = groups_get_all_groupings($COURSE->id)) {
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}

$mform->addElement('text', 'groupingname', get_string('groupingname', 'group'), $options);
$mform->setType('groupingname', PARAM_MULTILANG);
$mform->disabledIf('groupingname', 'grouping', 'noteq', '-1');
}
$mform->addElement('select', 'grouping', get_string('createingrouping', 'group'), $options);
if ($groupings) {
$mform->setDefault('grouping', '-1');
}

$mform->addElement('text', 'groupingname', get_string('groupingname', 'group'), $options);
$mform->setType('groupingname', PARAM_MULTILANG);
$mform->disabledIf('groupingname', 'grouping', 'noteq', '-1');

$mform->addElement('hidden','courseid');
$mform->setType('courseid', PARAM_INT);
Expand Down
85 changes: 33 additions & 52 deletions group/overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,12 @@
$strdescription = get_string('description');

// Get all groupings
if (empty($CFG->enablegroupings)) {
$groupings = array();
$members = array(-1 => array()); //groups not in a grouping
$groupingid = 0;
} else {
$groupings = $DB->get_records('groupings', array('courseid'=>$courseid), 'name');
$members = array();
foreach ($groupings as $grouping) {
$members[$grouping->id] = array();
}
$members[-1] = array(); //groups not in a grouping
$groupings = $DB->get_records('groupings', array('courseid'=>$courseid), 'name');
$members = array();
foreach ($groupings as $grouping) {
$members[$grouping->id] = array();
}
$members[-1] = array(); //groups not in a grouping

// Get all groups
$groups = $DB->get_records('groups', array('courseid'=>$courseid), 'name');
Expand All @@ -71,28 +65,19 @@
$groupwhere = "";
}

if (empty($CFG->enablegroupings)) {
$sql = "SELECT g.id AS groupid, NULL AS groupingid, u.id AS userid, u.firstname, u.lastname, u.idnumber, u.username
FROM {groups} g
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
LEFT JOIN {user} u ON gm.userid = u.id
WHERE g.courseid = :courseid $groupwhere
ORDER BY g.name, u.lastname, u.firstname";
if ($groupingid) {
$groupingwhere = "AND gg.groupingid = :groupingid";
$params['groupingid'] = $groupingid;
} else {
if ($groupingid) {
$groupingwhere = "AND gg.groupingid = :groupingid";
$params['groupingid'] = $groupingid;
} else {
$groupingwhere = "";
}
$sql = "SELECT g.id AS groupid, gg.groupingid, u.id AS userid, u.firstname, u.lastname, u.idnumber, u.username
FROM {groups} g
LEFT JOIN {groupings_groups} gg ON g.id = gg.groupid
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
LEFT JOIN {user} u ON gm.userid = u.id
WHERE g.courseid = :courseid $groupwhere $groupingwhere
ORDER BY g.name, u.lastname, u.firstname";
$groupingwhere = "";
}
$sql = "SELECT g.id AS groupid, gg.groupingid, u.id AS userid, u.firstname, u.lastname, u.idnumber, u.username
FROM {groups} g
LEFT JOIN {groupings_groups} gg ON g.id = gg.groupid
LEFT JOIN {groups_members} gm ON g.id = gm.groupid
LEFT JOIN {user} u ON gm.userid = u.id
WHERE g.courseid = :courseid $groupwhere $groupingwhere
ORDER BY g.name, u.lastname, u.firstname";

if ($rs = $DB->get_recordset_sql($sql, $params)) {
foreach ($rs as $row) {
Expand Down Expand Up @@ -132,18 +117,16 @@

echo $strfiltergroups;

if (!empty($CFG->enablegroupings)) {
$options = array();
$options[0] = get_string('all');
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$popupurl = new moodle_url($rooturl.'&group='.$groupid);
$select = new single_select($popupurl, 'grouping', $options, $groupingid, array());
$select->label = $strgrouping;
$select->formid = 'selectgrouping';
echo $OUTPUT->render($select);
$options = array();
$options[0] = get_string('all');
foreach ($groupings as $grouping) {
$options[$grouping->id] = strip_tags(format_string($grouping->name));
}
$popupurl = new moodle_url($rooturl.'&group='.$groupid);
$select = new single_select($popupurl, 'grouping', $options, $groupingid, array());
$select->label = $strgrouping;
$select->formid = 'selectgrouping';
echo $OUTPUT->render($select);

$options = array();
$options[0] = get_string('all');
Expand Down Expand Up @@ -196,16 +179,14 @@
if ($groupid and empty($table->data)) {
continue;
}
if (!empty($CFG->enablegroupings)) {
if ($gpgid < 0) {
echo $OUTPUT->heading($strnotingrouping, 3);
} else {
echo $OUTPUT->heading(format_string($groupings[$gpgid]->name), 3);
$description = file_rewrite_pluginfile_urls($groupings[$gpgid]->description, 'pluginfile.php', $context->id, 'course_grouping_description', $gpgid);
$options = new stdClass;
$options->noclean = true;
echo $OUTPUT->box(format_text($description, $groupings[$gpgid]->descriptionformat, $options), 'generalbox boxwidthnarrow boxaligncenter');
}
if ($gpgid < 0) {
echo $OUTPUT->heading($strnotingrouping, 3);
} else {
echo $OUTPUT->heading(format_string($groupings[$gpgid]->name), 3);
$description = file_rewrite_pluginfile_urls($groupings[$gpgid]->description, 'pluginfile.php', $context->id, 'course_grouping_description', $gpgid);
$options = new stdClass;
$options->noclean = true;
echo $OUTPUT->box(format_text($description, $groupings[$gpgid]->descriptionformat, $options), 'generalbox boxwidthnarrow boxaligncenter');
}
echo html_writer::table($table);
$printed = true;
Expand Down
8 changes: 3 additions & 5 deletions group/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
$CFG->wwwroot.'/group/index.php?id='.$courseid,
get_string('groups'));

if (!empty($CFG->enablegroupings)) {
$row[] = new tabobject('groupings',
$CFG->wwwroot.'/group/groupings.php?id='.$courseid,
get_string('groupings', 'group'));
}
$row[] = new tabobject('groupings',
$CFG->wwwroot.'/group/groupings.php?id='.$courseid,
get_string('groupings', 'group'));

$row[] = new tabobject('overview',
$CFG->wwwroot.'/group/overview.php?id='.$courseid,
Expand Down
4 changes: 2 additions & 2 deletions lang/en_utf8/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
$string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
$string['configenablecomments'] = 'Enable comments';
$string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.';
$string['configenablegroupings'] = 'This setting enables groupings of groups.';
$string['configenablegroupmembersonly'] = 'This setting enables group members only feature. Please note it is incresing your server load and it is necessary to use some advanced tricks in the gradebook.';
$string['configenablehtmlpurifier'] = 'Use HTML Purifier instead of KSES for cleaning of untrusted text. HTML Purifier is actively developed and is believed to be more secure, but it is more resource intensive. Expect minor visual differences in the resulting html code. Please note that embed and object tags can not be enabled, MathML tags and old lang tags are not supported. ';
$string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site. To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
$string['configenablerssfeedsdisabled'] = 'It is not available because RSS feeds are disabled in all the Site. To enable them, go to the Variables settings under Admin Configuration.';
Expand Down Expand Up @@ -427,7 +427,7 @@
$string['enablecourserequests'] = 'Enable course requests';
$string['enablecomments'] = 'Enable comments';
$string['enableglobalsearch'] = 'Enable global search';
$string['enablegroupings'] = 'Enable groupings';
$string['enablegroupmembersonly'] = 'Enable group members only';
$string['enablehtmlpurifier'] = 'Enable HTML Purifier';
$string['enablerecordcache'] = 'Enable Record Cache';
$string['enablerssfeeds'] = 'Enable RSS feeds';
Expand Down
13 changes: 12 additions & 1 deletion lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3056,7 +3056,7 @@ function xmldb_main_upgrade($oldversion) {
}

if ($result && $oldversion < 2010033101.02) {

/// Define table license to be created
$table = new xmldb_table('license');

Expand Down Expand Up @@ -3435,6 +3435,17 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint($result, 2010033102.09);
}

if ($result && $oldversion < 2010040700) {
// migrate old groupings --> groupmembersonly setting
if (isset($CFG->enablegroupings)) {
set_config('enablegroupmembersonly', $CFG->enablegroupings);
unset_config('enablegroupings');
}

// Main savepoint reached
upgrade_main_savepoint($result, 2010040700);
}

return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected static function validate_context($context) {
throw new invalid_parameter_exception('Invalid activity.');
}
// verify group memebers
if (!empty($CFG->enablegroupings) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (!empty($CFG->enablegroupmembersonly) and $cm and $cm->groupmembersonly and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
if (!groups_has_membership($cm)) {
throw new invalid_parameter_exception('Must be member of at least one group.');
}
Expand Down
Loading

0 comments on commit 98da602

Please sign in to comment.