Multi-enrol changes for 1.6 -- drivers wanted!

Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -
Number of replies: 24

Thanks to Patrick Lee, we have a (r?)evolution of enrolments in our hands. We've been playing with it a bit, and we're really keen on merging into HEAD so it's part of 1.6. So come join us and test it!

How to get the code to try it out? If you're using anonymous CVS, do

  cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/moodle checkout -r MOODLE_16_MULTIENROL moodle-multienrol

if you have SSH access, this is your incantation:

  cvs -d:ext:username@cvs.sourceforge.net:/cvsroot/moodle checkout -r MOODLE_16_MULTIENROL moodle-multienrol

To review the patch you don't even need to get a checkout, in any Moodle checkout you already have, just do

  cvs diff -u -r MOODLE_16_MULTIENROL_PRE -r MOODLE_16_MULTIENROL 

What does it do? You can setup Moodle to use LDAP, DB, Paypal, OSCommerce and manual enrolments at the same time. This breaks down into the following parts:

  • Some modules are activated when a user logs in, and "read" enrolments from different places (external backends, internal records, etc). Of those, you can have as many as you want active. If you are using external enrolments, however, high latency can make your login process feel sluggish. Make sure your LDAP or DB servers are right next to the Moodle server wink

  • Other modules activate when someone tries to access a course they are not enrolled in. For any given course, we can have only one of these active -- so we have a Moodle-wide default (controlled from admin->enrolment), and then each course can pick a module (course->settings).

  • As a sweet extra, this includes OSCommerce integration -- out of the box (you do need a slightly patched OSCommerce).

  • Courses can now be set to be "available" to current students but not "enrollable" -- really useful with PayPal, OSCommerce, etc. See course->settings.

  • If you just upgrade from pre-multienrol to multienrol, Moodle should continue to work correctly -- help us double check that it works for you.

So -- that's the brief.

Average of ratings: -
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- extra notes

by Martín Langhoff -

