Duplication of a Quiz takes too long - freezes the course

Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -
Number of replies: 22

Moodle 2.8.3+ (Build: 20150205)


I've gotten reports from teachers that duplicating Assignments (Quizzes) takes forever sometimes (most times). He is clicking the 2 paper icon to duplicate a Quiz.


From teacher..
Again this AM I duplicated an assignment in Moodle so that I could get some work done before school and HWSpace (his course) froze up. This happened a few weeks back when I duplicated an assignment and am trying to edit it to meet the needs of my students and it locks up HWSpace for 40 minutes or so. Today it was able to move beyond that phase and allow me to do something in HWSpace after 17 minutes. I dont have 17 minutes to waste on a simple task like this.


more from the teacher..
What is happening is that it duplicates in the "background".


It starts out by showing the loading/thinking icon for about 30 seconds and then shows a copy of the assignemnt right below the original.  Then at that point you think everything is working, but it is not.  It is doing something in the background that is locking up the entire HWSpace site and will not allow you to edit any assignment or do anything until it completes the duplication.


It didnt give me any error, it just wouldnt allow me to do anything until it completed it cycle....today that took 17 minutes.


It locks it up for students and teachers, not just me, all users.


I will say that these teachers heavily use Quizzes and have a lot. Very robust. But having the course be basically unresponsive for 17 - 40 minutes..we might as well tell them not to use that feature.

  1. Has anyone else experienced this?
  2. What is the cause?
  3. What is the resolution?
  4. Any work arounds? What would you tell your staff?
  5. Is there any logs or troubleshooting I can do to help resolve this?


Maybe relevant?
This is just a part of a long string of issues regarding these teacher's courses. Other issues are: long load times and error when adding, moving or deleting gradebook categories and students getting errors when submitting Quizzes. I would not be surprised if it has something to do with these teacher's courses. It's a team of teachers and it's a heavily used 3 courses. There are tons of resources and activities. There are a bunch of Quizzes and questions. The gradebook is used because of that. They also have Groups and Groupings.


Like I said, it seems like there's a bunch of issues with the same teachers and courses but they use it the most and would most likely run into the most problems.
Average of ratings: -
In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

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 suspect the problem may be MDL-29439 Quiz restoration is very slow if the backup contains lots of questions. Some work has been done on this (MDL-40579) but there is still more to do.

To explain the symptoms you see: Moodle has a session lock, so that each user can only be loading one page at a time. Even when the duplicate times out, it is actually still running in the background, and that keeps the session locked, so the user can't get in again.

In this situation, if you completely shut your browser, then go and log in again, you should be able to continue.

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

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

So even if I'm trying to duplicate 1 quiz, which may have 10 questions in it...it will take that long because the question bank may have a bunch of questions? Why wouldn't it just be copying those 10 questions in that 1 quiz?

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

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

It depends.

If all 10 questions come from the part of the question bank specifically associated with the quiz, then just those 10 questions should be copied.

If, however, they come from the course area of the question bank (which is where questions go by defult) then all the course qusestions will be copied. Why? becuase some of the questions might be random questions, picking from particular categories and their subcategories.

Could it be made more intelligent about which questions to include? Yes. That is what MDL-41924 is about. However, it is extremely hard.

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

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Ah, that makes sense. Yes, I'm assuming they are using questions from not just the place associated with that one quiz...because we want teachers to add questions to the category/bank - so when they delete the quiz, they don't delete the questions!

Thanks again. I've voted and followed that tracker item.

It's unfortunate that our most advanced Moodle users, who have the most users, questions, organized categories, etc., are the ones who suffer in regards to a lot of the Quiz stuff. People who don't use it as heavily don't run into these issues but our power users do! Moodle is very robust but when taken advantage of, it's frustrating that performance-type issues make life harder for them. I'm at a loss as to how to advise them with issues like this.

In reply to Tim Hunt

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Hey Tim, do you think that MDL-41924 will get some traction? Or what is needed to get work done on it? Nothing new but below is a teacher's feedback.


I just tried to duplicate a "quiz" and I started the process at 1035am and it finished at 1054am, and then when I clicked on the new quiz it took a really long time to open.  It took ___ minutes to open (still has not), and while it was doing that I could not do any other tasks in moodle on that open browser.  Or on any other browswer, I even tried a different computer.  So at 1127am I gave up.

While this was duplicating (during the 1035-1054 window) I went on a different computer and tried to access NEW HWSPACE and it let me do that, so that is good.  We want to be able to do things on the site while duplicating is happening -- this was a major pain after Winter Break...as it would "lock up" our site and it is not doing that this time, but it is taking a long time to duplicate a "quiz".



In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

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, I don't know of anyone planning to work on that.

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Ray Morris -

> Hey Tim, do you think that MDL-41924 will get some traction? Or what is needed to get work done on it?


