Thursday, February 25, 2016

Update quiz timings en mass

I had a customer send me a request.  "James, could you remove all the quiz timings for course xyx"?  I pulled the course up and noticed 22 quizzes in the course. 























I had two options.

1 - update each quiz manually via the Time limit property via the edit quiz interface.  There, I could turn disable the time limit setting.


OR

2 - open the DB, filter the quizzes using the course ID and change the quiz Time limit value in the table.

I use MySQL Workbench as my main tool when manipulating records in the DB, I have a bunch of snippets stored that do things that tend to requested more than once, like this.

select * from `dbname`.`mdl_quiz`
 where course = 1575;

Once I had the query results showing the quizzes for the course, I made  a change to the first quiz in the course via the interface and observed the result in the DB, just to make sure it was updating the column I expected with the value I expected. 

Update query for all the course quizzes
update `student`.`mdl_quiz`
 set timelimit = 0
 where course = 1575;
 Easy peasy and better than a manual walk walk through of each quiz setting.

No comments:

Post a Comment