(1) Quiz configured to automatically submit attempts, 10 questions
(2) Duration of the quiz: 3 hours, Start: February 19, 2022, 08:00 AM
(3) Student starts the quiz at 08:05 AM
(4) When accessing the fifth question, 2 hours after starting, there is a power failure and the computer turns off
(5) After turning on the computer the clock now reads January 1, 1970
Question: How will the quiz behave once the student accesses it again?
I could be wrong, but I believe that "time" is based upon the server's time, not the local computer time.
I had a student once take a two-hour timed exam, who reported to me that the "storm" knocked out his power in his home about 1 hour into the exam. He drove across town to his parent's home, logged in from their network, and continued his exam in Moodle. I confirmed his story by looking at Moodle's logs, including IP addresses. (No, no report of his compter's clock being reset to 1970, however.)
The scenario described above was what happened to a student today.
After restarting the computer and accessing the quiz, he verified that the attempts had been submitted for evaluation even though the time had not yet expired.
He could not inform what time was being shown on the computer clock.
But I found several old (2013) and current (2020) posts that relate this automatic submission before the end of the quiz with the computer clock.
Ricardo
This makes sense!
But look at this student's access log entries:
19/02/2022 09:22 The user with id '286811' has submitted the attempt with id '877892' for the quiz with course module id '390010'. <====
19/02/2022 09:18 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:17 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:12 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:08 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:06 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:05 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:05 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:04 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:02 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 09:02 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:56 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:55 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:53 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:51 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:42 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:36 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:33 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:32 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:32 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:28 The user with id '286811' has viewed the attempt with id '877892' belonging to the user with id '286811' for the quiz with course module id '390010'.
19/02/2022 08:28 The user with id '286811' has started the attempt with id '877892' for the quiz with course module id '390010'.
19/02/2022 08:24 The user with id '286811' viewed the 'quiz' activity with course module id '390010'.
According to the quiz settings, attempts will be submitted at 1:00 PM. However, the automatic submission took place at 09:22 AM. Notice that the summary page was not accessed.
This is the post that mentions that the problem would be associated with the computer clock: https://moodle.org/mod/forum/discuss.php?d=221961#p967743
Ricardo
That was from 2013. Check out the comments over the years on this Topic by Tim Hunt, he really knows the code for this.
I understand that this post is old, but the point here is that, even today, attempts were automatically submitted before the quiz closes. This behavior was not supposed to happen, as the automatic attempts submission should only occur at the end of the quiz.
I found this post explaining that according to the logs the student did not access the summary page. Therefore, the attempts were submitted automatically:
https://moodle.org/mod/forum/discuss.php?d=412083#p1694054
This is exactly what is happening with my student: automatic submission of attempts before the quiz closes.
That is not my interpretation of that post nor my understanding of how automatic quiz submission works.
You have not yet told us which Moodle version you are using. That is important information.
You say the power cut happened '2 hours' after the start of the student's attempt (which satrted at 08:05). However, looking at the times of the log entries, ... actually, I cannot make any sense of that. Do you actually have an accurate timeline of what happened which matches the logs?
Note (you too Marcus) that there are two ways that a quiz attempt can be automatically submitted:
- If the student does not have the the quiz open in their web browser when time expires, then (a minute or so later) a scheduled task running on the Moodle server submit the task (if that is what the quiz setting says should happen). In this case there won't be any log entries about viewing a page of the quiz just before it is submitted. You will just get the event to say the attempt was submitted by admin, or similar.
- If the student has the quiz attempt open in their browser, then then there is a second sort of auto-submit triggered by the JavaScript countdown timer. That happens irrespective of the quiz setting. (You can view it as the invigilator/proctor saying "stop writing now".) This is, to some extent, controlled by the clock on the student's computer (although the time will be double-checked on the server to ensure that students cannot cheat and gain more time). Even so, I don't see how it can cause the quiz to submit early.
In your description, you say "After turning on the computer the clock now reads January 1, 1970". What is 'the clock'? I cannot think fo any clock that woudl start showing January 1, 1970, just because a computer was restarted. Also, even if it did, that would not be after the time the quiz was supposed to finish.
So, basically, you have not yet given enough information to know what happened. If you can be more precise, we may be able to be more helpful. Marcus's suggestion that you try to re-produce what happened to the student is good advice to try to understand what happened.
(Note that, once MDL-71984 is out, the logging during quiz attempts will be better.)
Sorry for the lack of information.
(1) Moodle v3.11.4+, PostgreSQL 12, PHP 7.4, Ubuntu 20.04
(2) The power cut happened 09:18AM
(3) "... What is 'the clock'? ..." = student computer clock
(4) "... I cannot think fo any clock that woudl start showing January 1, 1970, just because a computer was restarted ..." : CMOS battery failure
Ricardo
OK, I think I worked out how the quiz came to be auto-submitted.
First we need to think about what the students computer will do. Because of the CMOS issue, it powered on thinking the time was 1 Jan 1970 (Unix epoch 0), but then at some point, the computer's OS will have got an internet connection, made contact with a time server, and eventually discovered the right time, and automatically reset the clock.
Now, as previously alluded to, the issue the Moodle code has to solve how to do timing stuff in the student's web browser, where the clock might be different to the clock on the server, and when it takes a non-zero time to send data across the internet from Moodle to the browser. (Also, we want to make it impossible for people to cheat the timing, but has has been said, that is mostly done by enforcing the time limit on the server.
So actually, when we think about the purpose of the timing JavaScript that runs in the student's browser, it has two purposes:
- Deal with the mechanics of submitting the quiz attempt just before time runs out, so that the student can focus on answering the questions, and does not have to spend excessive amounts of time watching the clock, and rushing to the submit button in the last seconds.
- And, to give an informative display of the time remaining, so that the students can see how much time remains when they want to check.
Anyway, to make the timer work the information the server sends to the browser is how many seconds of time remain. Then, the JavaScript adds that many seconds to the current time, to work out what the end-time is in terms of the clock on the student's computer. Then it counts down to that. However, that goes wrong in this case. What happens is:
- Student restarts their computer - starts off thinking that it is 1 Jan 1970.
- They quickly go back to Moodle, log in, and continue their quiz attempt. Let us say that happens when their computer clock shows 1970-01-01 00:02:00, and at that time, they have 0:55:00 quiz time left.
- So, the quiz timer starts counting down towards 1970-01-01 00:57:00.
- A little bit later, the student' clock gets a time-signal an auto-corrects to some time in 2022.
- Well, that time in 2022 is later than 1970-01-01 00:57:00, so the quiz is submitted. (Remember, computers have no common sense.)
I guess it might be possible to add some sanity checks to the quiz timer code to avoid this - but we would have to do it in a way that does not allow cheating.
(P.S. for anyone who thinks this is easy, read https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b923ca. For example, it is tempting to think "the timer updates once per second, so can't we put in a check based on that?" but that is not true. If I am attempting a quiz on this laptop, and close the lid so it hibernates, and then open in again 5 minutes - or an hour or a week - later, then that much time will pass between between two timer updates.)
Also note that since Moodle 3.10, whenever the quiz does an autosave of some student responses, we synchronise the time between the client and the server (see MDL-58926) but that does not help here.
In my view it is both cool that you have worked so hard for so long over so many years to get this code to work as well as possible, and extra cool that you have worked through the logic of what might have happened in this particular situation.
And Ricardo, the significance of Jan 1 1970 is that is year/time zero in Unix date/time counting, and other ways that computers count time. Which is of course not very handy if actual history is your subject.
Apologies if I am telling you stuff you already know, otherwise, check this out
The reason I am commenting on this is partly because I have been following this issue for over 10 years and reading just about every comment on it. However Tim is the real expert by a wide margin.
I`ve seen posts dated 2013.
Hi AL!
Your anecdote reminds me of the 1990-2000s when we had a "computerized" language lab at university. Some bored students (not in my own classes, of course ) would extract the ball from the ball mouse at their station to play with it and did not return it to its lodging. I had a small surplus of extra balls at hand, just in case.