Blocks: Coupon

Maintained by Picture of Sebsoft Plugins Sebsoft Plugins, Picture of Rogier van Dongen Rogier van Dongen
The Sebsoft Coupon Plugin offers you the possibility to create coupons for various levels of course access. Using a coupon code, users will be enrolled into courses that are attached to the coupon.
187 sites
39 fans


The Sebsoft Coupon Plugin offers you the possibility to create coupons for various levels

of course access. Using a coupon code, users will be enrolled into courses that are attached to the coupon. That way, you can use the coupon system as voucher or vouchering system for your course(s).

There are a few different ways of generating coupons:

- Course level: this means one or more course(s) need to be selected for which the coupon is valid.

  Once the coupon code is entered by a user, he or she will be enroled in every course the coupon

  is attached to.

  A nice extra feature is, when groups are configured for a certain course, you can configure which

  course group the coupon is for. When a user claims the coupon, he or she will be added to that specific

  group in the course. This makes it possible to separate coupon users from regular users.

  You could also make specific course groups every time you generate a batch of new coupons, so there's

  some way of matching a batch of coupons to a group of users. The possibilities are numerous.

- Cohort level: this means one or more cohort(s) need to be selected for which the coupon is valid.

  Once the coupon code is entered by a user, he or she will be added as a cohort member for every

  cohort the coupon is attached to.

  NOTE: When generating cohort level coupons, there is a possibility to "connect" extra courses to

  a given cohort. One MUST know that upon doing this, the courses will at that point be added to

  the cohort enrolment sync. Without knowing this little fact, it could be "unexpected" behavior,

  even though it's a logical step.

Furthermore, coupons can be generated on two "access" levels:

- Personalized. The base of this, is either a CSV is uploaded, or a CSV is given directly in a textbox.

  The needed user information for every coupon to be generated will be the user's name, email address

  and gender.

  These coupons will then be generated and sent off to the appropriate users using a background task.

- Bulk: The base of this is simple: you generate a certain amount of access coupons, which will then

  be emailed to the pre-configured recipient or (if allowed) to an emailaddress that can be freely entered.


  Wherever possible, please use PNG images.

  Also, whenever possible, do NOT use images that have an alpha channel.

  This will MASSIVELY slow down processing time, due to internal conversion of images by TCPDF.

  On our tests, for a 300 DPI image on A4 format (2480 x 3508 pixels) with an alpha channel,

  rendering a single PDF took around 25 seconds. Taking the alpha channel out of the image,

  rendering a single PDF was reduced to around 3 seconds.

  Furthermore, whenever possible, have the coupon generator create a single PDF with all

  coupons (this is only applicable when generating coupons in "bulk" mode). The process of

  generating coupons has been optimized to only "use" the image 1 time when creating any amount

  of coupons in a single PDF. If you choose the option to create a seperate PDF for every coupon,

  the image will have to be rendered for each and every PDF.

  This has 2 major downfalls:

  1. Every PDF will roughly have a slightly bigger size than the image size (in our tests, 350 - 400 kB per PDF)

  2. Every PDF takes the full amount of time to render.

  Effectively, this means the following (using fictitious sizes):

  10 coupons, single PDF -> result is around 400 kB, rendering takes around 3-4 seconds.

  10 coupons, seperate PDFs -> result is around 4 MB, rendering takes around 35-40 seconds.


- Copy the coupon folder to your blocks directory.

- Go to the moodle admin pages (you will probably be confronted with it anyway) and install the plugin

- Configure the main settings for the plugin.

- We're set up for usage!


There are only two pages you can add the coupon block on. This is the site's frontpage

or the user dashboard (my) page. The main reason for this is because the block is the

"frontend" for users to enter their coupon or voucher code.

Administrators and users with the correct capabilities will also see the links to

the coupon administration pages and the coupon generator page.


There's two main configurations to consider when generating coupons.

For course type coupons, this plugin attempts to enrol a user through use of Moodle's

internal function "enrol_try_internal_enrol".

