Role exports / imports for Moodle 2.0

Role exports / imports for Moodle 2.0

by Glenn Ansley -
Number of replies: 13

Hello,

I've been looking around the docs, forums, and tracker tickets for any references to the status of this feature in Moodle 2.0. It looks to me like this was not implemented yet. I would like get confirmation on that and seek advice for implementation.

There seems to be two existing Tracker reports mentioning this. At my University we have actually implemented a version of MDL-17081 for Moodle 1.9+ We are currently reevaluating all of our local 1.9 patches and refreshing for 2.0 where necessary.

The quickest solution would be to simply refresh MDL-17081 but I've found a couple discussions where it was suggested that this feature could be more robust and possibly start out as an admin report plugin (Tim Hunt's second comment here).

So, I guess my question is,

1) This doesn't exist for Moodle 2.0 yet, does it? and

2) If not, what would be the suggested path for implementation?

Thanks.

Average of ratings: -
In reply to Glenn Ansley

Re: Role exports / imports for Moodle 2.0

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

Certainly not implmeneted in standard Moodle yet.

It certainly should be implemented. It would be really useful.

I don't know what 3rd party plugin code aleady exists.

Of course, backup/restore has a way of turning role definitions into XML and vice versa. Don't know if that is useful.

If this is goint to become part of standard Moodle, then it might make sense if the scrip live in admin/roles. Initially however, it should be developed as a separate plugin, so an admin report makes sense.

It should only be a small amount of work to move scripts from admin/repor/whatever to admin/roles.

In reply to Tim Hunt

Re: Role exports / imports for Moodle 2.0

by Glenn Ansley -

Hey Tim,

I've got a question. I was looking into the maze of files, includes, and class::method calls that are a part of the backup API found in /backup/

I thought it would be pretty cool to build my admin report to export / import roles by using that API. I've run into a problem that looks like I'm going to have to edit the core if I want to use that API though.

This is primarilly because there are several places inside the API that assumes the $type of backup is going to be course, section, or activity. These assumptions mean that I can't build my own backup_plan without hacking core. It also means that I'd have to place my backup plan inside the backups directory because that's where it looks for them (by providing $type in the path). I'm hoping that you (or another core dev if this isn't your area) could give me some direction.

Should I just abandon the API so I can keep it all well contained in my report directory (seems like a shame) or should i consider working towards core inclusion from the beginning and just placing my files where I need them and adding a new $type to the codebase for roles.

Thoughts? Thanks.

In reply to Glenn Ansley

Re: Role exports / imports for Moodle 2.0

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 think I would not try to use the backup/restore code for this.

Well, to expand on that: If I wanted to implement this feature quickly, I would just code it all myself, using the accesslib.php and xmlize.php API to do the really low-level stuff.

If I wanted a deep intellectual challenge, and to learn a lot about how the Moodle 2.0 backup and restore system works, then I would try to use the existing code in the backup and restore system that handles roles in order to implement this functionality.

In reply to Tim Hunt

Re: Role exports / imports for Moodle 2.0

by Glenn Ansley -

There will probably be needed modifications as I'm the only one that's tested it so far. I have a couple other developers at our university looking at it now. Here's the first draft though: https://github.com/glennansley/moodle-report_rolesmigration

Average of ratings: Useful (1)
In reply to Glenn Ansley

Re: Role exports / imports for Moodle 2.0

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Cool stuff Glenn!

While reading this discussion I immediately thought about the (potential) relation of your code and the Moodle flavours GSoC 2011 project. Perhaps now it's a good moment to share with David & Michael some thoughts / plans and see if that information fits there.

Ciao smile

In reply to Eloy Lafuente (stronk7)

Re: Role exports / imports for Moodle 2.0

by David Monllaó -

Hi Glenn and Eloy,

The Moodle flavours plugin allows the creation of new classes to package/deploy all sort of things which belongs the the system context level like roles, site scales or custom language strings... but the GSOC project does not cover all the options, the current release can package and deploy plugins, language packs, custom language strings and site administration settings, but other intredient types can be added in future.

If you are interested on roles support or on adapt your development to Moodle flavours, there is a public interface to implement different ingredient types without so much trouble (just a constructor and 4 methods) you can see an example here https://github.com/dmonllao/moodle-local_flavours/blob/master/ingredient/flavours_ingredient_lang.class.php if you need something please tell me

In reply to Glenn Ansley

Re: Role exports / imports for Moodle 2.0

by Glenn Ansley -

I'm currently doing some updates to this... fixing some coding guidelines, etc. Do you think this would make more sense as a local plugin rather than an admin report since it techincally isn't a report? 

In reply to Glenn Ansley

Re: Role exports / imports for Moodle 2.0

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers

Glenn - Yes, local seems like a much better place for your code. Peace - Anthony

In reply to Anthony Borrow

Re: Role exports / imports for Moodle 2.0

by Glenn Ansley -

Thanks Anthony. I have two versions on github. One branch for local and one branch for admin/reports

https://github.com/glennansley/moodle-report_rolesmigration

In reply to Glenn Ansley

Re: Role exports / imports for Moodle 2.0

by David Gilardi -

Hi Glenn.  I would like to check out your rolesmigration capability.  I assume since you posted it out here folks are allowed to grab it, but I wanted to ensure before I did so.  Also, if this does what I think it does not only will it be terribly useful, but I will end up testing it out as well so I can let you know how it works out.

Thank you smile

In reply to David Gilardi

Re: Role exports / imports for Moodle 2.0

by Glenn Ansley -

Hi David,

Yep. Have at it. Feed back is welcomed!

In reply to Glenn Ansley

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.