It will, at some point in time.  As Tim pointed out, it's a hard problem. I happen to like problems exactly like this one - hard, but not impossible or logically invalid, and it's one single hard problem, not a bunch of interrelated problems.  When I get time, I'll probably need to work on this. That may be soon, after I finish polishing up the paper copy quiz module. Or something else will come up and this will get pushed off until later.  At some point in time, I'm fairly sure I'll have to solve this if nobody else has done so first.

Average of ratings:Useful (1)
In reply to Ray Morris

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Thanks for the feedback!

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Question that I never thought of before... we have a lot of system level quiz questions. We set up the quiz sharer role. Could this be causing any of these quiz issues we've been having? When you backup a course or duplicate a quiz will it also backup the SYSTEM questions?

Now I want to remove that set up and see if that makes a difference.

Is there any to see if those questions are being used? I don't want to remove them or remove the question sharer role if it will mess up teachers..

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

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

Yes, it includes the entire system level quiz bank.  Unfortunate side effect.  I ended up taking out my system level bank and returning everything to the course level - makes for much easier backup and restore and also gets sharing cart plugin working again.

In reply to Emma Richardson

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Wow, that is crazy!! That should be a caveat in that question sharer documentation!! 


What are my options of stopping this from happening? What if I remove the (question sharer) role of the teachers? Or do I have to remove them? What about moving them into another category? My issue is now, not causing any other issues because I remove them. I don't know if anyone is using them.

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

But here's a question....when I duplicate a smaller quiz in another smaller course...it doesn't seem to take that long. The issues are within these 2 courses that have a ton of questions in the actual course. Wouldn't duplicating the quiz take that long for every quiz then?

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

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

So, the backup will include all questions accessible to the course, in my understanding.  So it will include the system level questions and any category level questions for the category the course is in.  But it will not include questions from another course if those questions are at the course level and it will not include questions from another category (Tim will correct me here if I am mistaken!)

The courses with a lot of questions are taking longer because they are getting a double dose - lots of questions at the course level plus whatever questions are at the system level.

Questions are just intensive on the database - they have entries in several different tables and as such it just takes a while for all the entries (questions/hints/attempts/answers...etc) to populate.

It has been an age old problem without an easy fix but we keep hoping that the Moodle Gods will one day give Tim (or another of our great developers!) enough time to redesign it so that it works better!!

In reply to Emma Richardson

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Okay, makes sense.


Any advice on removing those System level questions? I'm just afraid it's going to cause issues if others have used them - removing them from quizzes that are being used. I'm wondering if there is a way to see if any of those system level questions are being used in courses.

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Ray Morris -

You can use this plugin I wrote to find questions that are being used in a particular category:

https://moodle.org/plugins/view/local_unusedquestions


If you find it helpful, you might also like this one:

https://moodle.org/plugins/view/local_searchquestions



Average of ratings:Useful (1)
In reply to Ray Morris

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Thanks, Ray - I will give this a try today.

In reply to Ray Morris

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

I've installed both of those plugins but I'm having a hard time figuring out how to get what I need. Do I have to go into each quiz and see if it's using one of the system quiz questions? So I go into the question bank for the course and choose "only unused" and everything it shows me are questions that aren't being used by that course?

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Ray Morris -

Used vs unused is not specific to a certain course or quiz.  So if you search for "used" questions in a category it shows questions used in ANY quiz, anywhere on the site.


This is a pretty new plugin, so it wouldn't hurt to double check my work by looking for a question that you know to be used in some other quiz.  It's an extremely simple plugin, though, so I don't think it has any bugs.

In reply to Ray Morris

Re: Duplication of a Quiz takes too long - freezes the course

by Melissa Benson -

Awesome, thanks.

And is there a way to see what quiz or course that "used" question is in? If not in your plugin, any advice in looking in phpmyadmin?

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Ray Morris -
One of the relevant tables was renamed, but assuming Moodle 2.7 or higher:


I haven't tested this, but it should be something like:


SELECT id, course, name FROM mdl_quiz WHERE id IN 

(SELECT quizid FROM mdl_quiz_slots WHERE questionid=:QUESTIONID)

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

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

I thought there was a report or something that shows that but I am not finding it.  A database query would probably figure that out for you if you are familiar with mysql.

In reply to Melissa Benson

Re: Duplication of a Quiz takes too long - freezes the course

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

Yep, I know what you mean.  I experience this myself, as I am both the instructor and administrator.  I actually find it faster to create the new quiz from scratch, which is not a big deal, but I would rather be able to duplicate.  I don't have any work around.

With a little bit of planning, for example if I need two quizzes that contain only different questions, I create the structure for the first quiz, and duplicate it before adding questions.  This way, all of my quiz settings (except for a reported problem with "grade category", MDL-42449 please vote) get duplicated.

Average of ratings:Useful (2)