The Moodle documentation shows it will attempt to enrol you using manual enrolment.

For this reason manual enrolment MUST be enabled for these courses.

For cohort type coupons, a user is made a member of a cohort. That's all there is to it.

Surprise though, if you want to actually make a user have access to a course, you

probably want to configure cohort enrolment for the course.

For those paying attention, creating cohort type coupons thus enables a simple

way of enrolling users into multiple courses at once just by configuring the right

cohort enrolments in multiple courses.

That's still not to say course coupons can't be used in a similar way (using meta courses).


Screenshot #0
Screenshot #1
Screenshot #2
Screenshot #3
Screenshot #4
Screenshot #5
Screenshot #6
Screenshot #7
Screenshot #8


Picture of Sebsoft Plugins
Sebsoft Plugins (Lead maintainer)
Picture of Rogier van Dongen
Rogier van Dongen
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Abel Carreto
    Wed, 27 Apr 2016, 6:49 PM
    Thanks for this plugin, it's really useful, but I think there's a problem when enroling a user on a certaing course.

    I set manual enrolment on every course in order to enrol them. In that configuration, I specify that I want them to enrol under the role "student".

    However, once the put the enrolment code given in the coupon, they get enroled in the course, but no role is assigned (as you can see on the attachment).

    So, when the user enters the code, he's enroled correctly and can acces to the course, but he only can see the sections (no quizes... anything).

    Then, I go to the "Enroled users" page in the specific course, and what I see is that no role appears assigned to the user who entered the coupon, so I need to specify manually the role, as you can see on the imagen.

    Is there any solution for that? Anybody else?

    Thanks in advance for your help,

    Attachment 1:

    Attachment 2:

    Best regards.
  • Picture of rkLearn .
    Tue, 10 May 2016, 3:16 PM
    Is there a way to let students to use the coupon code and select the course they want to access? Thanks
  • Picture of Corey Zinn
    Fri, 7 Oct 2016, 1:53 AM
    Thank you for this plugin. It appears to work pretty well. We have what we hope is a simple question for which we are just overlooking the answer.

    We would generally be issuing coupons manually, and for a single course - although I suppose there would be the possibility of multiple courses. The coupon is generated fine and the pdf is emailed - and we can customize the image. However, the coupon doesn't list the actual course name anywhere on it. The email that is sent has the course name, but if the user loses or deletes the email and just has the pdf, there is no way of telling what course the coupon is for, except by entering the code and finding out what course the user is enrolled into.

    So now our question - is there a way to easily add the course name/s to the actual coupon that gets sent?

  • Picture of Per Oskar Westin
    Thu, 9 Feb 2017, 7:18 PM
    This seems like a great plugin, and pretty much what I am looking for. Can someone advise as to whether it will work in Moodle 3.1? I can see that the versions only go up to 3.0, but does that mean there is no way it works in 3.1?
    Any comments or help appreciated!
  • Picture of Sebsoft Plugins
    Thu, 23 Feb 2017, 5:37 AM
    It means we haven't had the time to test the plugin on later versions yet. It's on the roadmap though.
    When the new roadmap is certain, we'll post an update here smile
  • Picture of Janice Maxson
    Tue, 4 Apr 2017, 5:34 PM
    Hey! A great plugin, thank you so much for sharing it with us! I'll be definitely using it for my blog I work with lots of students, and sometimes we have some interesting events. And this plugin for coupons will fit just perfect.
  • Picture of Rogier van Dongen
    Thu, 11 May 2017, 9:36 PM
    Hello All!
    New version is here, with some massive updates!
    Be sure to read the changelog and don't hesitate to ask questions if things may be unclear.

    Relevant changes:
    Version 2017050100 (Release 3.0.0 (build 2017050100))
    * Added $CFG->wwwroot on all moodle_urls
    * Added setting to choose default assigned role (resolve issue #12: Student role problem.
    Roles were fetched by shortname = 'student', NOT foolproof)
    * Disabled sorting by 'owner' column in coupon overviews (resolve issue #13).
    * Fixed error notification when inserting to table block_coupon_courses
    * Added course name(s) to coupons
    * Changed default coupon template-main contents (language files)
    * Added filtering for progress reports
    * Added filtering for coupon overview
    * Code overhaul to comply to stricter Moodle coding standards (codechecker, Moodle phpdoc check)
    * Added course_deleted event handler
    * Added cohort_deleted event handler
    * Added custom cleaning of coupons
    * Added QR based coupon to PDF including processing
    * Added signup for QR based coupon when user is not logged on yet
    * Added possibility for signup with a coupon code (in block_coupon, when user is not yet logged in)
    * minimum required version: Moodle3 3.0

    * Thanks to everyone for their valuable input and remarks.

    Also, it is now possible to upload multiple coupon background and pick the background to use when generating the coupons (manager is limited to 10 backgrounds).
    Note: make sure you ALWAYS hit "Save" after managing your images, otherwise they're not saved from the draft area.

  • Picture of Rogier van Dongen
    Fri, 26 May 2017, 11:45 PM
    Yet Another New Version.

    In this release we added the possibility for enrolment extension coupons on a course level.
    The possibility to create enrolment extension coupons is available from the course administration menu (added as a new menu item).
    We also added a webservices to generate coupon codes or coupons and request the progress reports.

    In case of questions on functionality, don't hesitate to contact us.

  • Picture of Rogier van Dongen
    Wed, 31 May 2017, 4:33 PM
    Updated to new version.
    This resolves issue #14 where the page, after a successful login, redirects back to the customized signup page after choosing "I already have an account and want to login".
  • Picture of Rekha C
    Tue, 13 Jun 2017, 1:16 AM
    Each coupon pdf has a unique QR code with it. What can i do with the QR code? How can I stop coupons generating QR codes?
  • Picture of Rogier van Dongen
    Mon, 3 Jul 2017, 6:44 PM
    Updated to new version.
    This resolves and issue with cohort enrolment coupons not functioning as intended.
    Added is the possibility to disable including the QR Code in the generated coupons.

    @Rekha: due to lack of time, we have yet to write a comprehensive manual. In short, the QR Code enables the possibility to process the coupon without having to type it in.
    For example; when logged in in Moodle and on a device that can scan the QR Code, this method can be used to instantly scan the QR Code. The coupon code is instantly applied, so users do not have to type it in.
    It also allows users to scan the QR Code and register with your website (providing the user isn't logged in yet). The signup form is the same as the "standard" form, but also has a input field that holds the coupon code. After successful registration, the coupon code for the new user will automatically be processed.
    We're working on a manual to explain all capabilities and processes for the coupon block and hope to have it finished soon.

  • Picture of narutoget shippuden
    Mon, 3 Jul 2017, 7:08 PM
    Really nice article and definitely it will be useful for many people, Rhonda . Kindly keep update like this. I am truly delighted to glance at this blog posts, thanks for providing such information. Narutoget
  • Picture of spyros zoup
    Fri, 14 Jul 2017, 6:24 AM
    Congrats! one of the best Moodle plugins! Do you intend to add discount options when generating coupon instead of the standard 100% off?
  • Picture of Yuri Lima
    Thu, 20 Jul 2017, 5:20 AM
    Hello Rogier van Dongen. Thanks for the plug-in, it's being very useful for me, however I'm needing to give discount coupon when buying courses. For the payment method, I use native PayPal in moodle. Is it possible to do this with this plug-in?
    Thank you very much in advance
  • Picture of Yuri Molina Vale
    Mon, 9 Oct 2017, 10:14 AM
    Dear Rogier,

    Thank you very much for the coupon plug-in. It has been much usefull.

    I'd like to ask you if you could update the plug-in in order to accept the Portuguese (Brazil) language.
    For instance, in the following print you can see the strings "CUPOM" and "Enviar Cupom" in Portuguese, but the string "Please enter your coupon code here:" in English.
    Print screen:

    Is it possible to correct ?

    Thanks for your attention.
1 2 3 4
Please login to post comments