Tuesday, March 25, 2014

Updating quiz settings in a course directly in the DB

My customer says "James, is there a way to update the quiz settings for a course in the DB?  The teacher wants to allow 2 attempts on each quiz and average the 2 attempts for the grade"

Reasonable.

The course looks like this, which is why they are asking if I can do the updates en mass for the entire course, rather than quiz by quiz in via the moodle quiz edit interface.



This is just 2 of the 7 sections in the course.  I counted the # of quizzes in the course and found 78 of them!  A lot of quizzes!

I opened MySQL Workbench, where I have SQL code snippets saved and ran this code to update the quiz settings

UPDATE mdl_quiz
SET attempts = 2
WHERE course = 706;

UPDATE mdl_quiz
SET grademethod = 2
WHERE course = 706;

I could have run together like this:

UPDATE mdl_quiz
SET attempts = 2,
grademethod = 2
WHERE course = 706;


No comments:

Post a Comment