** Get Your Free Totara Demo Now! **

Generate random test data in Moodle 2

Would you like to test Moodle 2 performance? Or maybe you are interested in checking Moodle’s scalability? Sure, it works fast with the few courses you have created – but how will it look when you have hundreds of courses and thousands of users?

In either case, you will need to fill your Moodle installation with sample data. Doing this manually may take a long time – fortunately Moodle 2 comes with a generator script.

We had a quick look at the generator script here, at Enovation and it turned out that the script is not really usable. It was developed for an old version of Moodle (see CONTRIB-490) and has not been fully updated for the latest Moodle 2 release.

But fear not – we have fixed the issues and submitted the code to back to Moodle šŸ™‚ Although at the time of writing the fixes may not be merged with Moodle yet, you can get the most recent, working version of generator by downloading generator.php and putting it into the admin directory. Some code in the question types needed fixing as well, so you will also need to apply the patch from MDL-25796.

Please vote in Moodle Tracker on issues MDL-25796 and MDL-16177 if you are interested in having the fixes pushed into the main Moodle code soon!

Using the generator is very straight-forward; in the simplest case the default settings will work just fine – so simply go to http://<your_moodle_url>/admin/generate.php and press “Generate data!” button. It will create:

  • New courses
  • Sections and modules within the course
  • Grades
  • Full module data, including forum posts, questions, chat messages, etc
  • New users (it will also assign users to course

The recording below shows the generator in action.

Happy testing!

February 17, 2011 In: Blog Written by: tmuras


  • Nachiket Kate
    May 31, 2016

    I am using bitnami ubuntu-moodle virtual machine for setting up moodle. After successfully setting up moodle instance using that VM, I wanted to generate sample data in moodle so I used your generator.php.
    I kept it in admin directory and when I hit I get url not found or can’t locate this page message.

    When I run it from cli as php generator.php, I get “generator_cli may not inherit final class (Generator)” error message. I have less knowledge in php so couldn’t resolve it on my own but it looks like generator class is not declared final or const in php script which surprises me.

    Any help from you guys would be helpful. Thanks in advance.

Leave a Reply