Moodle Community Sites
  1. Moodle Community Sites
  2. MDLSITE-2081

local_moodleorg needs to populate PHM cohort rather than group

    Details

    • Rank:
      47096

      Description

      We'll use the cohort sync plugin to populate to all the courses.

        Issue Links

        Progress
        Unresolved Sub-Tasks

        Sub-Tasks

        1. Execute update_phm.php via cron Sub-task Open Unassigned
         

          Activity

          Hide
          Dan Poltawski added a comment -

          hmm, this is gonna be harder than I thought

          Show
          Dan Poltawski added a comment - hmm, this is gonna be harder than I thought
          Hide
          Dan Poltawski added a comment -

          with the groups we were doing it per course, so could work out who to remove.

          Show
          Dan Poltawski added a comment - with the groups we were doing it per course, so could work out who to remove.
          Hide
          Dan Poltawski added a comment -

          Added Helen here..

          Talked with Martin to help me form my undeststanding.

          At the moment we work out the PHM's per course. I will change this so that course is not considered, i.e. any posts/ratings across the site will be used.

          One problem with becoming site wide is that its more difficult to inform the correct course facilitator about a new PHM being added. One potential solution to this is that we could inform each course facilitator about anyone enrolled in their course who is made a PHM.

          Show
          Dan Poltawski added a comment - Added Helen here.. Talked with Martin to help me form my undeststanding. At the moment we work out the PHM's per course. I will change this so that course is not considered, i.e. any posts/ratings across the site will be used. One problem with becoming site wide is that its more difficult to inform the correct course facilitator about a new PHM being added. One potential solution to this is that we could inform each course facilitator about anyone enrolled in their course who is made a PHM.
          Hide
          Martin Dougiamas added a comment -

          Sounds fine to me.

          Show
          Martin Dougiamas added a comment - Sounds fine to me.
          Hide
          Helen Foster added a comment -

          Just noting that I've created a PHM cohort and am going through all the courses creating a PHM group in each one and adding a cohort members to group enrolment method to populate the PHM group from the PHM cohort.

          Show
          Helen Foster added a comment - Just noting that I've created a PHM cohort and am going through all the courses creating a PHM group in each one and adding a cohort members to group enrolment method to populate the PHM group from the PHM cohort.
          Hide
          Helen Foster added a comment -

          Dan, when you next look at the PHM script, please could you remove the requirement 'Must have posted something in the past 60 days' (or let me know if I should create a new tracker issue for it).

          People are removed from the PHM group anyway if they become unenrolled from Using Moodle due to inactivity. Having the PHM script remove people causes confusion, as quite a few people have contacted me to ask why they have been dropped from the group. Currently, when they re-enrol in Using Moodle, they have to wait until the beginning of the next month for the PHM script to run to be re-added to the group. Once we start using the cohort members to group enrolment method, people will be added to the PHM group automatically as soon as they re-enrol.

          Show
          Helen Foster added a comment - Dan, when you next look at the PHM script, please could you remove the requirement 'Must have posted something in the past 60 days' (or let me know if I should create a new tracker issue for it). People are removed from the PHM group anyway if they become unenrolled from Using Moodle due to inactivity. Having the PHM script remove people causes confusion, as quite a few people have contacted me to ask why they have been dropped from the group. Currently, when they re-enrol in Using Moodle, they have to wait until the beginning of the next month for the PHM script to run to be re-added to the group. Once we start using the cohort members to group enrolment method, people will be added to the PHM group automatically as soon as they re-enrol.
          Hide
          Dan Poltawski added a comment -

          Hmm, i'm sat here remvoing code here there and everywhere and I think that without the 60 day requirement and not tied to scale this phm calculation becomes ridiculously easy..

          Show
          Dan Poltawski added a comment - Hmm, i'm sat here remvoing code here there and everywhere and I think that without the 60 day requirement and not tied to scale this phm calculation becomes ridiculously easy..
          Hide
          Dan Poltawski added a comment -

          Oh no, its complicated due to the requirement of working out what the context is for each forum post.

          Show
          Dan Poltawski added a comment - Oh no, its complicated due to the requirement of working out what the context is for each forum post.
          Hide
          Dan Poltawski added a comment -
          SELECT fp.userid, count(r.id)
          FROM mdl_forum_posts fp
          JOIN mdl_forum_discussions fd ON fp.discussion = fd.id
          JOIN mdl_course_modules cm ON cm.instance = fd.forum
          JOIN mdl_context ctx ON ctx.instanceid = cm.id
          JOIN mdl_rating r ON r.contextid = ctx.id
          WHERE cm.module = (SELECT id FROM mdl_modules where name = 'forum')
          AND ctx.contextlevel = 70 AND r.component = 'mod_forum' AND r.ratingarea = 'post'
          AND r.itemid = fp.id
          GROUP BY fp.userid
          
          Show
          Dan Poltawski added a comment - SELECT fp.userid, count(r.id) FROM mdl_forum_posts fp JOIN mdl_forum_discussions fd ON fp.discussion = fd.id JOIN mdl_course_modules cm ON cm.instance = fd.forum JOIN mdl_context ctx ON ctx.instanceid = cm.id JOIN mdl_rating r ON r.contextid = ctx.id WHERE cm.module = (SELECT id FROM mdl_modules where name = 'forum') AND ctx.contextlevel = 70 AND r.component = 'mod_forum' AND r.ratingarea = 'post' AND r.itemid = fp.id GROUP BY fp.userid
          Hide
          Dan Poltawski added a comment -

          I've run a first go of this based on the new non-time based rules:

          • You need to have been rated useful at least 14 times
          • Been rated by 8 different raters
          • And a post to ratings count of 0.12 or graer.

          While this now brings in 100 new people (who from names look from non-english language courses) the problem is that this seems to remove a lot of old-time posters. I assume because the ratio rule applies on all posts, even before we had useful scales in place. I think we probably need to change the ratio part to only apply on recentish posts. Will try a few things

          Show
          Dan Poltawski added a comment - I've run a first go of this based on the new non-time based rules: You need to have been rated useful at least 14 times Been rated by 8 different raters And a post to ratings count of 0.12 or graer. While this now brings in 100 new people (who from names look from non-english language courses) the problem is that this seems to remove a lot of old-time posters. I assume because the ratio rule applies on all posts, even before we had useful scales in place. I think we probably need to change the ratio part to only apply on recentish posts. Will try a few things
          Hide
          Dan Poltawski added a comment -

          Actually, I put a typo in the rating ratio!

          I've run again and now it doesn't remove anyone, but it it'll add 187 users. I recognise quite a few of the names as old-timers who haven't posted in some time (2+ years). Maybe we could consider doing it based on having posted in the last 2 years?

          Show
          Dan Poltawski added a comment - Actually, I put a typo in the rating ratio! I've run again and now it doesn't remove anyone, but it it'll add 187 users. I recognise quite a few of the names as old-timers who haven't posted in some time (2+ years). Maybe we could consider doing it based on having posted in the last 2 years?
          Hide
          Martin Dougiamas added a comment -

          Why are you taking out the "must have posted recently?"

          If someone doesn't post they aren't particularly helpful!

          I'm OK with lengthening 60 days a bit if required but surely we need something there.

          Show
          Martin Dougiamas added a comment - Why are you taking out the "must have posted recently?" If someone doesn't post they aren't particularly helpful! I'm OK with lengthening 60 days a bit if required but surely we need something there.
          Hide
          Dan Poltawski added a comment -

          Because Helen asked for it above!

          Show
          Dan Poltawski added a comment - Because Helen asked for it above!
          Hide
          Helen Foster added a comment -

          Sorry for not explaining things so well previously, or maybe there is something I'm not understanding? Let me try again...

          If someone doesn't post in 60 days, they are unenrolled from the course and so from the PHM group. Why make the script do that too? A good reason why NOT to make the script do that is for PHMs who stop posting for a while and then start again (a very common occurrence) are confused as to why they are no longer a PHM. They then have to wait up to a month to be re-added to the PHM group.

          Show
          Helen Foster added a comment - Sorry for not explaining things so well previously, or maybe there is something I'm not understanding? Let me try again... If someone doesn't post in 60 days, they are unenrolled from the course and so from the PHM group. Why make the script do that too? A good reason why NOT to make the script do that is for PHMs who stop posting for a while and then start again (a very common occurrence) are confused as to why they are no longer a PHM. They then have to wait up to a month to be re-added to the PHM group.
          Hide
          Martin Dougiamas added a comment - - edited

          Thanks for explaining.

          Actually, that does not make sense. It means that someone who is a PHM need never post again, and as long as they just log in they'll forever be regarded a PHM.

          I don't think that's particularly helpful, we want them to be actually posting.

          So I would still be checking for a post within the last X days, it's unrelated to enrolment.

          Show
          Martin Dougiamas added a comment - - edited Thanks for explaining. Actually, that does not make sense. It means that someone who is a PHM need never post again, and as long as they just log in they'll forever be regarded a PHM. I don't think that's particularly helpful, we want them to be actually posting. So I would still be checking for a post within the last X days, it's unrelated to enrolment.
          Hide
          Dan Poltawski added a comment -

          I've deployed the current phm code populating the cohort and then cohort-synced to a new group so can see the comparison. I'm going to do a reset of the clone site to todays moodle.org db so that we can work on it a bit more with non-out of date info.

          But at this miment i'm loosing too many from the group:

          English: (current: 123 new: 75)
          http://clone.moodle.org/group/overview.php?id=5

          French: (current: 24 new: 15)
          http://clone.moodle.org/group/overview.php?id=20

          Spanish: (current: 29 new: 16)
          http://clone.moodle.org/group/overview.php?id=11

          Show
          Dan Poltawski added a comment - I've deployed the current phm code populating the cohort and then cohort-synced to a new group so can see the comparison. I'm going to do a reset of the clone site to todays moodle.org db so that we can work on it a bit more with non-out of date info. But at this miment i'm loosing too many from the group: English: (current: 123 new: 75) http://clone.moodle.org/group/overview.php?id=5 French: (current: 24 new: 15) http://clone.moodle.org/group/overview.php?id=20 Spanish: (current: 29 new: 16) http://clone.moodle.org/group/overview.php?id=11
          Hide
          Helen Foster added a comment -

          Hi Dan,

          Please could you give an update with where we are on this issue, then maybe you'd like it to be re-assigned to someone in the community sites team?

          I have set up a Particularly helpful Moodlers cohort members to group enrolment method in each course.

          Show
          Helen Foster added a comment - Hi Dan, Please could you give an update with where we are on this issue, then maybe you'd like it to be re-assigned to someone in the community sites team? I have set up a Particularly helpful Moodlers cohort members to group enrolment method in each course.
          Hide
          Dan Poltawski added a comment -

          Hi Helen,

          The code for this is done in the way discussed on this issue. But its all tied together with all the changes in various subtasks in this META for someone to be able to pick it up.

          So, going forward I see:

          1. Someone needs to become familiar with all the related changes on my branch wip-danp-useful-rework (useful posts on front page, course mapping in plugin etc etc).
          2. Deployed on the clone to see the resulsts
          3. The actual algorithm we use to work out phm needs to be reviewed and tweaked, as mentioned in my post above, we've seen to losses and gains which may not be right. Doing this course-wide changes the way it works.

          dan

          Show
          Dan Poltawski added a comment - Hi Helen, The code for this is done in the way discussed on this issue. But its all tied together with all the changes in various subtasks in this META for someone to be able to pick it up. So, going forward I see: Someone needs to become familiar with all the related changes on my branch wip-danp-useful-rework (useful posts on front page, course mapping in plugin etc etc). Deployed on the clone to see the resulsts The actual algorithm we use to work out phm needs to be reviewed and tweaked, as mentioned in my post above, we've seen to losses and gains which may not be right. Doing this course-wide changes the way it works. dan
          Hide
          Helen Foster added a comment -

          Thanks Dan for the info. I'm just unassigning you so we can easily see what needs picking up by the sites team.

          Show
          Helen Foster added a comment - Thanks Dan for the info. I'm just unassigning you so we can easily see what needs picking up by the sites team.
          Hide
          Helen Foster added a comment -

          David, can we try this on the clone site sometime?

          Show
          Helen Foster added a comment - David, can we try this on the clone site sometime?
          Hide
          David Mudrak added a comment -

          Right. Sorry this took time to get under my radar. So, I went thru the code to get familiar with this area. Big thanks to Dan for all his awesome work on this. His code is clean and easy to follow.

          So, I have executed the script to populate the PHM cohort at the clone machine. It put total of 107 users into it. There is one thing that will not make Helen happy though. We can't use that cohort manually pre-created. As we are going to use this externally maintained cohort, it can't be created manually. The script created a new cohort "Particularly helpful moodlers" (note the lowercase m). So all the cohort-to-group-members enrolment plugins in all courses have to be updated to use this new cohort instead of the manually created "Particularly helpful Moodlers" (note the uppercase M):

          http://clone.moodle.org/cohort/index.php

          I have tested the enrolment plugin in the Czech community course and it put just myself into the group:

          http://clone.moodle.org/group/overview.php?id=17227

          More testing is required I would say. Also, IIRC the cronjob is not running at the clone which may or may not be related.

          Show
          David Mudrak added a comment - Right. Sorry this took time to get under my radar. So, I went thru the code to get familiar with this area. Big thanks to Dan for all his awesome work on this. His code is clean and easy to follow. So, I have executed the script to populate the PHM cohort at the clone machine. It put total of 107 users into it. There is one thing that will not make Helen happy though. We can't use that cohort manually pre-created. As we are going to use this externally maintained cohort, it can't be created manually. The script created a new cohort "Particularly helpful moodlers" (note the lowercase m). So all the cohort-to-group-members enrolment plugins in all courses have to be updated to use this new cohort instead of the manually created "Particularly helpful Moodlers" (note the uppercase M): http://clone.moodle.org/cohort/index.php I have tested the enrolment plugin in the Czech community course and it put just myself into the group: http://clone.moodle.org/group/overview.php?id=17227 More testing is required I would say. Also, IIRC the cronjob is not running at the clone which may or may not be related.
          Hide
          Helen Foster added a comment -

          Thanks David. I have tried adding a cohort-to-group-members enrolment plugin for "Particularly helpful moodlers" to several courses and found that in each case the PHM group was populated correctly. Is there anything else I should test?

          I was also wondering why the "Particularly helpful moodlers" cohort contains 107 users, whereas the PHM group in Moodle in English contains 132 users?

          Show
          Helen Foster added a comment - Thanks David. I have tried adding a cohort-to-group-members enrolment plugin for "Particularly helpful moodlers" to several courses and found that in each case the PHM group was populated correctly. Is there anything else I should test? I was also wondering why the "Particularly helpful moodlers" cohort contains 107 users, whereas the PHM group in Moodle in English contains 132 users?
          Hide
          David Mudrak added a comment -

          Could it be that the group is copied from the live moodle.org, thence manually populated? IIRC, the Cohort to group enrolment plugin does not remove members that were not assigned to the group by itself - and currently all 132 members are put into the group manually. What might help is to remove all current group members and let the plugin re-sync. I can try that if your agree.

          Show
          David Mudrak added a comment - Could it be that the group is copied from the live moodle.org, thence manually populated? IIRC, the Cohort to group enrolment plugin does not remove members that were not assigned to the group by itself - and currently all 132 members are put into the group manually. What might help is to remove all current group members and let the plugin re-sync. I can try that if your agree.
          Hide
          David Mudrak added a comment -

          Today, the script logic has been improved so that it matches the previous criteria as much as possible, while still performing well. As tested by Helen, all cohort members are also current PHM.

          Matthew Spurrier please let's talk tomorrow to enable executing the update script via cron.

          Show
          David Mudrak added a comment - Today, the script logic has been improved so that it matches the previous criteria as much as possible, while still performing well. As tested by Helen, all cohort members are also current PHM. Matthew Spurrier please let's talk tomorrow to enable executing the update script via cron.
          Hide
          David Mudrak added a comment -

          So, there are some decisions required before we move this to the production site.

          • How often should the cohort be populated (i.e. how often should we look for new PHMs)? The performance is pretty good now so it can be safely done every night, every week, every month, whatever.
          • Should some e-mail notifications be sent when a new member is added to the cohort (or removed from the cohort)? If so, who should receive them? (this is not implemented in the new script yet).
          Show
          David Mudrak added a comment - So, there are some decisions required before we move this to the production site. How often should the cohort be populated (i.e. how often should we look for new PHMs)? The performance is pretty good now so it can be safely done every night, every week, every month, whatever. Should some e-mail notifications be sent when a new member is added to the cohort (or removed from the cohort)? If so, who should receive them? (this is not implemented in the new script yet).
          Hide
          David Mudrak added a comment -

          For the record, the enrol_groupsync seems to work well - just tested in the Czech community course at https://next.moodle.org/group/overview.php?id=17227 the cron in that plugin is set to execute hourly using the in-built cron mechanism (no extra cron setting at the server level needed).

          Show
          David Mudrak added a comment - For the record, the enrol_groupsync seems to work well - just tested in the Czech community course at https://next.moodle.org/group/overview.php?id=17227 the cron in that plugin is set to execute hourly using the in-built cron mechanism (no extra cron setting at the server level needed).
          Hide
          Helen Foster added a comment -
          • How often should the cohort be populated? How about once a week. I don't think it's necessary to do it nightly and manually awarding PHM 2014 badges (current solution) weekly sounds doable.
          • Should some e-mail notifications be sent when a new member is added to the cohort (or removed from the cohort)? If so, who should receive them? Yes, notification is necessary in order to award PHM 2014 badges. How about only notifying me for now.

          Thanks for the info about the cohort members to group plugin working hourly. I'd noticed it didn't work immediately and didn't realise it required the cron.

          Show
          Helen Foster added a comment - How often should the cohort be populated? How about once a week. I don't think it's necessary to do it nightly and manually awarding PHM 2014 badges (current solution) weekly sounds doable. Should some e-mail notifications be sent when a new member is added to the cohort (or removed from the cohort)? If so, who should receive them? Yes, notification is necessary in order to award PHM 2014 badges. How about only notifying me for now. Thanks for the info about the cohort members to group plugin working hourly. I'd noticed it didn't work immediately and didn't realise it required the cron.
          Hide
          David Mudrak added a comment -

          OK, this should be done now. Helen, you should find two test notification e-mails in your inbox to illustrate how this will work in the future on the live system. To test it, I removed myself from the PHM cohort and added Trudy Tested to it prior to running the sync script. So the expected output was that I should be added and Trudy removed from the cohort.

          At the moment, only you and me are getting these e-mails. As agreed in the private chat, the e-mail body text now contains just summary information while details are attached in the CSV format.

          Show
          David Mudrak added a comment - OK, this should be done now. Helen, you should find two test notification e-mails in your inbox to illustrate how this will work in the future on the live system. To test it, I removed myself from the PHM cohort and added Trudy Tested to it prior to running the sync script. So the expected output was that I should be added and Trudy removed from the cohort. At the moment, only you and me are getting these e-mails. As agreed in the private chat, the e-mail body text now contains just summary information while details are attached in the CSV format.
          Hide
          Helen Foster added a comment -

          PHM cohort update notification email received and checked. Everything looking fine, thanks David

          I'll close this issue once I notice that the emails are arriving regularly.

          Show
          Helen Foster added a comment - PHM cohort update notification email received and checked. Everything looking fine, thanks David I'll close this issue once I notice that the emails are arriving regularly.
          Hide
          Helen Foster added a comment -

          Just noting when I've received PHM emails: 11 Feb, 25 Feb, 1 Mar. Should they be arriving weekly or fortnightly?

          Show
          Helen Foster added a comment - Just noting when I've received PHM emails: 11 Feb, 25 Feb, 1 Mar. Should they be arriving weekly or fortnightly?
          Hide
          David Mudrak added a comment -

          Weekly. The one on Tuesday was ignited by myself manually IIRC, to make sure it works.

          Show
          David Mudrak added a comment - Weekly. The one on Tuesday was ignited by myself manually IIRC, to make sure it works.
          Hide
          Helen Foster added a comment -

          Just noting that I have not received a PHM email since 1 Mar.

          Show
          Helen Foster added a comment - Just noting that I have not received a PHM email since 1 Mar.
          Hide
          David Mudrak added a comment -

          It turned out that I was wrong. The script is currently scheduled to run monthly at the beginning of the month. Let me know Helen if that is ok for you or whether we should change it to the weekly (or any other) period.

          Show
          David Mudrak added a comment - It turned out that I was wrong. The script is currently scheduled to run monthly at the beginning of the month. Let me know Helen if that is ok for you or whether we should change it to the weekly (or any other) period.
          Hide
          Helen Foster added a comment -

          Monthly is OK I think. I will close this issue once I receive an email at the beginning of next month.

          Show
          Helen Foster added a comment - Monthly is OK I think. I will close this issue once I receive an email at the beginning of next month.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:

                Development