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

New hook 'after_require_login'

XMLWordPrintable

    • MOODLE_31_STABLE, MOODLE_32_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE
    • MOODLE_37_STABLE
    • Hide

      Requirements:

      1. A site with some courses, activities and users. Ability to install a plugin (by downloading and copying it to the correct folder).
      1. Install this plagiarism plugin: https://github.com/stronk7/moodle-plagiarism_dummypla into plagiarism/dummypla. You can do it using git or easier, just download the attached dummypla.zip file and unzip it in the plagiarism directory.
      2. In your site, go to the admin page, so upgrade will happen, verify that the dummypla plagiarism plugin in going to be installed.

      AS REGULAR USER

      1. Log is as student or teacher.
      2. Then in any course, visit various activities (say forum, glossary...).
      3. Verify that In all activity pages you see a notification with text "'after_require_login @ plagiarism_dummypla intercepted this MODULE page!" (where MODULE = activity type, aka, forum, glossary...).
      4. Verify that other pages (course page, admin pages), don't show that notification. Only activity ones do.

      AS ADMIN (same results than with regular users):

      1. Log is as admin.
      2. Verify that In all activity pages you see a notification with text "'after_require_login @ plagiarism_dummypla intercepted this MODULE page!" (where MODULE = activity type, aka, forum, glossary...).
      3. Verify that other pages (course page, admin pages), don't show that notification. Only activity ones do.

      That's all, the hook is working!

      Show
      Requirements: A site with some courses, activities and users. Ability to install a plugin (by downloading and copying it to the correct folder). Install this plagiarism plugin: https://github.com/stronk7/moodle-plagiarism_dummypla into plagiarism/dummypla . You can do it using git or easier, just download the attached dummypla.zip file and unzip it in the plagiarism directory. In your site, go to the admin page, so upgrade will happen, verify that the dummypla plagiarism plugin in going to be installed. AS REGULAR USER Log is as student or teacher. Then in any course, visit various activities (say forum, glossary...). Verify that In all activity pages you see a notification with text "'after_require_login @ plagiarism_dummypla intercepted this MODULE page!" (where MODULE = activity type, aka, forum, glossary...). Verify that other pages (course page, admin pages), don't show that notification. Only activity ones do. AS ADMIN (same results than with regular users): Log is as admin. Verify that In all activity pages you see a notification with text "'after_require_login @ plagiarism_dummypla intercepted this MODULE page!" (where MODULE = activity type, aka, forum, glossary...). Verify that other pages (course page, admin pages), don't show that notification. Only activity ones do. That's all, the hook is working!

      We would like to introduce a hook that will be executed before the end of the require_login function.

      'after_require_login' will allow you it intercept the page request and potentially redirect elsewhere, or perform any business logic.

      This enables whole classes of features to be added by plugins cleanly. Some use cases where we have wanted this and hacked around it in the past:

      • replacing the sitepolicy feature with a more robust / advanced version
      • augmenting the 'user fully setup' workflow to add more steps but outside their profile editing page
      • adding extra layers of checks, eg an ip address check but doing this across whole courses instead of at the sitelevel which is too coarse, or at the activity level which is too fine.
      • enforcing various types of course visibility dependencies, eg 'before you can do course X you need to complete course Y'

       

        1. dummypla.zip
          0.2 kB
        2. MDL-60470.jpg
          MDL-60470.jpg
          44 kB

            brendanheywood Brendan Heywood
            nhoobin Nicholas Hoobin
            Brendan Heywood Brendan Heywood
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Anna Carissa Sadia Anna Carissa Sadia
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 10 minutes
                2h 10m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.