michael-milette / moodle-filter_filtercodes

FilterCodes filter for Moodle enables content creators to easily customize and personalize course and site content using plain text tags (no HTML). For premium support, contact us at https://www.tngconsulting.ca/contact
https://moodle.org/plugins/filter_filtercodes
GNU General Public License v3.0
30 stars 42 forks source link

Feature Request: If between dates function #281

Closed davefoord closed 6 months ago

davefoord commented 7 months ago

Prerequisites

Feature Request - The User Story

Would it be possible to add in a filter code to display something if it falls between 2 date/time codes?

I am thinking along the lines of something like {ifbetweenXXXXX_YYYYY}{/ifbetween} where XXXXX is the start time code and YYYYY is the end time code (unix).

I have been asked to create a manual exam countdown timer, showing the number of weeks (starting at 20) until an exam, and although I could do this by creating 20 separate labels and using restriction access to show the right label to the right group at the right time, this would be quite messy - whereas with filter codes I could have one single label that contains the information and uses the filtercodes to show the right number of weeks. I would use Exel to generate the required html that I need to acheive this.

I cannot use the students enrolment dates, as they enrol onto the course at different times, and I cannot use the course end date, as the course is open ended with students constantly coming in and out - but they are organised into groups based on the date of the exam they are signed up for.

Screenshots / Mock-ups

No response

Alterative you have considered

No response

Additional information

If necessary, I do have a small budget to contribute towards this.

Planning on submitting a solution in a pull request (PR)?

Yes

Code of Conduct

michael-milette commented 7 months ago

Hi @davefoord ,

I am not sure I am clear on what you are asking for.

Are your groups named something like 1699747200000_1704067200000?

If so, would you be using the {mygroups} tag to get the name of the group - e.g., {ifbetween {mygroups}}Content{/ifbetween}?

Please provide additional details on how you see this working.

Best regards,

Michael

davefoord commented 7 months ago

Hi Michael, ignore the bit about groups - that is me just confusing the situation.My idea is that the message that someone sees, actively changes as the time changes. Eg it initially says ‘you have 20 weeks until your exam’ but when the clock ticks over, the same message changes to say ‘you have 19 weeks until your exam’ - I would put the numbers 20 and 19 in between the tags.Dave

michael-milette commented 7 months ago

Hi Dave,

I am still not getting it.

The 19 or 20 would be relative to what? If you could provide a more complete example, it might help me better understand your vision..

Michael

davefoord commented 7 months ago

Hi Michael, apologies for me not being clear. The 19 and 20 wouldn't be relative to anything, I would manually work our the desired time codes, and enter them in manually.

e.g. If I had an exam date that was at the end of January, I would add something like this into a text and media area (label).

You have {iftimebetween1704067200_1704672000}4{/iftimebetween}{iftimebetween1704672000_1705276800}3{/iftimebetween}{iftimebetween1705276800_1705881600}2{/iftimebetween} weeks until your exam!

The time codes in the first filter are for 1st January 2024 and 8th January 2024 - so during that week, the message would show 'You have 4 weeks until your exam!', the time codes in the second filter are for 8th January 2024 and 15th January 2024, so during that week the message would show as 'You have 3 weeks until your exam!' etc.

I assumed that using unix timecodes would be the easier to programme, but from a user perspective, if it wasn't too difficult to programme, then something like:

You have {ifdatebetween010124_080124}4{/ifdatebetween}{ifdatebetween080124_150124}3{/ifdatebetween}{ifdatebetween150124_220124}2{/ifdatebetween} weeks until your exam!

Would be easier for an end user to use, as they wouldn't have to look up the desired time codes.

Does this make sense?

michael-milette commented 6 months ago

Hi @davefoord

Thanks for the feedback. I think I understand. Would something like this work?

You have {ifdatebetween 20240101 20240801}4{/ifdatebetween}{ifdatebetween 20240801 20241501}3{/ifdatebetween}{ifdatebetween20241501 20242201}2{/ifdatebetween} weeks until your exam!

Alternatively, I was also thinking about something as simple as:

You have {countdown 20242202} until your exam!

{countdown YYYYMMDD} would display the number of months, weeks, days until the date.

This could even be taken a little further:

{countdown YYYYMMDD HH:MM} would display the number of months, weeks, days as well as the hours, minutes and seconds until the date - live!

I haven't thought this through completely as there might be some accessibility issues with a live countdown timers.

Thoughts?

By the way, if you are in a hurry for this, please feel free to contact me through my website for premium service at https://www.tngconsulting.ca/contact

Best regards,

Michael

davefoord commented 6 months ago

Hi Michael - yes, I like all of the above a lot.

In terms of accessibility of a live countdown timer - if the timer was counting down and displaying the number of minutes live (e.g. the page was effectively refreshing) then I expect this would have an accessibility issue, as screen reader users would probably 'lose' their place each time the screen refreshed.

If however, the countdown timer calculated on page load and then remained the same until the page was manually refreshed by the user, then I would expect that to be OK.

If you do add the HH:MM element in, we would need to set it so that the person adding the code can specify the time in the day that the exam or whatever is taking place (as unlikely to be exactly at midnight) - but there is then the problem of people in different time zones - would the system use the timezone of the server, or the user adding the item? We do have a similar issue with the dates, but I think this is less problematic - as if it gets down to the point of there being 1 day or 0 days left then hopefully the user is on the ball enough to work out exactly what time something is happening.

So in summary - I would personally find the if datebetween item useful, and the basic countdown item useful, but the more advance countdown timer would be less useful for me.

michael-milette commented 6 months ago

My concern with a javascript-based the countdown is that a screenreader might continuously try to read the change on the page. But I am not sure about it. Anyway, the time parameter would be optional.

As far as creating the tag, the date (and time) would need to be entered in the Moodle site's timezone. If there is no time, the default would be 0:00 (12:00 AM). That way, Moodle would be able to display the information in the user's selected timezone... assuming their timezone was set correctly.

michael-milette commented 5 months ago

Hey Dave,

Just thought of a problem with my {countdown} tag. What do you think should happen when you get past the date? Should it start counting negative days?

Michael

davefoord commented 5 months ago

Hi Michael - yes a very good question, and I am not sure what would be best option. I wouldn't go for negative counting - that could be confusing, and if someone doesn't see the minus sign may think they have 5 days to go, when in fact 5 days late.

Could you have it so that it displays nothing at all once the date has passed? or have it just sticking on 00:00:00 or similar

michael-milette commented 5 months ago

Hi Dave,

I can do that for sure. However, if I went to a page and saw a message that said "Final exam in 0 days!", I might assume that the final exam was today... but it might have been 5 days ago.

As for displaying nothing, the same sentence would end up saying "Final exam in days!" which would not convey the correct message either.

I am now leaning back towards your original idea of creating a set of {if...}...{/if...} tags, perhaps in combination with the {countdown} tag.