Restriction by relative date

Availability conditions ::: availability_relativedate
Maintained by RenaatRenaat Debleu
Restrict module and section access based on a relative date.
Latest release:
319 sites
19 fans
Current versions available: 3

Relative dates will be experimental in Moodle 3.8. Until then we can restrict module and section access based on a relative date.

This availability condition makes it easy to show modules or sections only x days/weeks/months - after course start date - before course end date - after user enrolment date.

Check the global documentation about availability conditions :


  1. Unpack the zip file into the availability/condition/ directory. A new directory will be created called relativedate.
  2. Go to Site administration > Notifications to complete the plugin installation.

travis  coverage


Screenshot #0
Screenshot #1


Renaat Debleu (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of João Pedro F.
    Mon, Sep 21, 2020, 10:47 PM
    Hello, first thanks for developing the plugin.
    I want to report a bug: access restrictions are being updated dynamically according to local time, no matter how much in the configuration of the restriction we have selected "based on the user's enrollment in the course".
  • Renaat
    Wed, Sep 23, 2020, 11:30 PM
    Hello João,

    please use the bug tracker to report a bug. Do not forget to add your Moodle and plugin version .

  • Picture of Diogenes Mata
    Sat, Nov 7, 2020, 12:11 AM
    Hello Renaat, I hope you are well.
    Install the latest version of the 3.8+ plugin (2020110200) in Moodle 3.9.2+, it does not take the relative dates from when the student enrolled in the course, but since the plugin was updated or by the server date.
    Similar to the bug that Joao Pedro mentioned earlier.
    Can you help me with this please.
  • Picture of faculdadeitaqua moodle
    Wed, Nov 11, 2020, 4:30 AM
    We are using the relative date plugin at our college.
    However after the update (the last two), a serious error started to occur.
    Every time the student enters moodle, the relative date is updated based on the time he last accessed moodle.
    Soon the student is never able to access the content with relative date.
    We structured our entire grid with this plugin, and now we have this problem after updating the plugin.
  • Renaat
    Wed, Nov 11, 2020, 4:45 AM
    Working on a fix.
  • Picture of Diogenes Mata
    Fri, Nov 13, 2020, 3:13 AM
    Hi faculdadeitaqua moodle.
    I had a similar problem in the version that was solved in version 3.8+ (2020111000).
    Do you have that version?
  • Picture of Antonio Dégas
    Fri, Nov 13, 2020, 11:02 PM

    Excellent plugin, congratulations !! How can I do to increase the number of days to more than 50, as this is the limit that can be selected in the plugin for days, weeks or months
  • Renaat
    Sat, Nov 14, 2020, 12:18 AM
    THX Antonio for your comments,

    You can change the form.js source file and rebuild the YUI modules. Or you can suggest a new number (100 - 365 - ?) in the bug tracker and wait until it is implemented for you. I opted for choices between 1 and 51 to cover 51 weeks and to make the dropdown not too long. Any suggestion is welcome.
  • Picture of Antonio Dégas
    Fri, Nov 20, 2020, 1:48 AM
    Thanks for the answer. Could you confirm for me: is it in the "moodle-availability_relativedate-form.js" file that I should edit? In this case, I must change the value 52 in the section "html + = '';
    for (i = 1; i <52; i ++) {
    html + = '' + i + ''; "??? Thank you, as I have urgency in this
  • Renaat
    Fri, Nov 20, 2020, 11:05 PM
    Hi Antonio, you can change the 52 in something else, but then you need to rebuild the YUI modules before it will appear in your platform, see
  • Picture of Antonio Dégas
    Sat, Nov 21, 2020, 2:46 AM
    tks so much
  • Picture of Armin Trommer
    Tue, Jan 5, 2021, 11:32 PM
    Hi Renaat. We are using your plugin in some courses where the users are enrolled via 2 enrolment methods. The restriction by date should refer to the original enrolment date, but it seems to take the latest date. Is this the way how it should work from your side or are there any plans to take the original enrolment date in a future version? Thanks a lot!
  • Renaat
    Wed, Jan 6, 2021, 3:05 AM
    Hi Armin,

    The functionality you used was reported as a bug in one of our projects, so the plugin was updated to take the most recent enrollment as a starting point. Luckily this project is Open Source, so you can create a fork and modify line 222 of the classes/condition.php file to "restore" this bug.


  • Picture of Jean-Roch Meurisse
    Mon, Feb 22, 2021, 5:31 PM
    Hi Renaat,
    Thanks for your plugin!
    Teachers in my university ask me the following question... Could relative dates be linked to completion of another activity?
  • Renaat
    Wed, Feb 24, 2021, 10:49 PM
    Hello Jean-Roch,

    THX for the feedback. You mean something like 3 days after completing quiz 4?
    Technically this seems possible to me. Although a lot of work would be needed to implement a cache for performance reasons.

    But for the moment I do not see a lot of extra value in this link to completion of another activity. Completing an activity would become more a punishment than a achievement....
    Can you provide some samples where this extra restriction could be used in a way students are encouraged instead of discouraged?

    Of course, currently you can already combine restrictions: Quiz 4 is completed AND 4 weeks after course start date.

1 2
Please login to post comments