Note: You are currently viewing documentation for Moodle 2.3. Up-to-date documentation for the latest stable version is available here: Groups.

Development:Groups: Difference between revisions

From MoodleDocs
 
(29 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Improving the Groups design in Moodle 1.9==
{{Moodle 1.9}}
Summary of problems:
==Improved groups/groupings design in Moodle 1.9==
* Can not define groupings at site level
* Groupings not implemented in modules
* Concept of orphaned groups
* Not integrated into Moodle core
* Unfinished and partially broken code
It would be very hard to improve current code without major refactoring and design changes. --[[User:Skodak|Skodak]] 02:37, 10 April 2007 (CDT)


==Competing proposals==
The groups related database structure in 1.9 was reverted to 1.7, groupings are now implemented in a different way than in 1.8. The current design is compatible with 1.7 style groups.
* [[Development:Groupings OU]]
* [[Development:Groupings and Groups]]


==Change groups/groupings relationship==
==Alternative rejected proposals==
At present both groups and groupings may belong to course, you could use one group in several courses and groupings at the same time. This loose relationship of groups and groupings adds too much complexity and is a source of bugs in code.
* [[Obsolete:Groupings OU]]
* [[Obsolete:Groupings and Groups]]


''Solution:'' Each group should be attached to exactly one grouping. The groups would not be shared in groupings anymore, instead groups could be linked using linkid. See attached db schema.
==Changed groups/groupings relationship==
In 1.8 both groups and groupings are not linked strictly to one course, you could use one group in several courses and groupings at the same time. This loose relationship of groups and groupings adds too much complexity and could be/is a source of bugs in code.
 
''Solution:'' Each group and grouping links the course id directly. Groupings are only limiting the number of usable groups in activities. This allows free sharing of groups in groupings inside course without potential problems. This idea was proposed by Enrique. See attached db schema.


[[Image:groupsdb.png]]
[[Image:groupsdb.png]]


Benefits:
===course===
* groupingid - default grouping used in course (new activities, etc.)
 
===course_modules===
* groupingid - grouping used in activity
* groupmembersonly - limit access to and visibility of activity based on group membership - if user is not member of at least one group in grouping, the activity is invisible for them; this needs a new shared option in course/moodleform_mod.php
 
===groupings_groups===
renamed table
 
===groups===
reverted to pre 1.8 state (with the password exception)
 
===Benefits===
*fewer tables
*fewer tables
*normalized
*normalized
*simpler SQL
*simpler SQL
*faster
*easier backup/restore implementation
*much easier backup/restore implementation
*fully compatible with old group implementation in 1.7
 
==Global groups==
Global groups are not implemented in 1.9. They are not going to be implemented at the database level. Instead some other solution should be present in 2.0. This will require patching of enrolment framework and group/lib.php.
 
==Groups API==
Main public API is in lib/grouplib.php, modules should use only these functions.
 
Moodle core may use other functions defined in group/lib.php
 
== See also ==
* [[Development:Groupings and Groups|Enrique Castro group specification]].
* [[Development:Groupings OU|Open University group specification]].
 
 
==New feature ideas==
 
===Student self selection of group from grouping===
To be implemented as normal module.


==Linked groups==
===Linked groups===
TODO
It would allow synchronizing of group membership from different courses; the idea is to have ''linkid'' in groups table and synchronize the groups membership in group functions for adding/removing of members for groups with the same ''linkid''.


==Group/grouping cloning==
===Group/grouping cloning===
TODO
Cloning or duplicating is UI feature only, it helps to prefill new groups/groupings with existing data. In theory it could also copy existing grouping setups from other courses too.


==Enrolment synchronization==
===Context-assigned groups instead of just global groups===
Global groupings can partially replace metacourses in some scenarios. They should support synchronization of enrolments based on group membership. Global groupings should allow:
Groups can reuse context subsystem, so that there can be site, category, course and even activity-level groups, when low-level context can override group membership. This allows for more flexible system (there are common cases in universities, when groups are altered in 1-2 courses), and also for reusing of existing code.
*automatic or manual sync of enrolments – reuse code from metacourses
*setting of default sync role id with possible exception for teachers, tutors, etc.  
*import/export of grouping definitions
*mapping of global groupings during course restore (course groupings always backed/restored)


==Other code cleanup==
Also some modules make use of the teachers, assigned to the groups they taught. There seems to no way that this can be useful with site-wide groups, but context-wide groups can easily retain this functionality.
Current group code does not follow Moodle coding guide, has several unfinished/broken/obsoleted parts, is not integrated into core, etc.
To do:
*integrate setup and upgrade into main lib/db/*.*
*remove columns from groupings table that can be replaced by permissions
*reduce the number of functions, rewrite or fix them, move them into lib/grouplib.php
*split UI in /group/ – global groupings management and course grouping setup
*implement module and course groupings support, fix all mods to use it (course edit form, mod edit form, etc.)
*fix legacy functions
*documentation


==Needed time==
[[Category:Developer]][[Category:Groups]]
1 month for implementation and testing.

Latest revision as of 09:37, 29 November 2010

Template:Moodle 1.9

Improved groups/groupings design in Moodle 1.9

The groups related database structure in 1.9 was reverted to 1.7, groupings are now implemented in a different way than in 1.8. The current design is compatible with 1.7 style groups.

Alternative rejected proposals

Changed groups/groupings relationship

In 1.8 both groups and groupings are not linked strictly to one course, you could use one group in several courses and groupings at the same time. This loose relationship of groups and groupings adds too much complexity and could be/is a source of bugs in code.

Solution: Each group and grouping links the course id directly. Groupings are only limiting the number of usable groups in activities. This allows free sharing of groups in groupings inside course without potential problems. This idea was proposed by Enrique. See attached db schema.

groupsdb.png

course

  • groupingid - default grouping used in course (new activities, etc.)

course_modules

  • groupingid - grouping used in activity
  • groupmembersonly - limit access to and visibility of activity based on group membership - if user is not member of at least one group in grouping, the activity is invisible for them; this needs a new shared option in course/moodleform_mod.php

groupings_groups

renamed table

groups

reverted to pre 1.8 state (with the password exception)

Benefits

  • fewer tables
  • normalized
  • simpler SQL
  • easier backup/restore implementation
  • fully compatible with old group implementation in 1.7

Global groups

Global groups are not implemented in 1.9. They are not going to be implemented at the database level. Instead some other solution should be present in 2.0. This will require patching of enrolment framework and group/lib.php.

Groups API

Main public API is in lib/grouplib.php, modules should use only these functions.

Moodle core may use other functions defined in group/lib.php

See also


New feature ideas

Student self selection of group from grouping

To be implemented as normal module.

Linked groups

It would allow synchronizing of group membership from different courses; the idea is to have linkid in groups table and synchronize the groups membership in group functions for adding/removing of members for groups with the same linkid.

Group/grouping cloning

Cloning or duplicating is UI feature only, it helps to prefill new groups/groupings with existing data. In theory it could also copy existing grouping setups from other courses too.

Context-assigned groups instead of just global groups

Groups can reuse context subsystem, so that there can be site, category, course and even activity-level groups, when low-level context can override group membership. This allows for more flexible system (there are common cases in universities, when groups are altered in 1-2 courses), and also for reusing of existing code.

Also some modules make use of the teachers, assigned to the groups they taught. There seems to no way that this can be useful with site-wide groups, but context-wide groups can easily retain this functionality.