numbas / numbas-lti-provider

An LTI tool provider to run Numbas exams
https://docs.numbas.org.uk/lti/en/latest/
Other
11 stars 12 forks source link

Numbas LTI Provider uses time-zone of laptop #285

Open Spruce8913 opened 9 months ago

Spruce8913 commented 9 months ago

An international student recently arrived in Belgium (GMT +2). They adjusted their time on Windows laptop by manually adjusting the time, but leaving the timezone on Jakarta (GMT +7). When entering the (timed) Numbas exam, the following data is saved in Numbas LTI Provider: Sep 19, 2023, 4:43:17 AM |   | Moved to Question 1. |   |   Sep 19, 2023, 9:42:50 AM |   | Launched in normal mode by STUDENTS NAME.

Their attempt is immediately closed as it falls outside of the time window when this resource is available, or because their timer has run out of the attempt (not sure which). This issue was resolved when changing their time zone on their laptop. I think it's important Numbas LTI provider uses only server time (and time zone), as these settings can otherwise be used by students to ignore settings on resource availability or the timer per attempt.

christianp commented 9 months ago

Oh, this is annoying! Sorry about this - I thought we'd dealt with it. The timestamps should use UTC, so changing time zones shouldn't matter, but clearly that didn't happen in that case. I'll look into it.

christianp commented 9 months ago

Sorry, I've just re-read this and realised I misunderstood. The problem is that the laptop's time was incorrect, not that they changed time zone.

This is a really hard problem: within JavaScript, the only source of time we have reliable access to is the student's device's own clock. If the student's device loses the network connection during their attempt, it can't compare its time with the server's. So at the moment, only the device's clock is used.

We can't use a fixed difference between the student's time and the server's time, because their clock might change during the attempt, as in this case.

I suppose we can detect when the student's clock moves backwards, but a big jump forward might just be because the laptop was suspended for a while.

When the network connection is active, we could use a regular ping to check that the student's clock is close enough to the server's. I don't know what the right thing to do would be if they don't match, beyond showing a warning. We can't ask the server for the time each time a SCORM value is changed.

Related: #125

Spruce8913 commented 9 months ago

I don't know if the problem came across correctly: the current hours/minutes visible on the student's laptop were "correct". It's just that instead of changing their timezone, they manually had added 5 hours to their time. So their time was 9:42 (GMT+7) while it should have more sensibly been 9:42 (GMT+2). All testing with Numbas exam was happening within Belgium in one timezone (GMT+2). The student was connected to university wifi so stable and fast internet connection was guaranteed. The clock on the student's laptop did not change during the attempt (as in, if you looked at the time being displayed by Safe Exam Browser on bottom right, or just in Windows on bottom right, you could still see 09:42 as time).

What especially surprises me is that Numbas LTI provider saved a different time for launching the exam and for moving to a question, while the exact same time settings and current time were set on their laptop for both.