Jefferson49 / Joomla_plugin_sexypolling_reloaded

Migration of the joomla plugin "Sexy Polling" to joomla 4.x
GNU General Public License v3.0
2 stars 3 forks source link

Warning message about start time of vote shows wrong time delta until vote will start #93

Closed Jefferson49 closed 5 months ago

Jefferson49 commented 5 months ago

Observed with v5.0.4.0 and Joomla 3.10.12

Issue was reported in the discussion of #90 Related screenshot: wrong rest time for vote

Jefferson49 commented 5 months ago

Potential root cause: JavaScript for warning message does not use timezone for date calcluation; instead uses UTC.

gnutello commented 5 months ago

The main problem is not just that the pop-up incorrectly displays the number of hours left until voting begins, the problem is that voting will begin right after the incorrect number of hours the pop-up indicates. So I'm having this problem: if I inform users that they have 24 hours to vote and the elections are scheduled from 00:00 am to 12:00 pm, they will find the polls still closed at 00:00 (they will find the polls open from 01:00 am). Also they will find the polls open until 00:59:59 am on next day. I'm experiencing a 1 hour skew (I think due to my UTC+1 time zone).

Jefferson49 commented 5 months ago

I spent some thought on this issue. The background for the behavior is that start_date and end_date are saved as date only (i.e. without a specific time and timezone). If the value is used for calculations, Sexypolling loads the date from the database, but does not know the time or timezone. Therefore, "UTC" is assumed as timezone. If you operate in a different timezone, you experience the delays

In order to change this behavior, I see the following approaches:

  1. Change the datatype for start_date/end_date from "date" to "datetime" (e.g. "2024-03-20 19:11:21")
  2. Save the timezone (as string) to a different (new) database value
  3. Save the timezone offset (in hours) to a different (new) database value

1.) looks straight forward. However, it would need to migrate existing databases to the new datatype. Therefore, I am hesitating. Also, I am not sure if the users wants to specifiy the time additionally to the date.

2.) and 3.) would also need a change of the database to introduce a new value. However, migration would be simpler and with less risk.

For 2.) and 3.), the timezone values could be shown as settings. Maybe, an offset (-12 to +12 hours) would be easier in handling than a timezone string.

What is your opinion?

Jefferson49 commented 5 months ago

Another option would be to change the calculation for the warning message only. This could be done by considering the time offset between the user timezone and the UTC timezone of the start_date/end_date. The actual start_date/end_date would stay with UTC.

Indeed, the proposals above could only specify one single timezone of the start_date/end_date (chosen by the administrator). If the user operates in a different timezone, the votes will not start at midnight etc. anyway. And probably, the start time should not vary between users and their timezones.

gnutello commented 5 months ago

Change the datatype for start_date/end_date from "date" to "datetime" (e.g. "2024-03-20 19:11:21")

In my opinion this solution would be perfect. For me this would make sexypolling much more flexyble and would keep the votations safe from possible complains. But my opinion is one of a simply user that manage sexypolling in a university environment where the risks of disputes are a bit probable. I'm not a programmer and i don't know about the difficulties to develop something like that.

If the user operates in a different timezone, the votes will not start at midnight etc. anyway.

Yes this is clear, and I understand that sexypolling must be a tool also and mostly for users spread on different UTC timezones. Anyway I think that when somone organize a votation like that and where the start/end time needs to be a must, comes natural to indicate to the users the timezone start/ends of the polls. Nobody knows better than you about the features that a polling tool should have and if you have some doubt about the possibility to specify the time additionally to the date may be you are right.

Jefferson49 commented 5 months ago

I decided to introduce a configuration setting in the configuration and also adopted the calculation of the warning message. With my test data this works successful.

configuration time zone

Maybe, you want to test with the latest changes: Download file deleted

gnutello commented 5 months ago

Hi, thank you very much for the modified component. Is this version for J.5 / J.4? Because when I try to install I get an error. Unfortunately the site where I have to manage Sexy polling is in joomla 3

Jefferson49 commented 5 months ago

Hi, thank you very much for the modified component. Is this version for J.5 / J.4? Because when I try to install I get an error. Unfortunately the site where I have to manage Sexy polling is in joomla 3

You are right. Sorry for attaching a Joomla 4/5 version. Find enclosed a test version for Joomla 3: com_sexypolling_v5.0.4.0_e97e88c9.zip

gnutello commented 5 months ago

Works fine!!! The alert message shows the correct amout of remaining hours and minutes. I will definitively confirm you only after the midnight of my local time. I'll give you news later. Thanks!

gnutello commented 5 months ago

Good news! To test I set the polls to open for tomorrow and I used the time zone of an area of the world close to midnight and I can confirm that it works perfectly. Thank you very much!!!

Jefferson49 commented 5 months ago

Thank you for testing and the very good discussion! I plan to release a new version today.