Moodle reset (php scripts)

Overview

The principle behind this process is to provide schools with a standard process to reset their Moodle site at the end of each school year. The tools / options listed are designed to reset the database to clean up files (e.g. Reduce disk space / increase performance) while keeping the core of the system (e.g. courses / staff) intact.

The traditional way to accomplish a "fresh start" is to re-install Moodle and then re-install all the courses. But this takes a great deal of time in that courses, categories, and teachers have to be reloaded, then themes re-installed, groups set up etc.  To help avoid this and still get a clean starting point, we are supplying processes that can be done (any or all can be used at your discretion).

Please understand that WCLN R&D hopes to support local server admins by providing these tools with the following understandings.

These should be implemented by a server technician who will:

  1. do a site backup prior to implementing any script.
  2. read the documentation below carefully.
  3. understand the process and outcomes of these scripts
  4. take responsibility for their own site 

Note that that the preview versions of the files can be used to test prior to running the actual script.


Processes (click to download reset.zip):

1. Remove all student accounts (keeping teachers).

  • Site Admin > Users > Accounts > Bulk user actions
  • Used filter = "Course role is "Student" in any course from any category" > Add All
  • Delete users & Confirm

2. Reset all courses to remove accumulated data:  

Script = group_reset.php  

What this script does:

  • courses left from previous years still hold student data such as quizzes, assignments, forums, messages, etc... (which will continue to accumulate if not cleared)
  • it will clear all students from courses, but leave teachers in place
  • clearing this data can be done by "resetting" each course on the site (https://docs.moodle.org/33/en/Reset_course)
  • if you have a large site, manually resetting each course is time consuming
  • this file runs what is in effect a Moodle course reset for all courses on a given site

Instructions:

  • put site in maintenance mode
  • download reset.zip (above) and unzip
  • move the folder on your site in this location: yourmoodlesite.com/local/reset/
  • login as an admin
  • from a browser, enter "yourmoodlesite.com/local/reset/group_reset.php" and let it run
  • it will display a message when routine is complete
  • remove the files to avoid any future confusion
  • take out of maintenance mode and thoroughly check site

3. Clear out logs & backup files:

Scriptclear_logs.php & clear_backups.php

What this script does:

  • log files and grades history can take up a large amount of space in your database.
  • note Settings > Plugins > Standard Logs
  • this script clears the accumulation of data in these areas

Instructions:

  • put site in maintenance mode
  • download reset.zip (above) and unzip
  • move the folder on your site in this location: yourmoodlesite.com/local/reset/
  • login as an admin
  • from a browser, enter "yourmoodlesite.com/local/reset/clear_logs.php" and let it run
  • it will display a message when routine is complete
  • remove the files to avoid any future confusion
  • take out of maintenance mode and thoroughly check site

4. Once these are done, you need to clear three tables (if Moodle doesn't reset them):

  • mdl_question_attempts
  • mdl_question_attempt_steps
  • mdl_question_attempt_steps_data

After these resets, run any Moodle upgrades, then load in the new courses.

Last modified: Thursday, 28 July 2022, 10:18 AM