Adding 0 marks questions to already attempted quiz

Adding 0 marks questions to already attempted quiz

by Alexandru Cojocaru -
Number of replies: 4

Hi all,

I want to add some 0 marks questions to a quiz that has already been attempted (right now I'm getting the "You cannot add or remove questions because this quiz has been attempted." message) . The new questions will not affect the grade of the older attempts because they will have 0 marks. I want to do this without copying the existing quiz because I want to keep the quiz attempts history.

 Is it possible to do this in Moodle 3.1?

Average of ratings: -
In reply to Alexandru Cojocaru

Re: Adding 0 marks questions to already attempted quiz

by Alexandru Cojocaru -

(Looks like I cannot edit my post, so I'll add an additional question here)

For adding the question directly in the database, can I safely do something like this?

UPDATE mdl_quiz_slots SET slot = slot + 1 WHERE quizid = 2 ORDER BY slot DESC;
INSERT INTO mdl_quiz_slots(slot, quizid, page, questionid, maxmark) VALUES (3, 2, 1, 70, 0);

This should move the existing questions one slot and then add the new question as the first question of the quiz (assuming that all questions are displayed on the same page).

Is this safe or is there a chance of breaking something with this approach?

In reply to Alexandru Cojocaru

Re: Adding 0 marks questions to already attempted quiz

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

If that were safe, it woudl be possible to do it thorugh the Moodle user interface.

It is not safe. If you do this, then you will get errors when you try to access teh quiz reports, and possibly also when you review an existing quiz attempt. I am not really sure, but if you want to do an experiement, do it on a Moodle server that you don't care about (e.g. a test install).

In reply to Tim Hunt

Re: Adding 0 marks questions to already attempted quiz

by Alexandru Cojocaru -

Thanks for the answer, Tim. 

I already tried this on a dummy quiz and I was able to view the quiz attempt with no errors, but now I see some "Undefined offset" errors in the "Responses" report.

Are there any other options for adding the questions to the quiz? Creating a new course and a new quiz just for adding some questions that do not affect the grade seems like an overkill (especially when we are talking of ~80 existing quizzes). Is there an easier way of doing this? 

In reply to Alexandru Cojocaru

Re: Adding 0 marks questions to already attempted quiz

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

If you really want to do this, then the only option is to also update the data where the students' quiz attempts are stored, to make it look like the extra questiosn were part of those quiz attempts, and the student did not answer them.

You can see the relevant database tables from this query: https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine#Detailed_data_about_an_attempt