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.
233 sites
44 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 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.
  • Picture of Michael Reen
    Sat, 21 Oct 2017, 4:10 AM
    Hey Rogier,
    is it possible to see who (user account) used which coupon (for example AjsjS2jfkasajFJ2) to access the courses?
    If one coupon was stolen, we would be able to deactivate the right account.
    Best wishes!
  • Picture of Rogier van Dongen
    Mon, 23 Oct 2017, 7:01 PM
    Hi Michael,

    You could use the "Used coupons" overview tab along with the implemented filtering capabilities.
    This will provide you an overview of the used coupons/vouchers along withy their code and the user it was assigned to.
    If you'd wish to see extra filtering possibilities (for example a search on specific coupon/voucher codes), please notify me so we can incorporate it in a future release.
    Cheers! Rogier
  • Picture of Rogier van Dongen
    Mon, 6 Nov 2017, 7:57 PM
    New version is here!
    Changes for Version 3.3.0 (build 2017092500)
    * Fixed deprecated pix_url references (replaced by image_url)
    * Minimum required Moodle version: 3.3

  • Picture of Rekha C
    Tue, 21 Nov 2017, 2:14 PM
    The coupon block appears on the home page in the right column and occupies an entire column. How can I move the Coupon block to the footer?
  • Picture of Michael Reen
    Fri, 15 Dec 2017, 6:16 AM
    Dear Rogier,
    how can I notify you -> I wrote you a message on moodle! smile

    Best wishes!
  • Picture of Rogier van Dongen
    Fri, 16 Feb 2018, 9:32 PM
    New version is here!
    Changes for Version 3.3.1 (build 2017092501)
    * Added coupon code to "progress report" for validation purposes (feature request by Michael Reen)
    * Added claimed user to "used coupons" overview for validation purposes (feature request by Michael Reen)

    The additions allow for specific tracking of coupon codes in case this would be needed. For instance if you provide students their own personal code, have this registered somewhere and you want to validate whether or not students do not use someone elses code, the reports can now show this.
    Thus, In the aforementioned reports you will now find both the person who was claimed the coupon code as well as the code used.

    Do note: this is only available for Moodle 3.3 and onwards. There's no plans as of yet to backport this to older versions.
  • Picture of Phuong Hoang
    Sat, 17 Feb 2018, 1:38 PM
    Dear Rogier van Dongen,
    As I commented 2 years ago "Sun, Jan 3, 2016, 8:18 AM", Is it possible for registered users and guests to have a look at what activities and resources I have in a course first? If so, customers will be more persuasive before buying a course. A brief preview in the main course page not just a course summary.
    * P/s:
    + Most payment gateways just give a link of the course and it's hard for course creators to buy. I hope your plugin will be different.
    + Just the same as when a guest access to a course, he/ she can see quizzes, assignments, forums...However, when he/ she hits the links, moodle will appear the popup to register or to enter the coupon code to continue (available in moodle)
    Kind regards,
  • Picture of Nirav Gosalia
    Sun, 25 Feb 2018, 10:36 PM
    Hi, When i apply a coupon to a course i get this error - An error occured while trying to enrol you in the new course. Please contact support.
    On clicking on more details it opens a new page with the error "error/block coupon/error:unable to enrol"

    Can you please guide me with the next step for troubleshooting the same ?
  • Picture of Rogier van Dongen
    Tue, 27 Feb 2018, 5:16 PM
    Hi Nirav,
    Coupon tries enrolment through the use of the internal Moodle function dedicated to this.
    Looking at the code, this internal method only supports manual enrolment and will fail if either manual enrolment is not available (globally disabled) OR if the course is not configured with manual enrolment.
    Let me know if this helps!
  • Picture of Donna Betancourt
    Sat, 10 Mar 2018, 4:35 AM
    Does anyone have a screenshot of how to fill out the form? I can't figure out what to put in each text box.
  • Picture of Konstantinos Ntanos
    Thu, 15 Mar 2018, 5:47 PM
    Hi Rogier,

    Very nice plugin and especially the QR code function is really simple.
    However, I would like to ask you if there is a way to enroll some users as teachers and some as students because, if I am not mistaken, when you use a coupon you get the role that 's selected at the "Default role" (block_coupon | defaultrole) setting at plugin 's settings, the moment you are claiming your coupon and not the setting you had when the coupons where generated.
    Is there a way to generate coupons that you can assign the role this coupon will activate, so as to be able to create coupons for teachers, as well as students, that skip the "Default role" setting?
    If not, is there a possibility to have this kind of functionality in the future?

    Thanks in advance.
  • Picture of Rogier van Dongen
    Fri, 16 Mar 2018, 12:24 AM
    Hello Konstantinos,
    This is a decent feature request we've considered in the past and could be implemented in the future.
    One of the reasons we decided not to implement was that this wasn't needed at the time (long before it even landed on Moodle's plugin page).

    Do you have any thoughts on how you would track each coupon / voucher and make sure any printed or otherwise distributed vouchers are distinguishable?
    Of course you could have a specific background/logo, but I could imagine you'd want to have that information clearly stated on the coupon itself.

    I'd love to hear your input on this.
  • Picture of Konstantinos Ntanos
    Fri, 16 Mar 2018, 6:59 PM
    Hello Rogier,

    I am presenting the way I am thinking of it but of course you decide how this can be done.
    After you select your courses for example, on a new page or even maybe on the same page under the courses selection box with a drop down menu, you choose the role (custom roles would be nice too) that should be assigned to the coupons that will be generated.
    There should also be an extra column at the reports page with the role that's assigned to each coupon, to be able to filter them as well.
    Now about how this information will be stated on the coupon, I 'm thinking something simple like a parenthesis after the course name with the role in it. Something like "Thermodynamics (Student)" or "Thermodynamics (Non-editing teacher)" for example.

1 2 3 4 5
Please login to post comments