A function to delete quiz attempts?

A function to delete quiz attempts?

by v k -
Number of replies: 5

Dear friends,

All quiz attempts are stored in 'quiz_attempts' table.
Is there a function that deletes quiz attempts by IDs with full respect to Moodle's internal dependencies to avoid any errors? 

Something like I couldn't find by myself:

public static function DeleteQuizAttempts($IDs);
{
$IDs =[1, 7, 99]; //IDs of attempts for deleting
//Here goes the function code.
return true
}
Average of ratings: -
In reply to v k

Re: A function to delete quiz attempts?

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

Re: A function to delete quiz attempts?

by v k -

Thank you!

This really helped me.

In reply to Tim Hunt

Re: A function to delete quiz attempts?

by v k -

May I also ask...

I try to understand the process of deleting attempts when on '/mod/quiz/report.php':


  1. Inspect '/mod/quiz/report.php' code in NetBiens - no mention of 'quiz_delete_attempt' found;
  2. On  '/mod/quiz/report.php' we can check or select all attempts in the bottom table and then press 'Delete selected attempts'. I understand that by clicking that button we call for a function ('quiz_delete_attempts'??) with giving it an array of chosen attempts: but how this array is formed? Where is the code which matches the IDs of attempts with what I checkbox in that table?

In reply to v k

Re: A function to delete quiz attempts?

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

Read mod/quiz/report.php more carefully. You will see that it is just a wrapper. It loads one of the classes like mod/quiz/report/overview/report.php, then calls one of the methods to do the actual work.

And, for that report, the report classes uses mod/quiz/report/attemptsreport.php to do a lot of the work.

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

Re: A function to delete quiz attempts?

by v k -

Once again, thank you!!!