Recurring Date Range

Re: Recurring Date Range

by Mark Whitington -
Number of replies: 2
Thanks Mark,
I am sure a few of us are looking at the new possibilities but not sure how to use them.
Cheers
Mark
In reply to Mark Whitington

Re: Recurring Date Range

by Alexander Bias -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hi Mark (Whitington),

I am the one who contributed the date range element type to this plugin. In fact, the code was written and contributed by Catalyst IT, but the specs came from me at Ulm University. This why Mark (Nelson) asked me to add my thoughts to this thread.

The goal of this element type was to have a possibility to map a date item of the certificate (in our case: the current date, but you can use any other date item as data source) to a string representing a date range where the date lies within (in our case: the lecture term when the certificate was generated).

Within our certificates at UUlm, we have a date range field which is configured with two date ranges.
The first date range represents the summer term and the second date range represents the winter term. 

We are using the recurring_range_* placeholders to realize this. These placeholders do not directly use the year of the configured date range, they do assume that the date range is repeated every year.

Please see the attached screenshot for details.
Based on our example in the screenshot, this happens:

1. If the certificate is generated between the 1st april and the 30th september, the first date range will be picked.
If the certificate is generated between the 1st october and the 31st march, the second date range will be picked.

2. The recurring_range_* placeholders ignore the particular configured years more or less but shift the date range into the year of the given date instead.
Thus, if the certificate is generated in the year 2020, the {{recurring_range_first_year}} placeholder will be 2020 and the {{recurring_range_last_year}} will be 2021.

3. For example, if the certificate is generated today, the string will say "Sommersemester 2020". If it is generated in November this year, the string will say "Wintersemester 2020/2021".

This way, we can realize a mapping between each day of the year (when the certificate is generated) to the particular lecture term including its particular year.


I admit that this recurring_range_* functionality is somehow special. But we also built other, more standard placeholders for the sake of completeness into the date range item. And it was important to us to push this feature upstream to Mark.

If you want to know more and are able to read PHPUnit test code, you could have a look at https://github.com/mdjnelson/moodle-mod_customcert/blob/MOODLE_38_STABLE/element/daterange/tests/element_test.php where the placeholders are tested and their functionality might become somehow more clearer.

Cheers,
Alex
Average of ratings: Useful (1)
In reply to Alexander Bias

Re: Recurring Date Range

by Mark Whitington -

Thank you Alexander,

Great explanation... and just what I need smile

Cheers

Mark