mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-22033 groupings now enabled unconditionally, groupmembersonly kept 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
This commit is contained in:
parent
e8c2189d78
commit
98da60215e
31 changed files with 137 additions and 214 deletions
|
@ -55,23 +55,21 @@ class autogroup_form extends moodleform {
|
|||
$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));
|
||||
}
|
||||
$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');
|
||||
}
|
||||
|
||||
$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);
|
||||
|
|
|
@ -47,18 +47,12 @@ $strnogroups = get_string('nogroups', 'group');
|
|||
$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');
|
||||
|
@ -71,28 +65,19 @@ if ($groupid) {
|
|||
$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) {
|
||||
|
@ -132,18 +117,16 @@ echo $OUTPUT->heading(format_string($course->shortname) .' '.$stroverview, 3);
|
|||
|
||||
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');
|
||||
|
@ -196,16 +179,14 @@ foreach ($members as $gpgid=>$groupdata) {
|
|||
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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue