Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-63508

user_enrolment_* events firing before teachers are given role

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 3.4.3, 3.5
    • Fix Version/s: None
    • Component/s: Blocks, Enrolments
    • Labels:
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE

      Description

      In my plugin we listen to the user_enrolment_* events so we can sync Moodle users to our service when an enrollment is created, updated, or deleted. 

      It looks like these events are firing before the role is given to the user in the course context and that is causing teachers to initially sync as students in our service. We check to see if the user has a creator(teacher) capability during the enrollment event, and by the time our sync code fires the user does not have this capability in the course context so they are being assigned a viewer(student) role instead.

       

      We assign this capability to the teacher role before enrollment happens so I'm not sure what can be done on the plug in side to fix this behavior, I would expect when the enrollment event fires the below code should find the capabilities in the context of the course they were enrolled in:

      $canprovisionaspublisher = has_capability('block/panopto:provision_aspublisher', $context, $userid);
      $canprovisionasteacher = has_capability('block/panopto:provision_asteacher', $context, $userid);

      I expect this to happen on all version of Moodle, I believe customers experiencing this are using different versions. 

       

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jmalmsten joseph malmsten
              Participants:
              Component watchers:
              Adrian Greeve, Mihail Geshoski, Peter Dias, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: