Thursday, January 29, 2015

Updating moodle quiz questions in the db....

My customer asked to change the review settings for all the quizzes in a particular course so students after completing the quiz, could see feedback - result - correct ans. on the quizzes.  There were 20 quizzes in the course.

I could have manually gone into each quiz, one after the other, and updated the settings via the moodle web interface.  Tedious, repetitive, boring.  Or, I could open the moodle db, find the table and update the data using a little SQL.  Exciting, challenging , not boring.

But, a little more risky - dangerous, especially when we are talking about updating data.

Steps I took to update the quiz data in the db

1)  open MySQL workbench - and remote into the moodle db
2) open the correct db and browse the mdl_quiz table

View the quizzes in the course

select * from mdl_quiz
where course = xxxx

3) update the column in the table  - 272 was the value for the option on in the setting

update mdl_quiz

   set reviewattempt= 272,
   set reviewcorrectness= 272,
   set reviewmarks= 272,
   set reviewspecificfeedback= 272,
   set reviewgeneralfeedback= 272,
   set reviewrightanswer= 272,
   set reviewoverallfeedback= 272

where course = xxxx 

I really had a third option too, which was change the value once in the form - to see what the correct value is for the other columns, and then manually change each field in the table, a copy once, paste many times job.

In the end, if you get your syntax correct and are careful - updating in the db is a good option.


No comments:

Post a Comment