I have only a course in my moodle installation that I duplicate every month to start a new class with new user. After six month I close the course and move user who have not completed the course to a new one.
When I move the users I would like to move the result of their quiz attempts in the old course to the same quiz in the new course.
I found this topic https://moodle.org/mod/forum/discuss.php?d=347705 that is related to a similar problem but in that case the quiz attempts were moved from two similar quiz in the same course just by changing 2 values:
- The quiz id in the row of the quiz_attempts table.
- The contextid in the corresponding row of the question_usages table.
In this case I would like to ask which is the easiest way to find the context id of the quiz in the new course.
These are the sql statements I would like to use:
- to identify the attempts that I need to move
Select quiza.id, quiza.quiz, quiza.userid, quiza.uniqueid, qu.contextid from mdl_quiz_attempts AS quiza
JOIN mdl_question_usages qu ON qu.id = quiza.uniqueid
WHERE quiza.quiz = (Select id from mdl_quiz where name = 'Simulazione 1' and course = (Select id from mdl_course where shortname = 'PMEZEM18')) and quiza.state = 'finished' ;
- to identify the grades that I need to move
Select id, quiz, userid, grade from mdl_quiz_grades where quiz = (Select id from mdl_quiz where name = 'Simulazione 1' and course = (Select id from mdl_course where shortname = 'PMEZEM18'));
- to identify the quiz in the new course where to move the results
Select id from mdl_quiz where name = 'Simulazione 1' and course = (Select id from mdl_course where shortname = 'PMEZEM19');
Thanks
Moodle 3.6.1