Deleted quiz attempt - can I find the data in current database somehow?

Deleted quiz attempt - can I find the data in current database somehow?

by Susan Mangan -
Number of replies: 7

Hi, running Moodle v.3.3.9

An instructor deleted a quiz attempt approximately 2 hours after the student completed it.  The results will not have been backed up otherwise we could restore the backup and retrieve the deleted attempt that way.

Is there a way to retrieve the data directly from the current database somehow?  For example, does a Quiz attempts history table or something similar exist?

TIA!

Average of ratings: -
In reply to Susan Mangan

Re: Deleted quiz attempt - can I find the data in current database somehow?

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

Sorry, no. If you ask Moodle to delete a quiz attempt (and click confirm in the pop-up) then it will.

In reply to Tim Hunt

Re: Deleted quiz attempt - can I find the data in current database somehow?

by Susan Mangan -

Thanks.

We showed the instructor the logs and she swears she never deleted the attempt.  She's a long time user and very proficient in Moodle so I have a hard time believing she actually clicked the checkbox next to the student's name, scrolled down and clicked Delete attempt and then proceeded to confirm via a pop-up.

But the logs show she deleted it.... can't argue with the logs I suppose?

I did find a very odd entry right before the deleted log entry though.

"Quiz attempt abandoned" I've never seen this entry before. We are running v.3.3.9  Any chance this is related?

11/03/19, 20:50 Teacher Name Student Name Quiz: Quiz 3 (IRAC) (02) Quiz Quiz attempt deleted The user with id 'teacherid' deleted the attempt with id 'attemptid' belonging to the quiz with course module id 'coursemodid' for the user with id 'studentid'. web IP
11/03/19, 19:42 Admin User Student Name Quiz: Quiz 3 (IRAC) (02) Quiz Quiz attempt abandoned The user with id 'studentid' has had their attempt with id 'attemptid' marked as abandoned for the quiz with course module id 'coursemodid'. cli  

 

It looks like all of the students who took the quiz went over the time limit and the quiz was auto submitted but for some reason hers is the only one that shows as being "abandoned".

In reply to Susan Mangan

Re: Deleted quiz attempt - can I find the data in current database somehow?

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, what happens when time expires is controlled by the "When time expires.." quiz setting. https://docs.moodle.org/34/en/Quiz_settings#Timing

I can only assume that for this quiz, it is (or was) set to "Attempts must be submitted before time expires, or they are not counted". If it is set to that, and time ends, and the on-screen count-down timer does not automatically submit the attempt while the student is working on it, then the attempt goes to the 'Abandoned' state, which is show in places like the quiz reports as 'Never submitted'.

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

Re: Deleted quiz attempt - can I find the data in current database somehow?

by Susan Mangan -

Thanks for this info. I confirmed with the teacher that in an attempt to give the student more time on the quiz, she was in fact playing with those settings when the student's attempt ended/or was about to end.

So that explains the "abandoned" log entry.

I still don't understand the deleted attempt entry though.  Does Moodle automatically delete abandoned attempts and log them as being deleted by the teacher?

The teacher had also created an override for some students (including this one) and for some reason she deleted this student's override the following day.  At first we thought this action could caused the attempt to be deleted but since the logs show that the deleted attempt happened shortly after the abandoned log entry on the same day of the quiz where the deleted override happened the day after, it would seem unlikely.

In reply to Susan Mangan

Re: Deleted quiz attempt - can I find the data in current database somehow?

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

I just checked: apart from the automated built in tests, the only place that log entry is created is in the quiz_delete_attempt function, and the only place that function is called is from the quiz reports. So, it really has to be user action to generate that log entry.

In reply to Tim Hunt

Re: Deleted quiz attempt - can I find the data in current database somehow?

by Susan Mangan -

Thank you so much for looking into this for us Tim.  I really appreciate getting clarity around this as it's sometimes difficult to know what's really going on in the bowels of the system and how to respond to Teachers when this happens.

One last question (hopefully smile)

I'm pretty proficient with Moodle and somewhat proficient with the "bowels" of Moodle.  If I wanted to help myself to better understand the mechanics around how the logs are generated, and corresponding functions, are there specific php files that I would look for?  Would there be a file for each individual component? 

This might  be a good idea for the next Moodle certification course:

"Advanced Moodle Admin. Troubleshooting 101:  Learn all about the mechanics of what makes Moodle tick.  Get inside Moodle's bowels and learn how to perform a simple colonoscopy." big grin tongueout

In reply to Susan Mangan

Re: Deleted quiz attempt - can I find the data in current database somehow?

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

The way log entries are generated is via the event API. Code will create an event with the data to log, then 'trigger' it to cause the log entry to be created. Docs are here, but the are a bit verbose. https://docs.moodle.org/dev/Event_2. The helpful thing to know is that the even classes will always be in places like .../classes/event/event_name.php throughout the Moodle code. So, for example mod/quiz/classes/event/attempt_deleted.php. Then you can search the code for places where that event class is referred to, like https://github.com/moodle/moodle/blob/0e1e1e5586a1f43c951d9a399243220a3ccf882c/mod/quiz/locallib.php#L436.

Hopefully it is clear how what is defined in that class relates to what is written to mdl_logstore_standard_log. 

(LOL at the proposed course title.)

Average of ratings: Useful (2)