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 BCLN 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 


Processes (click to download reset.zip):

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

Clear out student accounts:

Script = clear_accounts.php 

What this script does:

  • deleting student accounts on your site through Moodle doesn't remove the accounts from the databases (it just marks them as "deleted")
  • these files are stored in the mdl_user table.
  • to reset your site, you can choose to actually clear this table of student accounts to make start-up cleaner (smaller, no email conflicts, etc....)
  • this script clears all accounts in this table that is not currently a teacher or admin

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_accounts.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

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

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

Last modified: Tuesday, 25 July 2017, 12:25 PM