Changing quiz/question type

Changing quiz/question type

by Max Stucchi -
Number of replies: 3

Hi all!

This is my first post in the forum, so please bear with me if anything is wrong.

I have a problem I've been working on with a colleague recently.  For a specific need we have to change a question type in a moodle install, but have the need to retain all the attempts and grades, in order to preserve statistics.

So far, we've worked out a procedure that would be like this:

- Add the new activities (as we have more than one quiz/activity to change);

- Run a series of queries that does the following:
  - Update mdl_quiz_attempts to set quiz=$new_quiz where quiz=$old_quiz;
  - update mdl_quiz_grades to set quiz=$new_quiz where quiz=$old_quiz;
  - delete from mdl_grade_grades where itemid=$new_item_id;
  - update mdl_grade_grades set itemid=$new_item_id where itemid=$old_item_id;
  - update mdl_course_modules set instance=$new_instance where instance=$old_instance and module=16;
  - update mdl_course_modules set instance=$new_instance where instance=$old_instance and module=15;


- Swap back the entries in mdl_course_modules with the $new_instance, but that have the newest value, with $old_instance.  This way we have the old quiz pointing to the new questions we created with the new type of plugin, and the new quiz pointing to the old question, that we would then like to discard.

We feel there is something else we should be treating, but we've been banging our heads against this wall trying different other changes with no luck.  Googling is no help, so I hope somebody here could point me in the right direction.

Thanks!


Average of ratings: -
In reply to Max Stucchi

Re: Changing quiz/question type

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

This seems very hazardous. (E.g. what happens if someone tries to regrade this quiz in future.)

Another option:

  1. Make a completely new quiz.
  2. Hide the old quiz from students.
  3. In the gradebook, add a new Grade item with calculation (score from old quiz) + (score from new quiz). That will effectively merge the scores from the two quizzes.
In reply to Tim Hunt

Re: Changing quiz/question type

by Max Stucchi -
Thanks for the answer.

At the moment, the situation we have is that we have made it so that the grades and attempts from the old question get associated directly with the new question, so we're pretty good on that side.

The reason for asking here on the forum, is that after some time trying to come up with a solution for retaining the attempts, grades and statistics for the old questions while moving to a new plugin type, we ran out of ideas on how to finish it and are seeking some advice/tips/guidance.

Put another way, if you had to do something like this, how would you approach it ?

Thanks!
In reply to Max Stucchi

Re: Changing quiz/question type

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

How much do you know about how the Moodle quiz/question system works? https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine#Database_tables & https://docs.moodle.org/dev/Quiz_database_structure


What might make it possible to do what you want is that, once an attempt has been started, the link from the quiz attempt to the question is

quiz_attempts.uniqueid -> question_attempts.questionusageid ; question_attempts.questionid -> question.id

and it no longer matters how the quiz is set up.

And, because of random questions, all the quiz reports cope just find if you have different questionids in the same slot.

So, just don't change the old quiz attempts at all, but make sure any new quiz_attempts started in future use the new questions you want used.

Would that work?