Quiz behavior after computer power failure

Quiz behavior after computer power failure

by Ricardo Caiado -
Number of replies: 24
Picture of Particularly helpful Moodlers
Scenario:

(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?
Average of ratings: -
In reply to Ricardo Caiado

Re: Quiz behavior after computer power failure

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Have you tried this on your own?

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.)
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: Quiz behavior after computer power failure

by Ricardo Caiado -
Picture of Particularly helpful Moodlers
Hi Ricky,

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
In reply to Rick Jerz

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Auto submission is based on the server clock, otherwise it would be possible for a candidate to manipulate the time.
In reply to Marcus Green

Re: Quiz behavior after computer power failure

by Ricardo Caiado -
Picture of Particularly helpful Moodlers
Hi, Marcus.

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
In reply to Ricardo Caiado

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"This is the post "
That was from 2013. Check out the comments over the years on this Topic by Tim Hunt, he really knows the code for this.
In reply to Marcus Green

Re: Quiz behavior after computer power failure

by Ricardo Caiado -
Picture of Particularly helpful Moodlers
Hi, Marcus.

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.
In reply to Ricardo Caiado

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"I found this post explaining that according to the logs the student did not access the summary page. Therefore, the attempts were submitted automatically:"
That is not my interpretation of that post nor my understanding of how automatic quiz submission works.

You can see detailed discussions of quiz autosubmit issues in the tracker with this search
In reply to Ricardo Caiado

Re: Quiz behavior after computer power failure

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

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:

  1. 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. 
  2. 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.)

Average of ratings: Useful (3)
In reply to Tim Hunt

Re: Quiz behavior after computer power failure

by Ricardo Caiado -
Picture of Particularly helpful Moodlers
Tim,

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
In reply to Ricardo Caiado

Re: Quiz behavior after computer power failure

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

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:

  1. 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.
  2. 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:

  1. Student restarts their computer - starts off thinking that it is 1 Jan 1970.
  2. 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.
  3. So, the quiz timer starts counting down towards 1970-01-01 00:57:00.
  4. A little bit later, the student' clock gets a time-signal an auto-corrects to some time in 2022.
  5. 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.


Average of ratings: Useful (5)
In reply to Tim Hunt

Re: Quiz behavior after computer power failure

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Wow, Tim. I appreciate your explanation. This is really cool and complex stuff happening.  Thanks for helping.

In reply to Rick Jerz

Re: Quiz behavior after computer power failure

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well, only cool up to the point where it incorrectly submits the student's quiz attempt. I created MDL-73960.
In reply to Tim Hunt

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
"Well, only cool up to the point ..."
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.
Average of ratings: Useful (3)
In reply to Tim Hunt

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Thanks for the feedback Tim, I have been working on some assignment auto-submit code and it it is heavily influenced by your quiz auto-submit code, It probably should be more influenced by it and I will get on and read through https://tracker.moodle.org/browse/MDL-71984

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
https://en.wikipedia.org/wiki/Unix_time

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.
Average of ratings: Useful (1)
In reply to Marcus Green

Re: Quiz behavior after computer power failure

by Ricardo Caiado -
Picture of Particularly helpful Moodlers
"The reason I am commenting on this is partly because I have been following this issue for over 10 years..."

I`ve seen posts dated 2013.

In reply to Marcus Green

Re: Quiz behavior after computer power failure

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Typically, " the significance of Jan 1 1970 is that" the clock battery on the motherboard of the computer in question is dead, and needs to be replaced. Know from experience of teaching in a computer lab for many years and having to replace many batteries.
Average of ratings: Useful (8)
In reply to AL Rachels

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Both my answer and Al's answers are correct, but Al's answer is far more useful in this context )
In reply to AL Rachels

Re: Quiz behavior after computer power failure

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

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 wink) 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.

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Quiz behavior after computer power failure

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I also had to keep a few replacement balls for the same reason. I eventually bought some software that let me live monitor what was on the screen of each student computer to try and watch for "pointers" that were not moving for long periods of time. The software gave me the added benefit of being able to watch for solitaire players.
Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Quiz behavior after computer power failure

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Perhaps the first major implementation of a "mouse" was by Apple, on its "Lisa" (which became the Macintosh) computer, in 1983. (Reference). I actually used a Lisa computer when I worked for the John Deere Corporate Headquarters, in Moline, Illinois.  This "Lisa" computer was the John Deere Technical Center (across town).  I was searching for "visual" project management software, and this Lisa had "MacProject" installed.  Yes, Apple didn't create the mouse idea, nor the "windows" idea, these were created by Xerox.  But Steve Jobs became enthralled with the concept and created his "Mac" based upon what he had seen.  I think Steve named this computer after one of his girlfriends, but perhaps when he broke up with her, he decided to rename it "Macintosh" for the Apples that were growing around him in his state.  Maybe others can tell the story better than I.

I type this reply on my MacBook Pro, 2021 version, which has a form of UNIX as its OS.  How times have changed???
In reply to Rick Jerz

Re: Quiz behavior after computer power failure

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers
Oops, Lisa was Steve's daughter, not his girlfriend. Oh well.
Average of ratings: Useful (1)
In reply to Rick Jerz

Re: Quiz behavior after computer power failure

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
There is quite a good biopic movie about his life. Great salesperson/marketer, not quite so good at being nice to people.
Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: Quiz behavior after computer power failure

by Eric Bryant -
We used to remove the mouse balls to annoy our co-workers. When LED mice came out, we'd cover the diode with a tiny Post-it note. Not as much fun to do these antics to my wife while working from home these past two years.