(From Patrick's notes)

Here's a quick guide on how to use it:

  1. Enrolment admin panel is now enhanced. It now allows you to select multiple plugins you wish to use.
    1. Manual (the plugin formerly known as internal)is always enabled as it is required to do some internal work.
    2. Enrolment plugins those requires interactive actions with users can be selected as the default interactive plugin for the site.
    3. Click the "Edit" link on the right side of the plugins to configure them using the origial configuration interface. Don't forget to configure plugins you enabled correctly!
  2. There are a few extra options in the course settings.
    1. You can choose different interactive enrolment plugin from the site default for single courses.
    2. If you do not want any interactive plugins to be enabled in a course just set "Enrollable" setting in the course to "No". Non-interactive ones will still work.

For developers working on enrolment stuff -- here's a brief (!?) description of what's changed.

  1. Changes to the enrolment plugin class structure:
    1. There are no base class any more. All enrolment plugins are independent classes. (Don't panic! This is actually a good thing wink
    2. The original base class is now the manual plugin class (note! just renamed from internal to manual to match auth).
    3. A new enrolment_factory class is introduced to produce enrolment plugins required. Should an instance of any plugin is required, use $plugin = enrolment_factory::factory('plugin_name'); If plugin_name is not specified the default plugin for the site will be created.
    4. If any enrolment plugin does not implement print_entry() method it will be considered as a non-interactive plugin. In the new plugin configuration panel only interactive plugins will be able to set as default plugin. As non-interactive plugins will load student/teacher information everytime user is logged in and when user is attempting to enrol to a course, it is meanless to set them as the "gate" of a course.
    5. If any method in the manual class is required just factory an instance of manual plugin and call the required method.
  2. Setting "Enrollable" to "No" in a course will disable users to enrol interactively. So it is fine to leave manual plugin always enabled and as the default way of enrolling.
  3. Enabled plugins are stored as a comma-seperated list in config varaible enrol_plugins_enabled. It is ensured that manual plugin is always at the top of the list so it will produce a complete user-course array for the rest of the plugins to use.
  4. The old $CFG->enrol is used to store the default site interactive plugin. It may be empty as there is a block of code that if $CFG->enrol is empty, populate it with 'manual', which is exactly what we want.
  5. A new field called "enrol" is added to course table storing the plugin that the course uses. If it is empty, site default will be used.
  6. The upgrade script will try to figure out whether your current enrolment plugin is interactive or not. If not, "Enrollable" option for all courses will be set to "No".
  7. The internal get_student_courses() method will populate the user-course array in a slightly different way. A boolean value of true indicating the user is enrolled to a course is now replaced by a string of the name of the enrolment plugin that enrolled this user to the course. In this way there are no need to query database to ask if the user is enrolled by a particular plugin when trying to unenrol a user. Also this may be used to prevent a plugin to mess up with users enrolled by another plugin.
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by N Hansen -
Courses can now be set to be "available" to current students but not "enrollable" -- really useful with PayPal, OSCommerce, etc. See course->settings.

What does this mean? Does it mean students can pay for courses that haven't started running yet
In reply to N Hansen

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Chardelle Busch -
Picture of Core developers
Hi Martin,

This sounds like great stuff. I was wondering about this same thing. I was thinking it might mean that if someone has already paid for one course (current students), they can have access to the "available" courses whereas non-students cannot enroll in those courses?  This would be a great feature for allowing site-wide availability to all courses after paying for one main course.

Thanks
In reply to Chardelle Busch

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -
Exactly smile

I wrote "current students" to mean "currently enrolled users" (to Nicole: in Moodle, "student" is a user enrolled in a course). With PayPal/OSCommerce courses, it is currently impractical to keep running a course but stop taking new students. You have to do ackward things like disabling Paypal and adding an enrolment key.

Now there's a far better control for all of that. You can toggle it manually or define a date range. By all means, try it and see for yourself! wink
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Chardelle Busch -
Picture of Core developers
Thanks Martin,

Okay, it is clear now. So, you can define a date up until when users can pay for/enroll in a course, and after that no more enrollments. Cool, thanks. I will definitely try it out.
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by N Hansen -
Martin-That sounds useful. I've got a related idea that I know some people want that perhaps you could bundle together with it, and that is to offer the same functionality based on a certain enrollment level or students instead of by date. For example, don't allow any new enrollees when the number of enrolled students reaches 50, and only allow new students if the number drops below that. Or how about a waiting list? When the course has reached 50, anyone who is interested in enrolling would be sent an email automatically giving them a chance to enroll. Perhaps you could make the time period during which they would have to enroll configurable before the place would be offered to the next person on the waiting list.
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Just a quick question (indirectly related to this). It seems multi-auth and multi-enrol are on their way into 1.6, but we still have to manually assign teachers to courses (unless you manipulate mdl_users_teachers, as we do now). Are there any plans to automate things in this area (teacher assignment/course creation) without going the LDAP way for everything?

We have a (custom-made) SIS at our University that we use to extract the list of courses and their assigned teachers and then make a buch of inserts/updates into mdl_course and mdl_users_teachers. We fear all this infractructure is really dependent on the current (1.5.2) database structure. Is there any guarantee this structure is not going to be modified or a way to better integrate (read stable in time) moodle with our SIS?

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -

The enrolment plugin architecture fully supports it -- just teach your favourite enrol plugin how to "enrol" teachers. Enrol/LDAP does it, but the code right now is a bit mucky (it's mine and I'll have to fix it...) so don't use that as example. Be original and write your own bugs wink

There's an enrolment plugin API document somewhere that explains it. Oh! We should update it for multi-enrol!

In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ok, I'll have a look into it. What about automated bulk course creation/update/deletion? Is it possible aswell? (if it's documented somewhere, I'll rtfm wink

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -
Implemented -- not very well -- in the enrol/ldap plugin. There's a better version in a branch I have where I've been working on the enrol/db plugin. Will soon be merged into 1.6 -- look for mdl-artena-tairawhiti in this page: http://locke.catalyst.net.nz/gitweb?p=moodle.git;a=branches

Or get recent versions of git and cogito for your linux distro and get a checkout doing (one line)

cg-clone http://locke.catalyst.net.nz/git/moodle.git#mdl-artena-tairawhiti

Cheers!
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Nikki Macfarlane -
Martin, quick quesiton on the Oscommerce integration. Does this new enrol feature mean that if I am using Oscommerce I can set up Moodle so that students will automatically be enrolled once they have paid for their course? If so, fantastic! Been struggling with this for months now!

I would love to test it out but unable to figure out the instructions above - do you want non programmers to try it as well? If so, is there somewhere i can download the necessary files together with instructions on how to set it all up?

Nikki Macfarlane
In reply to Nikki Macfarlane

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Patrick Li -
Yes. This is exactly how osCommerce integration work.

But this will require a few more changes to moodle core and oscommerce needs to be patched.

You can follow the instructions above to get a copy of multi-enrolment enabled moodle. But for oscommerce integration we need to prepare more things.

Actually we already have a production moodle with integrated oscommerce running. So be tuned!
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Using this url http://locke.catalyst.net.nz/gitweb?p=moodle.git;a=branches gives me a nice "403 Forbidden - Unknown action."

Using the cg-clone command I get:
$ cg-clone "http://locke.catalyst.net.nz/git/moodle.git#mdl-artena-tairawhiti"
defaulting to local storage area
19:26:31 URL:http://locke.catalyst.net.nz/git/moodle.git/refs/heads/mdl-artena-tairawhiti [41/41] -> "refs/heads/origin" [1]
error: File 214e6374d49e6d014f0ba6f159d585a3fe468909
(http://locke.catalyst.net.nz/git/moodle.git/objects/21/4e6374d49e6d014f0ba6f159d585a3fe468909) corrupt

Cannot obtain needed object 214e6374d49e6d014f0ba6f159d585a3fe468909
while processing commit 0000000000000000000000000000000000000000.
cg-pull: objects pull failed
cg-clone: pull failed

I'm new to git/cogito but I suspect something is going wrong somewhere (I'm behind a quite restrictive http proxy, so this could be the problem, but that "corrupt" message doesn't look very promising...).

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -

Oops -- we just upgraded gitweb and the 'branches' action was renamed to 'heads'. So try http://locke.catalyst.net.nz/gitweb?p=moodle.git;a=heads instead.

WRT cg-clone, make sure you have a recent version (15.1 for cogito, 0.99.9 for git). It is ok that it complains about the object, but it should start "fetching packs". I also updated an index that is needed when using git/cogito over http -- so try again to see if that's better.

The silly proxy shouldn't be a problem. I hope tongueout

(Very cool to see you're keen on playing with Cogito/git -- they are extremely good tools. The initial cg-clone will take a while, as it has to download ~200MB. The good news is that it's the complete Moodle history.)

Once you've got it cloned, do

  cg-branch-add MOODLE_15_STABLE http://locke.catalyst.net.nz/git/moodle.git#MOODLE_15_STABLE

  cg-fetch MOODLE_15_STABLE

And then you'll be able to compare the two branches. Run gitk for a visual representation of what commits are where. Or do

  mkdir patches

  git-format-patch --mbox -o patches MOODLE_15_STABLE master

and it will export the patches that are in the artena-tairawhiti branch and not in MOODLE_15_STABLE. Cherry-pick what you need from there wink

In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Humm, it seems I was using an old set of tools. I have downloaded and built the latest and greatest and it starts to clone the tree. But a few minutes later, it stops with:
Getting pack 9cbe4a5eb777d4ee535f08feb471e812208ed3a5
which contains 7004cdf821ab5ddcded7819dea34015b0e84cd9a
error: Unable to get pack file http://locke.catalyst.net.nz/git/moodle.git//objects/pack/pack-9cbe4a5eb777d4ee535f08feb471e812208ed3a5.pack
The requested URL returned error: 404
error: Unable to find 7004cdf821ab5ddcded7819dea34015b0e84cd9a under http://locke.catalyst.net.nz/git/moodle.git/
Cannot obtain needed blob 7004cdf821ab5ddcded7819dea34015b0e84cd9a
while processing commit b065a5cb7f757dd6e271249cb49e19e8c34b26ce.
Waiting for http://locke.catalyst.net.nz/git/moodle.git/objects/f0/6a06d24eee0b7819e2aaf48ad0e255301394e0
Waiting for http://locke.catalyst.net.nz/git/moodle.git/objects/5e/0e0d41f781d53344fa67b5e5a0138b586e2946
cg-fetch: objects fetch failed
cg-clone: fetch failed
I have tried cloning the MOODLE_15_STABLE branch, and it also stops at the middle of the process. I have been able to clone the "master" branch however, so I guess there are a few other missing files somewhere.

Saludos. Iñaki.



In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Patrick Li -
This is because you don't have a *bleeding edge* version of git. Older version does not handle pack downloading correctly. I think the most recent version of git is 0.99.9d, make sure you have that.
In reply to Patrick Li

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I have 0.99.9c, dated 2005.11.03. It was the latest available friday night, when I downloaded and compiled it.

I'll have a look again, and will try with 0.99.9d if it's available wink

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I have tried with cogito-0.15.1, git-core-0.99.9d, and I get this:

$ cg-clone http://locke.catalyst.net.nz/git/moodle.git#mdl-artena-tairawhiti
...
...
Getting pack 9cbe4a5eb777d4ee535f08feb471e812208ed3a5
which contains 7004cdf821ab5ddcded7819dea34015b0e84cd9a
error: Unable to get pack file http://locke.catalyst.net.nz/git/moodle.git//objects/pack/pack-9cbe4a5eb777d4ee535f08feb471e812208ed3a5.pack
The requested URL returned error: 404
error: Unable to find 7004cdf821ab5ddcded7819dea34015b0e84cd9a
 under http://locke.catalyst.net.nz/git/moodle.git/
Cannot obtain needed blob 7004cdf821ab5ddcded7819dea34015b0e84cd9a
while processing commit b065a5cb7f757dd6e271249cb49e19e8c34b26ce.
cg-fetch: objects fetch failed
cg-clone: fetch failed
Any ideas?

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -
Actually -- I tested this earlier today and it's in fact not working over HTTP. There must be a bug somewhere in git. I've posted 10 minutes ago to the git mailing list asking about it: http://marc.theaimsgroup.com/?l=git&m=113131410007771&w=2

Not your fault! I'll post again with a fix as soon as I have it...
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I have downloaded git-0.99.9g and tried again. The first time I wasn't able to clone the mdl-artena-tairawhiti branch, but could clone the master branch.

On a second attempt (several hours later), I was able to clone the artena branch succesfully. Martin, have you done anything to your repository recently?

Saludos. Iñaki.

In reply to Iñaki Arenaza

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Martín Langhoff -

Yes, re-packed and re-indexed last night. Not sure if it was a small bug in git's http support or a mistake on my part. But it's going now... wink

To see the relevant changes, do cg-log auth/db enrol/database. Or you can do gitk auth/db enrol/database. The branch you're looking at used to have a strict set of changes, only related to database enrolment & authentication, but I've recently merged patches from a huge branch we have of local improvements (mostly 1.6 stuff), called mdl-local.

So now, instead of comparing it with MOODLE_15_STABLE, compare it with mdl-local:

  cg-branch-add  mdl-local http://locke.catalyst.net.nz/git/moodle.git#mdl-local

  cg-fetch mdl-local

And then you'll be able to compare the two branches. Run gitk for a visual representation of what commits are where. Or do

  mkdir patches

  git-format-patch --mbox -o patches mdl-local master

Starting gitk will probably be really slow. Run it like this:

  gitk --max-count=1000 master mdl-local 
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by N Hansen -
Martin-Is there any chance that this Moodle-OSCommerce integration (or any other aspect of multi-enrol) will allow for differing enrollment periods for different students? E.g student pays $100 and gets to enroll for 100 days, student pays $200 and gets to enroll for 200 days.
In reply to N Hansen

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Patrick Li -
It doesn't at the moment. As it is designed for fix-term courses.

In a brief thought this will not be too hard to do but we need to get moodle-oscommerce integration finalized first.
In reply to Martín Langhoff

Re: Multi-enrol changes for 1.6 -- drivers wanted!

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you just upgrade from pre-multienrol to multienrol, Moodle should continue to work correctly -- help us double check that it works for you.

I'm afraid it doesn't (at least not 100% cleanly). As part of the database upgrade, it says:

1146: Table 'moodle.mdl_couse' doesn't exist
         
   
 

Error

It seems there is a small typo (prefix_couse instead of prefix_course) at line 1661 of lib/db/mysql.php (line number corresponds to MOODLE_16_MULTIENROL branch). Ooops! I see there is the same typo in lib/db/postgres7.php (line 1403). I guess "copy & paste" is the culprit here wink

Saludos. Iñaki.