Deleting Previous Attempts on Quizzes

Deleting Previous Attempts on Quizzes

by Erin Moran -
Number of replies: 18

Is there a way to delete previous attempts on a quiz? I use Moodle as a course page for teaching and assess students using the quiz module.  I would like to use the same quiz as last year but need to make changes (add/delete) to some questions for this year's group of students. However, since there are attempts on the quiz already, I am unable to do so. 


Other than retype the quiz, is there any way to make this change? Thank you!

Average of ratings: -
In reply to Erin Moran

Re: Deleting Previous Attempts on Quizzes

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

There are various options:

1. In the course settings, you should see a 'Course reset' features. This will let you delete all the quiz attempts in your course easily, so use with care.

2. If you go to the quiz reports, you can selectively delete quiz attempts.

3. You can decide you want to keep last year's course as a record, and so rename it to a name like "My course 2011", then make a backup without user data, and restore it as a new course called "My course 2012".

In reply to Tim Hunt

Re: Deleting Previous Attempts on Quizzes

by Angela Johnson -

Hi,

 I have to provide online training for this month of Sept. In preparing, I would like to repeat the same training from last year. I have the power point slides that I want to re add and the quiz as well. The problem comes where I am still seeing the individuals that took the training last year quiz attempts showing.

I am trying to figure out how to add this years training without it showing last year attempts.

I need step by step instructions and I want to be able to still have access to the individuals grades from last year.

In reply to Angela Johnson

Re: Deleting Previous Attempts on Quizzes

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

If you still need the grades from last year, just backup the course and restore to a new section without userdata, effectively making a fresh course for the new year.  That would be the cleanest way.

In reply to Emma Richardson

Re: Deleting Previous Attempts on Quizzes

by Blair F. -
Picture of Particularly helpful Moodlers

I wish it were that easy, Emma, but we never do anything the easy way! LOL  In this particular scenario, we have One shell that acts as the program shell, contains ALL of the students in 3 different levels from 5 or more intakes.  What happens is, a student fails level 1 and comes back next term.  The instructor has to go and manually delete each of that student's attempts so they can re-do them all.  The instructors are not happy that they have to do this manually. I was able to write an ad-hoc sql report that would show each attempt for a particular student as a record. At least then the instructor has a list of what they have to delete. But I wanted to take it one step further and try to include code in the report that would delete each attempt if clicked (I've done this before for reports that just list course shells in each record), but I was not able to find the code to make that happen.  That's why I chimed in, here.  It seems that I won't be able to do what I originally intended, but I'm still hoping to find something that makes it easier for the instructors.

Thanks for your input!

In reply to Tim Hunt

Re: Deleting Previous Attempts on Quizzes

by Blair F. -
Picture of Particularly helpful Moodlers

Tim, are you aware of anyway to "reset" a particular student and delete all quiz attempts within a single course? 

I've tried unenroling the student and then reenrolling the student and NOT restoring grades, but that had no affect on their quiz attempts which still show up, even when they remain unenrolled.

I tried changing the role of the student and then resetting the course and unenrolling only users in that particular role.  I didn't expect that to work, and it didn't, but I had to try.  smile

Why do I want this? We have a department that uses only one shell for everything in 3 levels of the program.  Often, students have to repeat a level and they want to be able to blow away that student's previous attempts on everything in that level, without having to do it on each individual item.   So far, I haven't found a way to accomplish this.  I thought maybe I could write an SQL report, with a delete link (like the one below, which I added to a list of courses that meet a certain criteria), but I couldn't find the 'delete attempt' code to add to the SQL output.

I hope all of that is clear.

concat('<a target="_new" href="%%WWWROOT%%/course/',CHAR(100,101,108,101,116,101),'.php',CHAR(63),'id=',id,'">X</a>') AS Remove
Average of ratings: Useful (1)
In reply to Blair F.

Re: Deleting Previous Attempts on Quizzes

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 think you would need PHP code to do this. There is a quiz_delete_attempt function that you can call with a given quiz attempt you want to delete.

In reply to Tim Hunt

Re: Deleting Previous Attempts on Quizzes

by Debbie McDonald -
I think our group is in a similar situation. Moodle 2.6. New employees have to take a particular training. Employees are enrolled via an automated process. But once the employee quits we need to delete the record of the training so when they come back (which many do) they can be re-enrolled into the course without showing up as passing the course.  Admin > Gradebook settings > recovergradesdefault has been unchecked. This partially works, everything seems to be gone except the quiz score. Also, this is a global fix so concerns me in regards to other courses. An option that would allow student unenrollment including quiz scores would be a great option on a class-by-class basis. I'm not a programmer so I'm not sure how to begin to implement the quiz_delete_attempt function.
In reply to Debbie McDonald

Re: Deleting Previous Attempts on Quizzes

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

Hi Debbie,

I know when you manually enroll someone via te 'Enroll Users" button, after you search for a user and before you hit the 'enroll' button, you can expand an additional option--here is where you want to 'uncheck' the option to restore user grades and data.

I have experienced your issue when re-enrolling repeating students in a course. This is how I solved my issue and I hope it works for you.

In reply to John Provasnik

Re: Deleting Previous Attempts on Quizzes

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

That will not work for the quiz. We err on the side of not losing important user data.

If you want to delete a quiz attempt, you need to go an do that explicitly.

In reply to Tim Hunt

Re: Deleting Previous Attempts on Quizzes

by samridh mathur -

Hi Tim,

I tried to use the function delete_quiz_attempt to delete the attempt but doesn't delete. Is there any other way to do so. 

What's the explicit way you mentioned above.

Thanks

Samridh

In reply to samridh mathur

Re: Deleting Previous Attempts on Quizzes

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

delete_quiz_attempt will only work if you pass in the correct parameters. If you do, it will delete the attempt, and that is the right way to do it. (Make sure you have Debugging set to DEVELOPER while you try to make this work.)

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

Re: Deleting Previous Attempts on Quizzes

by samridh mathur -
Thanks a lot . There was an issue in the parametersk I was passing to the function . It works fine now. 
In reply to samridh mathur

Re: Deleting Previous Attempts on Quizzes

by Blair F. -
Picture of Particularly helpful Moodlers

So, what did you end up doing, Samridh?  How did you implement this?

In reply to Blair F.

Re: Deleting Previous Attempts on Quizzes

by samridh mathur -
Sorry for a late response Blair . 

I implement this by redirecting the user to the submission details page when the user clicks on 'quit quiz' button (Added to the quiz pages) .After redirecting, I use the quiz_delete_attempt function with the correct parameters to delete this attempt and this just quits the quiz (i.e delete the attempt from the table) as if there was no such attempt that the user attempted.

In reply to samridh mathur

Re: Deleting Previous Attempts on Quizzes

by Blair F. -
Picture of Particularly helpful Moodlers

Forgive my ignorance, Samridh, but from your description it sounds as though the user is the student. That would mean what you're doing is have the student delete their own attempt, is that correct?

In reply to Blair F.

Re: Deleting Previous Attempts on Quizzes

by samridh mathur -

That is correct. Actually I wanted to allow any user (who is attempting the quiz) to cancel the attempt he has started and give a new start again and avoid resuming the quiz when he returns to the quiz again.

In reply to Tim Hunt

Re: Deleting Previous Attempts on Quizzes

by Blair F. -
Picture of Particularly helpful Moodlers

I feel silly asking, but where is this function?  I've searched the moodle files found at /mod/quiz and cannot find anything.