Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      This patch affects following areas:

      • anything cohort sync enrolment plugin related
      • restore of group membership
      • restore of role assignments
      • restore of enrolments
      • group protection in enrolment UI (see MDL-31973)

      Test:

      • run phpunit tests in all supported databases
      • test all operation related to enrol_chort sync - add instances, change cohort memberships, delete cohorts, edit cohort sync insatcnes, delete use group, roles, etc.
      • test restore of course with cohort sync on the same site - exact restore expected
      • test restore on different site - restore as forced manual enrolments
      Show
      This patch affects following areas: anything cohort sync enrolment plugin related restore of group membership restore of role assignments restore of enrolments group protection in enrolment UI (see MDL-31973 ) Test: run phpunit tests in all supported databases test all operation related to enrol_chort sync - add instances, change cohort memberships, delete cohorts, edit cohort sync insatcnes, delete use group, roles, etc. test restore of course with cohort sync on the same site - exact restore expected test restore on different site - restore as forced manual enrolments
    • Workaround:
      Hide

      In MDL-22927 a solution statement was proposed, but i agree with Petr that this improvement would need a new column in the group table of the DB.

      Show
      In MDL-22927 a solution statement was proposed, but i agree with Petr that this improvement would need a new column in the group table of the DB.
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      w40_MDL-31437_m24_cohortsync
    • Rank:
      37963

      Description

      The discussion started in MDL-22927, but there is a need to put this in an seperate issue.
      In our Moodle installation we've configured a large set of cohorts corresponding to age-group of students. These cohorts are associated with course-groups to control access within courses. I'd guess this scenario is quite common for other schools/universities.
      The groups can be created from cohorts with the "Auto-create groups" feature. But unfortunately the cohorts aren't synced to these auto-created groups and modifying a cohort doesn't change the corresponding group.
      Summing up we've got the following situation:

      cohort – synced --> enrolment – NOT synced --> group (auto-created)

      In my point of view there is a need for a consistent sync because it's a logical conclusion to the idea of cohorts.

      Thanks in advance!

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          thanks for the report

          Show
          Petr Škoda added a comment - thanks for the report
          Hide
          Patrick Pollet added a comment - - edited

          Here is a git patch that does work in my place (a simplified version of the one I gave in MDL-22927)

          If it can be of some use ?

          Cheers
          It just requires that you add in config.php to enable automatice group/groupings creation and synching

          $CFG->enrolcohortsyncautocreategroup=1;
          $CFG->enrolcohortsyncautocreategrouping=1;
          $CFG->enrolcohortsyncuseidnumber=0;

          Show
          Patrick Pollet added a comment - - edited Here is a git patch that does work in my place (a simplified version of the one I gave in MDL-22927 ) If it can be of some use ? Cheers It just requires that you add in config.php to enable automatice group/groupings creation and synching $CFG->enrolcohortsyncautocreategroup=1; $CFG->enrolcohortsyncautocreategrouping=1; $CFG->enrolcohortsyncuseidnumber=0;
          Hide
          Patrick Pollet added a comment -

          and a second patch to take care of automatic group removal if user is not anymoe in the cohort

          Cheers.

          Show
          Patrick Pollet added a comment - and a second patch to take care of automatic group removal if user is not anymoe in the cohort Cheers.
          Hide
          Martin Dougiamas added a comment -

          Can't say I know about the patch but cohort-group sync would be really useful for moodle.org too so my +1 for this

          Show
          Martin Dougiamas added a comment - Can't say I know about the patch but cohort-group sync would be really useful for moodle.org too so my +1 for this
          Hide
          James Payne added a comment -

          Definitely would be useful, would integrate really well with an MIS link otherwise course membership seems like a real manual process.

          Show
          James Payne added a comment - Definitely would be useful, would integrate really well with an MIS link otherwise course membership seems like a real manual process.
          Hide
          Andrew Nicols added a comment -

          I believe that the addition of an idnumber to groups and groupings should also assist with the synchronisation of their members

          Show
          Andrew Nicols added a comment - I believe that the addition of an idnumber to groups and groupings should also assist with the synchronisation of their members
          Hide
          Patrick Pollet added a comment -

          and a third patch, still against Moodle 2.2 stable to make sure that if a teacher manually remove a student from a group synched with a cohort, the membership is restored at the next cron execution

          Cheers

          Show
          Patrick Pollet added a comment - and a third patch, still against Moodle 2.2 stable to make sure that if a teacher manually remove a student from a group synched with a cohort, the membership is restored at the next cron execution Cheers
          Hide
          Richard van Iwaarden added a comment -

          We really need to be able to add cohorts to groups. Please add this in 2.3 and I'll buy you pizza

          Show
          Richard van Iwaarden added a comment - We really need to be able to add cohorts to groups. Please add this in 2.3 and I'll buy you pizza
          Hide
          Przemyslaw Stencel added a comment -

          > to make sure that if a teacher manually remove a student from a group synched with a cohort, the membership is restored at the next cron execution

          Sorry to be replying so late, I only just now noticed Patrick's comment.

          I don't think this should work that way. If a teacher manually removes a student and then the student will be re-enrolled in the group at the next cron execution, it my cause quite a lot of confusion for the teacher. Imagine you remove a student from a group and half an hour later the student is there again. So you remove him again, only to see him back again half an hour later!

          I think a better way would be simply to block the ability to manually remove a student from a group if he's a member of the group as a result of cohort sync. Of course, there should be an error message saying e.g. "You can't remove this student from this group because he's a member of it thanks to a cohort sync", or something along these lines.

          Show
          Przemyslaw Stencel added a comment - > to make sure that if a teacher manually remove a student from a group synched with a cohort, the membership is restored at the next cron execution Sorry to be replying so late, I only just now noticed Patrick's comment. I don't think this should work that way. If a teacher manually removes a student and then the student will be re-enrolled in the group at the next cron execution, it my cause quite a lot of confusion for the teacher. Imagine you remove a student from a group and half an hour later the student is there again. So you remove him again, only to see him back again half an hour later! I think a better way would be simply to block the ability to manually remove a student from a group if he's a member of the group as a result of cohort sync. Of course, there should be an error message saying e.g. "You can't remove this student from this group because he's a member of it thanks to a cohort sync", or something along these lines.
          Hide
          Martin Dougiamas added a comment -

          We really need this for moodle.org too.

          Show
          Martin Dougiamas added a comment - We really need this for moodle.org too.
          Hide
          Stephen added a comment -

          Given that thought is being given to syncing cohorts into groups, I'd like to chip in with a suggestion in case it hasn't been considered.

          Being able to say members of Cohort-X will always be in Group A of Course 1 is nice, but is only a first step.

          It would be even better when auto-creating groups to be able to say: take Cohort-X and auto create groups from it. Any new members of Cohort-X get distributed between those auto-created groups as per the original rules.

          So at the start of the course (or realistically a week or so before the course officially begins and the teacher is setting it up) you may take Cohort-X that has 20 members and create 5 groups of 4 students. If a week later the course has 60 students the teacher does not have to trash their groups and start again, nor manually add the new 40 students to groups. Instead the magic of Cohort->Groups sync will ensure there are 5 groups now with 12 members each (and the original 20 remain in their original group).

          Hope this makes sense!

          Show
          Stephen added a comment - Given that thought is being given to syncing cohorts into groups, I'd like to chip in with a suggestion in case it hasn't been considered. Being able to say members of Cohort-X will always be in Group A of Course 1 is nice, but is only a first step. It would be even better when auto-creating groups to be able to say: take Cohort-X and auto create groups from it. Any new members of Cohort-X get distributed between those auto-created groups as per the original rules. So at the start of the course (or realistically a week or so before the course officially begins and the teacher is setting it up) you may take Cohort-X that has 20 members and create 5 groups of 4 students. If a week later the course has 60 students the teacher does not have to trash their groups and start again, nor manually add the new 40 students to groups. Instead the magic of Cohort->Groups sync will ensure there are 5 groups now with 12 members each (and the original 20 remain in their original group). Hope this makes sense!
          Hide
          Petr Škoda added a comment -

          The real problem here is that you need to be enrolled in the course BEFORE you can be added as group member. Do we want all cohort members to be always enrolled in the course?

          1/ yes - we can implement this in enrol_cohort; This is relatively simple and that is what I am going to implement now. It depends on the new group table fields which will be integrated soon I hope.

          2/ no - tricky, we could add only users that are actually enrolled into the groups, that means that you need to first get cohort users enrolled via any means and only then they appear in the selected group. What plugin should we use here? It does not seem like enrol plugin to me, we need something that can be linked form the course settings page - local plugin might be the best match.

          The even distribution to groups is something completely different, it could be implemented as a new feature in enrol_self, it already supports the cohort restrictions - see MDL-23875.

          Show
          Petr Škoda added a comment - The real problem here is that you need to be enrolled in the course BEFORE you can be added as group member. Do we want all cohort members to be always enrolled in the course? 1/ yes - we can implement this in enrol_cohort; This is relatively simple and that is what I am going to implement now. It depends on the new group table fields which will be integrated soon I hope. 2/ no - tricky, we could add only users that are actually enrolled into the groups, that means that you need to first get cohort users enrolled via any means and only then they appear in the selected group. What plugin should we use here? It does not seem like enrol plugin to me, we need something that can be linked form the course settings page - local plugin might be the best match. The even distribution to groups is something completely different, it could be implemented as a new feature in enrol_self, it already supports the cohort restrictions - see MDL-23875 .
          Hide
          Stephen added a comment -

          I would imagine if someone instructs Moodle to 'put all members of this cohort into this/these group(s)' then it implies then want all of those members in the course. I think that is a reasonable result.

          Show
          Stephen added a comment - I would imagine if someone instructs Moodle to 'put all members of this cohort into this/these group(s)' then it implies then want all of those members in the course. I think that is a reasonable result.
          Hide
          Petr Škoda added a comment -

          I am afraid that moodle.org is the example where you do not want that...

          Show
          Petr Škoda added a comment - I am afraid that moodle.org is the example where you do not want that...
          Hide
          Richard van Iwaarden added a comment - - edited

          For us (2500 students) it should be like this:

          Jack is in cohorts 2010, Mr.Jones, Science.
          James is in cohorts 2009, Mr. Jones, Languages.
          Jack is enrolled into course MATH
          James is enrolled into course SPANISH

          Bill Jones is the teacher of Jack and a math teacher. In the course MATH he can make a new group based on cohorts. If he chooses 'new group from cohort' and he chooses '2010' then Jack will be in it. If he chooses 'new group from cohort' and he chooses 'Mr. Jones' than Jack will be in it and James won't be in it, because James is not enrolled into MATH.

          Hope this makes things clear?

          Show
          Richard van Iwaarden added a comment - - edited For us (2500 students) it should be like this: Jack is in cohorts 2010, Mr.Jones, Science. James is in cohorts 2009, Mr. Jones, Languages. Jack is enrolled into course MATH James is enrolled into course SPANISH Bill Jones is the teacher of Jack and a math teacher. In the course MATH he can make a new group based on cohorts. If he chooses 'new group from cohort' and he chooses '2010' then Jack will be in it. If he chooses 'new group from cohort' and he chooses 'Mr. Jones' than Jack will be in it and James won't be in it, because James is not enrolled into MATH. Hope this makes things clear?
          Hide
          Petr Škoda added a comment - - edited

          Here is what I am going to implement for 2.4, it may or may not be suitable for you:

          1/ There will be a new option when setting up cohort enrolment sync instance - "Add users to group: no/group1/group2/..."
          2/ All members of the selected cohort will be enrolled and will be added to the selected group.
          3/ If user is removed from cohort the group membership is terminated.
          4/ Teachers can not manually remove cohort users from the selected group.

          Show
          Petr Škoda added a comment - - edited Here is what I am going to implement for 2.4, it may or may not be suitable for you: 1/ There will be a new option when setting up cohort enrolment sync instance - "Add users to group: no/group1/group2/..." 2/ All members of the selected cohort will be enrolled and will be added to the selected group. 3/ If user is removed from cohort the group membership is terminated. 4/ Teachers can not manually remove cohort users from the selected group.
          Hide
          Stephen added a comment -

          > I am afraid that moodle.org is the example where you do not want that...

          Sorry Petr, I don't understand this, maybe you can clarify for me.

          Cohort-X contains 10 students.
          Course A contains group-1.

          If I come along and say I want everyone from Cohort-X to be in group-1, surely by implication the only way that can happen is if everyone from Cohort-X is in course A. I don't understand how it would even make sense to be able to put members of a cohort into a group without those members being enrolled in the course.

          Show
          Stephen added a comment - > I am afraid that moodle.org is the example where you do not want that... Sorry Petr, I don't understand this, maybe you can clarify for me. Cohort-X contains 10 students. Course A contains group-1. If I come along and say I want everyone from Cohort-X to be in group-1, surely by implication the only way that can happen is if everyone from Cohort-X is in course A. I don't understand how it would even make sense to be able to put members of a cohort into a group without those members being enrolled in the course.
          Hide
          Petr Škoda added a comment -

          Imagine: you have a cohort with your VIP users and in some courses there are VIP groups, whenever you enrol some VIP in course you want them to immediately appear in that VIP group, the same when you add somebody to the VIP cohort you want them to appears in VIP groups of courses they are enrolled in...

          Show
          Petr Škoda added a comment - Imagine: you have a cohort with your VIP users and in some courses there are VIP groups, whenever you enrol some VIP in course you want them to immediately appear in that VIP group, the same when you add somebody to the VIP cohort you want them to appears in VIP groups of courses they are enrolled in...
          Hide
          Stephen added a comment -

          > Here is what I am going to implement for 2.4, it may or may not be suitable for you:
          >
          > 1/ There will be a new option when setting up cohort enrolment sync instance - "Add users to group: no/group1/group2/..."
          > 2/ All members of the selected cohort will be enrolled and will be added to the selected group.
          > 3/ If user is removed from cohort the group membership is terminated.
          > 4/ Teachers can not manually remove cohort users from the selected group.

          This seems a very reasonable and useful first step. Ideally I would like to also see 'Add users to an automated set of groups using the following rules <existing rules for automated groups>'.

          I understand this would involve more work but I think it would benefit many users.

          The most common use case would be where a single cohort maps to all students enrolled on a particular course, and where that particular course automatically sub-divides their students into manageable tutor groups. I have many such courses where there is no more than 15 students to a tutor, and the more students that take the course the more tutors that are allocated to it. I also have many examples of courses where there are multiple tutors between whom the students are evenly divided.

          Show
          Stephen added a comment - > Here is what I am going to implement for 2.4, it may or may not be suitable for you: > > 1/ There will be a new option when setting up cohort enrolment sync instance - "Add users to group: no/group1/group2/..." > 2/ All members of the selected cohort will be enrolled and will be added to the selected group. > 3/ If user is removed from cohort the group membership is terminated. > 4/ Teachers can not manually remove cohort users from the selected group. This seems a very reasonable and useful first step. Ideally I would like to also see 'Add users to an automated set of groups using the following rules <existing rules for automated groups>'. I understand this would involve more work but I think it would benefit many users. The most common use case would be where a single cohort maps to all students enrolled on a particular course, and where that particular course automatically sub-divides their students into manageable tutor groups. I have many such courses where there is no more than 15 students to a tutor, and the more students that take the course the more tutors that are allocated to it. I also have many examples of courses where there are multiple tutors between whom the students are evenly divided.
          Hide
          Stephen added a comment -

          > Imagine: you have a cohort with your VIP users and in some courses there are VIP groups, whenever you enrol some VIP in course you want them to
          > immediately appear in that VIP group, the same when you add somebody to the VIP cohort you want them to appears in VIP groups of courses they are enrolled in...

          My understanding of existing cohort functionality is that there is zero default relationship between a cohort and courses. The only relationship currently available is cohort syncing all members of a cohort into a course. This is an all or nothing process. I do not understand why cohorts would be used to automate a relationship between an arbitrary sub-set of a cohort and a course/group based on having to manually enrol that subset into the course.

          If you are manually managing the enrolment of a user into a course, their membership of a cohort that is not mapped to the same course should not affect that user in that course.

          Show
          Stephen added a comment - > Imagine: you have a cohort with your VIP users and in some courses there are VIP groups, whenever you enrol some VIP in course you want them to > immediately appear in that VIP group, the same when you add somebody to the VIP cohort you want them to appears in VIP groups of courses they are enrolled in... My understanding of existing cohort functionality is that there is zero default relationship between a cohort and courses. The only relationship currently available is cohort syncing all members of a cohort into a course. This is an all or nothing process. I do not understand why cohorts would be used to automate a relationship between an arbitrary sub-set of a cohort and a course/group based on having to manually enrol that subset into the course. If you are manually managing the enrolment of a user into a course, their membership of a cohort that is not mapped to the same course should not affect that user in that course.
          Hide
          Petr Škoda added a comment - - edited

          Yes, technically it would be possible to add new independent "Distribute users to grouping: no/grouping1/grouping2" option and then add users to random group from that grouping with the lowest member count. And not only for enrol_cohort, but enrol_self or enrol_paypal for example.

          Show
          Petr Škoda added a comment - - edited Yes, technically it would be possible to add new independent "Distribute users to grouping: no/grouping1/grouping2" option and then add users to random group from that grouping with the lowest member count. And not only for enrol_cohort, but enrol_self or enrol_paypal for example.
          Hide
          Oleg Sychev added a comment -

          >Here is what I am going to implement for 2.4, it may or may not be suitable for you:

          >1/ There will be a new option when setting up cohort enrolment sync instance - "Add users to group: no/group1/group2/..."
          >2/ All members of the selected cohort will be enrolled and will be added to the selected group.
          >3/ If user is removed from cohort the group membership is terminated.
          >4/ Teachers can not manually remove cohort users from the selected group.

          I don't see, would that means
          5/ If later user is added to cohort, he will be automatically enrolled in course and added to synced group

          For me it 5/ that make it actually "consistent sync".

          Show
          Oleg Sychev added a comment - >Here is what I am going to implement for 2.4, it may or may not be suitable for you: >1/ There will be a new option when setting up cohort enrolment sync instance - "Add users to group: no/group1/group2/..." >2/ All members of the selected cohort will be enrolled and will be added to the selected group. >3/ If user is removed from cohort the group membership is terminated. >4/ Teachers can not manually remove cohort users from the selected group. I don't see, would that means 5/ If later user is added to cohort, he will be automatically enrolled in course and added to synced group For me it 5/ that make it actually "consistent sync".
          Hide
          moodle.com added a comment -

          Petr, you were going to make a special local plugin for moodle.org that bypassed the enrolment process.

          Show
          moodle.com added a comment - Petr, you were going to make a special local plugin for moodle.org that bypassed the enrolment process.
          Hide
          Petr Škoda added a comment -

          Hi moodle.com, I am going to do what I said above and if necessary I can create a different plugin just for moodle.org in separate issue.

          Show
          Petr Škoda added a comment - Hi moodle.com, I am going to do what I said above and if necessary I can create a different plugin just for moodle.org in separate issue.
          Hide
          Dan Poltawski added a comment -

          (Created an issue for that: MDLSITE-1912)

          Show
          Dan Poltawski added a comment - (Created an issue for that: MDLSITE-1912 )
          Hide
          Gary Newport added a comment - - edited

          Sorry, I note above a reference to a patch but no idea where the patch is. I also note reference to Moodle 2.4 but since the stable version is 2.3.2+ surely a patch for that would be excellent?

          I am setting up Moodle for a college and support the idea that coorts being automatically mae into groups an ideal system. All our cohorts are our class codes (hence we know which cohort to allocate to which course). Automatically having the groups synched with the relevant cohort would be an absolute boon. In fact, having this an option that could be automatically enacted would reduce the workload of the teaching staff without shifting it to another member of staff.

          Show
          Gary Newport added a comment - - edited Sorry, I note above a reference to a patch but no idea where the patch is. I also note reference to Moodle 2.4 but since the stable version is 2.3.2+ surely a patch for that would be excellent? I am setting up Moodle for a college and support the idea that coorts being automatically mae into groups an ideal system. All our cohorts are our class codes (hence we know which cohort to allocate to which course). Automatically having the groups synched with the relevant cohort would be an absolute boon. In fact, having this an option that could be automatically enacted would reduce the workload of the teaching staff without shifting it to another member of staff.
          Hide
          Paul Sheehan added a comment - - edited

          Hello Moodle developers, first post on Moodle or indeed any forum / tracker kind of thing for that matter. Looking through this request in our institution we have actually implemented some of the functionality of this request. Please be aware I am not a coder, but someone who tends to fudge things together. Not being a Moodle coder this was actually written outside of Moodle in Powershell using a combination of database view queries and http screen scraping so no direct writing to database - however the mechanisms could be ported into PHP script. Before I am shunned / and or beaten for using this technique I had to achieve this in a REALLY REALLY short space of time and so please don't be too harsh - it works for us and keeps our SIS synced with Moodle Cohorts courses and Groups without worrying about the underline Moodle Framework. Sorry if this is not relevant or helpful as there seems to be an active path with this, but thought I would add my ten pence as we have had it running for a while now and a colleague suggested it may be found useful.

          The net result in our institution is this:

          1/ All Cohorts are created in Moodle prior to running the rest of the process.
          1/ All users are added to existing cohorts using the import users functionality using the cohort field.
          2/ Cohort sync 'CohortA' is added to course 1.
          3/ A group named 'CohortA' (same as relevant cohort)is added to course 1 with a flag set in the description field to indicate the group requires syncing with the cohort of the same name (Just in case). Ideally, should be a flag column of some sort in the database.
          4/ A periodic query is run on a view I created to determine users that have been added to cohortA that do not exist in GROUP 'cohortA' of course1 and adds the users to this group using standard posts to groups using screen scraping.

          At this point all users from COHORT 'CohortA' are added to GROUP 'CohortA' of course1. Later on, Jim Smith is added to COHORT 'cohortA' through the upload users and the view picks up that Jim Smith is still to be added to GROUP 'cohorta' of course1. It would also pick up on any other courses where a cohort Sync and group with same name and flag had been set. The view checks all courses where a course contains a cohort sync and group with the same name as the cohort and identifies the users to be added.

          5/ If a user is removed from the cohort the nature of cohort sync means the user is automatically removed from the group assuming only one enrollment method exists for the student. I should point out that adding to groups through the upload users adds another manual enrollment method in the course and is not suitable for deleting users as deleting the user from the cohort still leaves this new method. Again, I have written a screen scraper to bulk remove users from cohorts that, in turn, removes users from the relevant 'synced' group.

          Some caveats:

          1/ This sits outside of Moodle entirely But could be put into it if required I need direct clarification on this - can database tables be manipulated directly in Moodle or does everything have to be marshaled in some way though APIs and the like? If direct DB inserts is ok for table updates of mdl_group membership rather than screen scrape the updates based on the values returned from the view there is not much to be done as I could update this and run as part of a cron job I think.

          2/ If a teacher adds a user to the group that doesn't belong to the cohort this is permitted (may not be preferable). If the teacher removes a user from the group that still belongs in the same cohort the user will be re-added back into the group the next time the job is run.

          3/ I am sure there are others

          If direct database inserts into Mdl_Group_Membership for adding paired cohort users are permitted by Moodle this could be achieved quite quickly I think. If this could be clarified by someone it would be most appreciated so I know what to do with this. This solution is quite tailored by our institution in that its tied to the output of our SIS system but if there is any momentum in anyone requiring this I will generalize and improve it. Alternatively, I could provide the SQL views that identify the users still to be added from a Cohort to a group with the same name in all courses which could hopefully be used by someone.

          Show
          Paul Sheehan added a comment - - edited Hello Moodle developers, first post on Moodle or indeed any forum / tracker kind of thing for that matter. Looking through this request in our institution we have actually implemented some of the functionality of this request. Please be aware I am not a coder, but someone who tends to fudge things together. Not being a Moodle coder this was actually written outside of Moodle in Powershell using a combination of database view queries and http screen scraping so no direct writing to database - however the mechanisms could be ported into PHP script. Before I am shunned / and or beaten for using this technique I had to achieve this in a REALLY REALLY short space of time and so please don't be too harsh - it works for us and keeps our SIS synced with Moodle Cohorts courses and Groups without worrying about the underline Moodle Framework. Sorry if this is not relevant or helpful as there seems to be an active path with this, but thought I would add my ten pence as we have had it running for a while now and a colleague suggested it may be found useful. The net result in our institution is this: 1/ All Cohorts are created in Moodle prior to running the rest of the process. 1/ All users are added to existing cohorts using the import users functionality using the cohort field. 2/ Cohort sync 'CohortA' is added to course 1. 3/ A group named 'CohortA' (same as relevant cohort)is added to course 1 with a flag set in the description field to indicate the group requires syncing with the cohort of the same name (Just in case). Ideally, should be a flag column of some sort in the database. 4/ A periodic query is run on a view I created to determine users that have been added to cohortA that do not exist in GROUP 'cohortA' of course1 and adds the users to this group using standard posts to groups using screen scraping. At this point all users from COHORT 'CohortA' are added to GROUP 'CohortA' of course1. Later on, Jim Smith is added to COHORT 'cohortA' through the upload users and the view picks up that Jim Smith is still to be added to GROUP 'cohorta' of course1. It would also pick up on any other courses where a cohort Sync and group with same name and flag had been set. The view checks all courses where a course contains a cohort sync and group with the same name as the cohort and identifies the users to be added. 5/ If a user is removed from the cohort the nature of cohort sync means the user is automatically removed from the group assuming only one enrollment method exists for the student. I should point out that adding to groups through the upload users adds another manual enrollment method in the course and is not suitable for deleting users as deleting the user from the cohort still leaves this new method. Again, I have written a screen scraper to bulk remove users from cohorts that, in turn, removes users from the relevant 'synced' group. Some caveats: 1/ This sits outside of Moodle entirely But could be put into it if required I need direct clarification on this - can database tables be manipulated directly in Moodle or does everything have to be marshaled in some way though APIs and the like? If direct DB inserts is ok for table updates of mdl_group membership rather than screen scrape the updates based on the values returned from the view there is not much to be done as I could update this and run as part of a cron job I think. 2/ If a teacher adds a user to the group that doesn't belong to the cohort this is permitted (may not be preferable). If the teacher removes a user from the group that still belongs in the same cohort the user will be re-added back into the group the next time the job is run. 3/ I am sure there are others If direct database inserts into Mdl_Group_Membership for adding paired cohort users are permitted by Moodle this could be achieved quite quickly I think. If this could be clarified by someone it would be most appreciated so I know what to do with this. This solution is quite tailored by our institution in that its tied to the output of our SIS system but if there is any momentum in anyone requiring this I will generalize and improve it. Alternatively, I could provide the SQL views that identify the users still to be added from a Cohort to a group with the same name in all courses which could hopefully be used by someone.
          Hide
          Helen Foster added a comment -

          Hi Paul and welcome to the Moodle community Thanks a lot for sharing your solution to cohort and group syncing.

          Unfortunately I am not really a Moodle developer, so can't comment on what you have done, however I just wanted to add a little note to say that comments on tracker issues with suggested solutions, partial solutions, brainstorming etc are always welcome, also in the moodle.org forums (actually maybe the forums are better for brainstorming... ).

          Show
          Helen Foster added a comment - Hi Paul and welcome to the Moodle community Thanks a lot for sharing your solution to cohort and group syncing. Unfortunately I am not really a Moodle developer, so can't comment on what you have done, however I just wanted to add a little note to say that comments on tracker issues with suggested solutions, partial solutions, brainstorming etc are always welcome, also in the moodle.org forums (actually maybe the forums are better for brainstorming... ).
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks!

          PS: I'm not 100% sold to those debugging() calls along the restore process. logging should be able to report everything instead, IMO. Anyway... let's see.

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, thanks! PS: I'm not 100% sold to those debugging() calls along the restore process. logging should be able to report everything instead, IMO. Anyway... let's see.
          Hide
          Petr Škoda added a comment -

          Yes Eloy, the debugging messages are the worst option, but tho only I am afraid. Somebody has to implement the logging in restore UI and use it consistently everywhere. I am not volunteering right now before the freeze, sorry.

          Show
          Petr Škoda added a comment - Yes Eloy, the debugging messages are the worst option, but tho only I am afraid. Somebody has to implement the logging in restore UI and use it consistently everywhere. I am not volunteering right now before the freeze, sorry.
          Hide
          Tim Barker added a comment -

          Comprehensively tested using Petr's guidelines. Was not able to run the PHPUnit tests on MSSQL or Oracle though as I do not have that test environment available to me.

          Show
          Tim Barker added a comment - Comprehensively tested using Petr's guidelines. Was not able to run the PHPUnit tests on MSSQL or Oracle though as I do not have that test environment available to me.
          Hide
          Dan Poltawski added a comment -

          (I've run phpunit on Oracle and its all good)

          Show
          Dan Poltawski added a comment - (I've run phpunit on Oracle and its all good)
          Hide
          Phineas Head added a comment -

          Hi all, my turn for a first-ever-post!

          Could I please confirm that we are having the same issue?

          We run a number of BTec qualifications, each of which comprises a number of Units (typically 18). Historically, to handle this my college has created one Moodle 'course' per qualification, and created topic-view topics within each one for its units. We then enrolled students in to their single respective Moodle course (= real-life qualification) and put them into class groups with it (typically Groups A-I).

          This year, having received some expert training, we were advised to consider making each Unit its own course, load students into a cohort per qualification and then enrol/sync each into their respective Moodle meta-courses (= real-life Units), thereby being able to better take advantage of Moodle's completion tracking features, grade-book and simplifying the enrolment procedure. Having set that up on a test site the problem I have encountered is synchronising the groups between these courses.

          So, I have...

          Moodle Cohort 1 (all students of Qualification 1)
          course-sync enrolled on
          Moodle Course 1 (a 'normal' course containing general information/student handbooks etc. on Qualification 1)
          course-meta-linked to
          18 Moodle Meta-Courses (the units of this qualification)

          So far, so good. Except...

          1) When I make a Groups in the 'host' Course 1 they doesn't propagate to the meta-linked courses.

          2) When I upload users and specify their cohort1 and group1 settings, only the cohort1 bit seems to make it through to the course on which I enrol the cohort.

          3) When I work around this by creating one cohort per group I want (i.e. Cohorts A-I) and enrolling these in the 'host' Course 1, that gets closest to what I want, but I don't see any subdivisions by cohort when I view the results of an assessment (i.e. I just see all the students on the course, rather than getting the option to subdivide and see the submissions of only Cohort A).

          Therefore, could I just confirm that...

          A) The rationale to switch to the cohorts system is sound for what we want to achieve

          B) I am implementing it correctly

          C) The problem with the groups is a current limitation of Moodle which is being addressed, rather than me being thick and missing a feature it already has which will achieve this.

          Many thanks!

          p.s. I know about auto-create groups, but I have to do that per-course (unit) which negates the convenience of cohort syncing in the first place! (Unless I've missed something).

          Show
          Phineas Head added a comment - Hi all, my turn for a first-ever-post! Could I please confirm that we are having the same issue? We run a number of BTec qualifications, each of which comprises a number of Units (typically 18). Historically, to handle this my college has created one Moodle 'course' per qualification, and created topic-view topics within each one for its units. We then enrolled students in to their single respective Moodle course (= real-life qualification) and put them into class groups with it (typically Groups A-I). This year, having received some expert training, we were advised to consider making each Unit its own course, load students into a cohort per qualification and then enrol/sync each into their respective Moodle meta-courses (= real-life Units), thereby being able to better take advantage of Moodle's completion tracking features, grade-book and simplifying the enrolment procedure. Having set that up on a test site the problem I have encountered is synchronising the groups between these courses. So, I have... Moodle Cohort 1 (all students of Qualification 1) course-sync enrolled on Moodle Course 1 (a 'normal' course containing general information/student handbooks etc. on Qualification 1) course-meta-linked to 18 Moodle Meta-Courses (the units of this qualification) So far, so good. Except... 1) When I make a Groups in the 'host' Course 1 they doesn't propagate to the meta-linked courses. 2) When I upload users and specify their cohort1 and group1 settings, only the cohort1 bit seems to make it through to the course on which I enrol the cohort. 3) When I work around this by creating one cohort per group I want (i.e. Cohorts A-I) and enrolling these in the 'host' Course 1, that gets closest to what I want, but I don't see any subdivisions by cohort when I view the results of an assessment (i.e. I just see all the students on the course, rather than getting the option to subdivide and see the submissions of only Cohort A). Therefore, could I just confirm that... A) The rationale to switch to the cohorts system is sound for what we want to achieve B) I am implementing it correctly C) The problem with the groups is a current limitation of Moodle which is being addressed, rather than me being thick and missing a feature it already has which will achieve this. Many thanks! p.s. I know about auto-create groups, but I have to do that per-course (unit) which negates the convenience of cohort syncing in the first place! (Unless I've missed something).
          Hide
          Petr Škoda added a comment -

          Hello, please use moodle.org forums for general support questions, thanks. This issue introduces new option which adds users to selected group when synchronising enrolments with one selected cohort + contains a complete implementation of restore support for this enrolment plugin.

          Show
          Petr Škoda added a comment - Hello, please use moodle.org forums for general support questions, thanks. This issue introduces new option which adds users to selected group when synchronising enrolments with one selected cohort + contains a complete implementation of restore support for this enrolment plugin.
          Hide
          Phineas Head added a comment -

          Hello Petr – right, so it would solve my problem, but is not yet implemented?

          Show
          Phineas Head added a comment - Hello Petr – right, so it would solve my problem, but is not yet implemented?
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Closing as fixed, many thanks for your awesome collaboration.

          Show
          Eloy Lafuente (stronk7) added a comment - Closing as fixed, many thanks for your awesome collaboration.
          Hide
          Daniel Pospisil added a comment -

          I have just one small question - when I add all of the cohorts into the course, I want to automatically create groups in the course according to the cohorts. And I want the groups to be named exactly as the cohorts - is that possible somehow?

          Show
          Daniel Pospisil added a comment - I have just one small question - when I add all of the cohorts into the course, I want to automatically create groups in the course according to the cohorts. And I want the groups to be named exactly as the cohorts - is that possible somehow?
          Hide
          Petr Škoda added a comment - - edited

          The cohorts enrolment plugin does not create groups, you need to create them manually first and then select them when adding cohort enrolment method to course.

          Show
          Petr Škoda added a comment - - edited The cohorts enrolment plugin does not create groups, you need to create them manually first and then select them when adding cohort enrolment method to course.
          Hide
          Daniel Pospisil added a comment -

          We have over 100 cohorts for different organizations, and have courses where they need to be enrolled in groups according to their organization. The feature Auto-create groups works just fine to create groups according to the cohorts enrolled, bud the naming must be Group A, Group B etc... So nobody can tell from which organizations the people in particular groups are without searching... I don't know how difficult it would be to have an option to copy the names of cohorts (instead of automatically generated names) while using the Auto-create groups function.

          Show
          Daniel Pospisil added a comment - We have over 100 cohorts for different organizations, and have courses where they need to be enrolled in groups according to their organization. The feature Auto-create groups works just fine to create groups according to the cohorts enrolled, bud the naming must be Group A, Group B etc... So nobody can tell from which organizations the people in particular groups are without searching... I don't know how difficult it would be to have an option to copy the names of cohorts (instead of automatically generated names) while using the Auto-create groups function.
          Hide
          Mary Cooch added a comment -

          Removing docs_required label as this is documented here http://docs.moodle.org/24/en/Cohort_sync

          Show
          Mary Cooch added a comment - Removing docs_required label as this is documented here http://docs.moodle.org/24/en/Cohort_sync
          Hide
          Richard van Iwaarden added a comment -

          This tracker is closed, but it doesn't work for me (Moodle 2.4.1+ (Build: 20130214))

          We have cohorts that are created by LDAP. When I autocreate the group inside a course, and this group is exactly the same as the cohort, students are not added to the group or removed from the group when the cohort synchronises with our LDAP group.

          Is this not supposed to work? Am I overlooking something?

          Show
          Richard van Iwaarden added a comment - This tracker is closed, but it doesn't work for me (Moodle 2.4.1+ (Build: 20130214)) We have cohorts that are created by LDAP. When I autocreate the group inside a course, and this group is exactly the same as the cohort, students are not added to the group or removed from the group when the cohort synchronises with our LDAP group. Is this not supposed to work? Am I overlooking something?
          Hide
          Petr Škoda added a comment -

          see above: "you need to create them (groups) manually first and then select them when adding cohort enrolment method to course."

          Show
          Petr Škoda added a comment - see above: "you need to create them (groups) manually first and then select them when adding cohort enrolment method to course."
          Hide
          Richard van Iwaarden added a comment -

          Hi Petr,

          I'm sorry - must be my English, but I don't understand what you mean. This is what I do:
          1. I go to the course
          2. I go to users -> groups
          3. I creat a group automatically
          4. I select a sitegroup/cohort and create one group with all cohort members.

          Please tell me which step is wrong?

          Show
          Richard van Iwaarden added a comment - Hi Petr, I'm sorry - must be my English, but I don't understand what you mean. This is what I do: 1. I go to the course 2. I go to users -> groups 3. I creat a group automatically 4. I select a sitegroup/cohort and create one group with all cohort members. Please tell me which step is wrong?
          Hide
          Petr Škoda added a comment -

          5. go to enrolment methods page
          6. add cohort enrolment method to course with selected group

          Show
          Petr Škoda added a comment - 5. go to enrolment methods page 6. add cohort enrolment method to course with selected group
          Hide
          Petr Škoda added a comment -

          If yur users are enrolled to courses via some other method/criteria use https://moodle.org/plugins/view.php?plugin=enrol_groupsync

          Show
          Petr Škoda added a comment - If yur users are enrolled to courses via some other method/criteria use https://moodle.org/plugins/view.php?plugin=enrol_groupsync
          Hide
          Richard van Iwaarden added a comment - - edited

          Hm... then I need to test this first. It might be that I don't want all the cohort members is the group, but just the ones that are in the course already.

          Example:

          Cohort fruit: apple, pear, banana, grape
          Cohort 2011: banana, grape, tomato, cucumber

          Add to course grocerystore: cohort fruit
          Add group to course called 2011 based on cohort 2011

          Group 2011 in grocerystore (based on cohort 2011) should contain banana and grape.

          The way you describe it (points 1 to 6) is also adding tomato and cucumber to the course grocerystore. This is not the intention.

          Show
          Richard van Iwaarden added a comment - - edited Hm... then I need to test this first. It might be that I don't want all the cohort members is the group, but just the ones that are in the course already. Example: Cohort fruit: apple, pear, banana, grape Cohort 2011: banana, grape, tomato, cucumber Add to course grocerystore: cohort fruit Add group to course called 2011 based on cohort 2011 Group 2011 in grocerystore (based on cohort 2011) should contain banana and grape. The way you describe it (points 1 to 6) is also adding tomato and cucumber to the course grocerystore. This is not the intention.
          Hide
          Petr Škoda added a comment -

          Your requirements seem to match the expected use of the linked addon.

          Show
          Petr Škoda added a comment - Your requirements seem to match the expected use of the linked addon.
          Hide
          Richard van Iwaarden added a comment -

          Cheers, I will check that plugin out.

          Show
          Richard van Iwaarden added a comment - Cheers, I will check that plugin out.

            People

            • Votes:
              24 Vote for this issue
              Watchers:
              24 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: