Restriction by relative date

Availability restriction ::: availability_relativedate
Maintained by RenaatRenaat Debleu
Restrict module and section access based on a relative date.
Latest release:
2024 sites
664 downloads
67 fans
Current versions available: 8

Relative dates are experimental since Moodle 3.8 but are only implemented in the Assignment activity and the Weekly course format. If you want to use relative dates in other parts of a course, you can use this plugin.

This availability condition makes it easy to show modules or sections only x minutes/hours/days/weeks/months

  • before/after course start date
  • before/after course end date
  • after user enrolment date
  • after enrolment method end date
  • after the completion of an activity

Using Restriction sets, it is easy to make a resource available for a limited relative time.

Check the global documentation about availability conditions : https://docs.moodle.org/en/Conditional_activities_settings

Installation:

  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.

Warning

This plugin is 100% open source and has NOT been tested in Moodle Workplace, Totara, or any other proprietary software system. As long as the latter do not reward plugin developers, you can use this plugin only in 100% open source environments.

github  coverage

 
 
 
 

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

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

Comments RSS

Show comments
  • Samuel Sánchez sanz
    ବୁଧ, 18 ଜାନୁଆରୀ 2023, 10:40 PM
    Hola.
    Antes de nada enhorabuena por su trabajo.
    Quería preguntar cómo puedo hacer la siguiente configuración:
    Tengo un curso que se abona mensualmente y cada mes se abre un cierto contenido,
    Lo que quería hacer es que si un alumno no abona una mensualidad no tenga acceso al contenido del mes que no ha abonado. No sé si me explique bien...
    Un saludo y gracias
  • Renaat
    ବୁଧ, 18 ଜାନୁଆରୀ 2023, 11:09 PM
    Hola Samuel,

    Tal vez el plugin https://moodle.org/plugins/availability_gwpayments es una solutión?
  • Gábor Zahemszky
    ମଙ୍ଗଳ, 7 ମାର୍ଚ୍ଚ 2023, 6:17 PM
    Hi!

    Is it possible to modify this plugin to be usable with the Auto Enroll plugin, to enroll "new" users to some mandatory courses?

    I mean, if the users createDate (we got this attribute from AD) information is relative new (eg. in the last 30-60 day), he/she needs to enroll to course X.
    Now the plugin doesn't check this user attribute so we could not configure it.
  • Renaat
    ବୁଧ, 8 ମାର୍ଚ୍ଚ 2023, 9:47 AM
    Hello Gabor,

    this is an availability restriction plugin and not an enrollment plugin. If the auto enroll would add the correct start date from your AD, then this plugin let you restrict activities and section based on this start date.

    So you have to modify your auto enrol plugin.

    R

  • Gábor Zahemszky
    ବୁଧ, 8 ମାର୍ଚ୍ଚ 2023, 9:48 PM
    Hello, Renaat!

    I have to explain it smile

    The basics:

    I'd like to restrict something based on users first login into Moodle. Eg, in the first 30 days after his/her first login he/she can reach activity A, but after 30 days only activity B. Your plugin can do most of it, but we cannot check the first login date (I called it: createUser attribute), only the enrollment date.

    I think, the user's enrollment date of a course belongs to that user - and the first login date belongs to him/her, too. I mean, this two informations are not so different. So I think, it is possible to modify your plugin to check that information, too. And I think, it would not be so hard to do that modification.

    (And some words about enrollment. There is this plugin: AutoEnrol ( https://moodle.org/plugins/enrol_autoenrol ). It can automatically enroll users based on some criterias. And I can filter enrolling users using availability restrictions. So if your relative-date restriction plugin could check createUser date, I could enroll users based on their first login using these 2 plugins working together.)
  • Gábor Zahemszky
    ବୁଧ, 8 ମାର୍ଚ୍ଚ 2023, 9:55 PM
    (Small modification. In the user table, there is a field: timecreated - this is the information I'd like to check and called it: createDate. This name is the AD name of the same information.)
  • Renaat
    ବୁଧ, 8 ମାର୍ଚ୍ଚ 2023, 10:50 PM
    Hello Gabor,

    feature requests are made on GitHub (https://github.com/ewallah/moodle-availability_relativedate/issues).

    We tried already to implement that feature. But it was not working as expected. We tried out to hide an activity 5 minutes after first login. But It is never clear when this first access is set in the database.

    It did work when the user logged in - logged out and logged back in, or when the user accessed an activity, then the restriction worked as expected. But when the user did nothing during the first 5 minutes, the first access field was not yet set, so the restriction did not work.

    When features are not working as expected in all situations, it is better to drop the idea.

    R
  • Daniel Ciccone
    ବୁଧ, 14 ଜୁନ 2023, 1:10 AM
    Is there any way to make it send a message by moodle and by mail to the user when an activity is available at the end of the relative date restriction?
  • Renaat
    ବୁଧ, 14 ଜୁନ 2023, 5:57 PM
    Technically this is possible, but it would involve a lot of computing power: calculating every minute all restrictions for all users in every course to check if the end of the relative date restriction is reached or not.

    How would you handle combined restrictions (group = group1 AND 3 days before end of course)?

    And what happens if a course/section/module is unhidden, then the availability changes, so on that moment everything has to be recalculated again.

    So my answer is no, your problem should be revolved for every access restriction available in Moodle, and the huge amount of calculations and energy needed, makes it highly improbable it will ever be implemented or even work.
  • Bertrand Coquerelle
    ସୋମ, 3 ଜୁନ 2024, 10:15 PM
    Hello,

    - after enrolment method end date
    - after the completion of an activity

    I have moodle version 3.9

    So bad
    I can't see
  • Renaat
    ସୋମ, 3 ଜୁନ 2024, 10:42 PM
    You cannot see "after enrolment method end date" because your enrolment has no end date configured (4 days after 0 will never happen) .
    You cannot see "after completion of an activity" because you did not enable completion tracking in your course (or site)
  • Çağrı Akkaya
    ଶୁକ୍ର, 3 ଅକ୍ଟୋବର 2025, 6:54 PM
    How can I ensure that if a user doesn't complete a module within the training, the second module will be unlocked after a certain period of time? If the user I need takes an exam and doesn't receive a passing grade, the exam will not be completed. The second exam requirement is that the user took the first exam but didn't receive a passing grade, and I want it to be unlocked one month later. I've configured the first exam to be incomplete because they didn't receive a passing grade. Can such a feature be added?
  • Renaat
    ଶୁକ୍ର, 3 ଅକ୍ଟୋବର 2025, 10:48 PM
    For a human being, it is easy to understand a sentence like: "two hours after my teacher did not show up". For a computer or a Moodle instance, this is far more difficult. Things that do not happen, are not recorded or do not have logs.

    So I would add 2 availability restrictions, one on the grade (smaller than passing grade) combined with a date or relative date depending on the start of the course. How do you configure the availability of your first exam?
  • Çağrı Akkaya
    ସୋମ, 6 ଅକ୍ଟୋବର 2025, 7:22 AM
    Thanks for the reply. I realized I was a bit confused. What I actually need is to take into account the date the user took the first exam. I want the second exam to open a specified time after the user's first exam start date. In addition to the second exam requirement, I'll add a "fail to pass" condition. This way, if the user fails the first exam, the second exam will open a month later. If the user passes the first exam, the second exam won't open.
  • Renaat
    ମଙ୍ଗଳ, 7 ଅକ୍ଟୋବର 2025, 9:48 PM
    When you enable activity completion and configure the completion of your first exam to "Receive a grade" with "Any grade", then you should be able to configure your second exam with 2 restrictions: Grade lower than 50% AND 1 month after completion of Exam 1.
    As a result only people who do not pass the first exam will have access to the second exam, the others will not.
1 2 3 4
Please login to post comments