I'm in desperate need of having a subscription service for my Moodle site. I need to charge one fee that will give access to the sites exams for a period of a year...
I see it's easy enough to setup a charge for enrolling in to a single course, but when it comes to a subscription charge upon registration things get a little murky.
I've had a look here, http://docs.moodle.org/en/Improved_Payment_Plugin and at other posts throughout the forum but have yet to find anything that can help me out.
Is there a way I could mimic the yearly subscription? For example I will be offering 6 exams throughout this period so could I do something like:
if you enroll you will be charged X and will have access to all courses/exams but after 12 months your 'subscription' will expire and you'll need to enroll again? I was going to have each exam as a seperate course, but using this method I will have to have all exams under one course wouldn't I?
Please, any help would be very much appreciated as I'm still very much a moodle newbie...
Thanks for your time!
Hi Mark
You can do a yearly subscription by setting the Enrolment duration in your course settings to 365 days. That means that students will be automatically unenrolled from the course 365 days after joining, so they would have to join the course again... and therefore pay again.
For your other issue, have you considered using a metacourse? That way, you could control the enrolments and the payment in one master course, and have your exams in seperate courses which inherit their enrolments from the master course.
Have a look at http://docs.moodle.org/en/Metacourses for more info about metacourses.
There's a stumbling block unfortunately, I need the subscription to last for 2 years. There's no way I can bill half the fee yearly as it needs to run alongside another subscription that is set on a two year cycle.
Does anyone have any ideas on how to get a course to last for two years?
I just would like to clarify though if you don't mind??
I'm basically looking at creating a master course, that will house quizzes in the form of meta courses. A new quiz is added every two months to the master course.
That's straight forward enough, but I'm a little confused as to how I can mimic a subscription... the main problem is that not everybody is going to start at the same time. So if I set the master course to last two years and charge the 2 year membership amount on enrollment, someone that 'subscribes' to that course 6 months down the line will only get a year and a half of that course, correct?
I need to be able to cater for people to sign up at random times and ensure that they have access to the meta courses for two years from that point... if that makes sense?
Thanks for all help so far, very much appreciated!
You don't need meta courses for that. Disable the from to dates and set the Enrolment duration to 365 days.
Really I need a subscription service, you pay x for 2 years and during that time you can access courses.
Any ideas?? I'm really very stuck so any more help would be very much appreciated.
Can I hard code a 730 day option to appear in the enrollment duration field at all?
Can I hard code a 730 day option to appear in the enrollment duration field at all?
It is already there in the course. Or are you trying to limit the user's enrolment?
This is something that has to be asociated with the course, not the user. However, there are ways and there are ways.
The database has a field in the mdl_user table called firstaccess. This is a coded date so all you need do is create an sql statement to automatically run on a daily basis that will turn the active field to off if the date exceeds 730 days.
So to be crystal clear, I need for the 730 days to start counting down from the date they enroll, be it tomorrow, or on any random date in the future... if a person enrolls tomorrow, they need to be un-enrolled on 11/12/11. If they enroll on 23/03/10 they must be un-enrolled on 23/03/12.
I was hoping to use a paypal subscription, but your unable to offer them through Moodle, correct?
So next idea was to have a parent course that cost the two year subscription fee to enroll, then you would get access to the child courses (meta) for a duration of 730 days starting from the date you signed up to the master course.
Would the SQL statement you mentioned be able to handle that? Or is there a better way do you think?

In the mdl_course table the "enrolperiod" field limits the duration of an individual enrolment. Currently, the maximum number is 365 days. In the database, this is stored as seconds, 31536000 being the number of seconds in 365 days. So, set the field to 365 days in the Course settings. Come to the database, open the table, edit the field to read 63072000 that being the number of seconds in 730 days. If you want to do this for all your courses, then it may be quicker to set it by SQL. In this case it will read something like:
UPDATE `moodle`.`mdl_course` SET `enrolperiod` = '63072000';
But my SQL is a little rusty so do not take my SQL as being accurate, so it would be easier to use phpMyAdmin.
A bit more - added about 20 minutes later
A little further investigation reveals an even simpler method.
If you go to your text editor, and it is not Windows Notepad, something like Notepad++ or TextPad or Crimson Editor, or anything in Linux that saves as a UFT-8 file, and open the file course/edit_form.php. Scroll down to abut line 240 and you should see this code:
$periodmenu=array();
$periodmenu[0] = get_string('unlimited');
for ($i=1; $i<=365; $i++) {
$seconds = $i * 86400;
$periodmenu[$seconds] = get_string('numdays', '', $i);
This is a simple piece of code, ot must be, I recognised if for what it was immediately and my PHP sklls are non-existant. Change it to read:
$periodmenu=array();
$periodmenu[0] = get_string('unlimited');
for ($i=1; $i<=730; $i++) {
$seconds = $i * 86400;
$periodmenu[$seconds] = get_string('numdays', '', $i);
And that should resolve all your problems. (Phew!!!)
Don't hit me for this, but do the seconds count down from the time a person enrolls or from a given course start date? The master course has no start or end date you see, so I need the timer to start counting down from the moment someone enrolls.
So nearly there, thanks again!
*EDIT*
Awesome, will have a look at your code for sure... plus I'm now aware that the course duration starts from the moment someone enrolls.
THANK YOU SO MUCH!
It would be a slightly better idea to change the number 360 to a variable that can be defined in the config.php file, so that in future should this value need to change it can be done easily (by nearly anyone) rather than having to trawl through code that can be easily broken.
Something like this:
config.php:
$CFG->days_until_expire = 730;
course/edit_form.php:
for ($i=1; $i<= $CFG->days_until_expire; $i++) {
// ... etc ...
}
And don't forget you made this change, because if you upgrade/update Moodle it's possible you'll loose it
Now, you re going to have to do your own User page James...Just an FYI... we will have one the does all the functionality of the regular Paypal plugin.. but with subscriptions... in the next week. Hopefully this will be helpful to everyone. I will post here when it is available. PM me if you would be interested in this.
OK.. The Paypal Subscription plugin is done. It will allow you to choose between One Time Payment or Subscription. Will also allow you to set one price for initial payment and a different for ongoing subscription payment. It replaces your existing Paypal plugin. Unfortunately, we will have to recoup some costs for the moment, but here is the link if anyone is interested in purchasing it...