Split one moodle into many

Split one moodle into many

by Hal MacLean -
Number of replies: 5

I've been asked to take an older version of Moodle (1.8) with data from many different organisations, and split it into one moodle per organisation (i.e. seperate the users and courses for those users).

Additionally, each needs to be updated to 2.0.2.

I *know* there will be many things to get right in this, but I am not sure how to seperate out all of the users so that when they log in to thier new Moodle they have got all of their profile data, course results, access to courses, etc still intact.

Any advice gratefully received!

Average of ratings: -
In reply to Hal MacLean

Re: Split one moodle into many

by Colin Fraser -
Picture of Documentation writers Picture of Testers

First things first, update it to /moodle 1.9.x as early a version as you can get your hands on. Then to v1.9.11+ I know it is a bit of playing around but the upgrade to v1.9.11+ is a fairly substantial one and not necessarily a good one to make in just one step.

Once you have done that, then you have to determine how you want to set your new multiple Moodles up. You can have in one server any number of Moodles but you can place each one with their own database and code base, or have one codebase and different databases or one code base and one database for all users. I am not sure of there are other variations here, but you can start with this possibility here. There is no reason to think it may not work in Moodle 2.x The ensuing discussion also offers possibilities for a number of variations as well.

In reply to Colin Fraser

Re: Split one moodle into many

by Hal MacLean -

Hi Colin - thanks for that - I am very prepared for the upgrade through the versions to 1.9.11, it'll be the first step.

The intention is for one codebase and seperate databases, one for each of the organisations involved (58 in fact). This will sit on a single server (actually, a mirrored and load balanced arrangement that will operate as a single server).

The issue is that the user data, scores, profiles and so on needs to then be sent to the correct database. How should I go about this? Will it require a manual export of users and associated tables for each organisation from the older version's database to be imported one at a time into the new databases, or is there a more straightforward approach?

I know that the courses won't simply migrate and may well need recreating, and am prepared for that chore, but how will the user scores within the existing courses need to be handled in the migration?

I am also expecting to lose all custom plugins along the way - no big loss, actually - my main concern is the user data.

In reply to Hal MacLean

Re: Split one moodle into many

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I am just guessing. Perhaps someone who has actually don this themselves will be able to reply as well.

My guess would be that the easiest way to do this is to start by making one copy of the entire site for each organisation, and then go around deleting all the irrelevant bit from each organisation's copy.

Upgrading (first to 1.9, then 2.0, you need to do separate steps) is really a separate issue that could be done either before or after spitting. I think you should do one things at a time, and verify that it worked, rather than trying to do too much in one go.

In reply to Tim Hunt

Re: Split one moodle into many

by Hal MacLean -

Hi Tim - yup - sound advice, thanks!

I did wonder about the 'import all and delete the unwanted users' approach. It'll be a lot easier to do from inside the database as a MySQL query if all I have to do is remove users... however I would think the associated tables all need clearing as well. That starts to get messy, unless there is a function in the Moodle accounts options that will allow me to filter on a specific range of users and delete those, cascading through all of the associated tables accordingly to leave a pretty clean set of users in each.

Small steps, as you say, will be the order of the day!

In reply to Hal MacLean

Re: Split one moodle into many

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Tim may have a better idea than me, with the development work he has done and I have not, but by having a different config.php file for every client, perhaps in sub-domains, pointed at the codebase you can set up one database, but each with its own table prefix. Moodledata folders too may become an issue here, but numbering them has worked for me in a single domain, moodledata19, moodledata1911, moodledata20, moodledata201 with each Moodle using its own cookie prefix, but that is 4 different installations btw. The database has set up its own tables on install, which is where Tim's comments may come into their own, installing in a sub-domain, setting up the database with appropriate changes to table prefixes and so on, editing the config.php file... mmm sounds almost too easy doesn't it.... still might try it when I get some more time, mid-semester in about 10 or 11 weeks, might get it done before the MoodleMootAU in July. Will have a couple of days then, interesting challenge though...