Blocks: Coupon

block_coupon
Maintained by Picture of Sebsoft PluginsSebsoft Plugins, Picture of Rogier van DongenRogier 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.
467 sites
332 downloads
71 fans
Current versions available: 3

SEBSOFT COUPON PLUGIN


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.


- WARNING:

  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.

  This means the PNG images should _always_ be stored as 24-bit true colour images.

  _Do not use 32-bit_ (true colour + transparency)!

  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.


INSTALLATION INSTRUCTIONS


- 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!


PLACEMENT OF THE PLUGIN


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.


GENERAL CONSIDERATIONS


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).


Screenshots

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

Contributors

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 Rogier van Dongen
    Tue, Mar 31, 2020, 5:49 PM
    Hi Alfonso,
    it looks like you followed the correct initial way for testing purposes. Have you cleared your Moodle caches already? If this does not help there might be something in the way on a different level.
    But really, the correct way to add a new language is through AMOS. This way everyone can enjoy your translations and the Italic translation will be available through the language packs installer in Moodle itself (saves a lot of hassle).
    For more information, see https://lang.moodle.org/
    Cheers, Rogier
  • Picture of Rogier van Dongen
    Thu, Apr 2, 2020, 4:12 PM
    Another new version is here!
    This time we've changed the length of the batchid to 255 characters, since 40 characters just wasn't sufficient for some of the users of this very plugin.
    Cheers! Rogier
  • Picture of Owais Sonija
    Wed, Apr 8, 2020, 11:07 PM
    Can you someone how to use this plugin and how to generate voucher (coupon) codes for different courses? Any video tutorial or screenshots?
  • Picture of Online earning tricks hindi
    Fri, Apr 10, 2020, 10:18 PM
    Thanks for the info
  • Picture of Rogier van Dongen
    Fri, Apr 10, 2020, 10:23 PM
    @Owais Sonija
    You can find an incomplete user guide on the bitbucket repository in the downloads section for now (see "source control url" earlier on this page).
    Do note we are in the process of migrating several plugins to Github, so in time, a more complete user guide (and updated repository url for the plugin) will become available.
    Cheers, Rogier
  • Picture of Brendan McNamara
    Mon, Sep 7, 2020, 4:39 PM
    I am trying to use the API to generate a coupon, however when when I use :
    http://127.0.0.1/moodlenew/webservice/rest/server.php?wstoken=thygsksiweuyw6wyhkd7hdtejkedduy&wsfunction=block_coupon_generate_coupons_for_cohorts&moodlewsrestformat=json&email=email@email.com&amount=1&cohorts[0]=1
    I get the error message:
    {"exception":"invalid_response_exception","errorcode":"invalidresponse","message":"Invalid response value detected (Scalar type expected, array or object received.)","debuginfo":"Scalar type expected, array or object received."}

    If I change it to http://127.0.0.1/moodlenew/webservice/rest/server.php?wstoken=thygsksiweuyw6wyhkd7hdtejkedduy&wsfunction=block_coupon_generate_coupons_for_cohorts&moodlewsrestformat=json&email=email@email.com&amount=1&cohorts=1
    I get the error message:
    {"exception":"invalid_parameter_exception","errorcode":"invalidparameter","message":"Invalid parameter value detected (cohorts => Invalid parameter value detected (Only arrays accepted. The bad value is: '1'): Only arrays accepted. The bad value is: '1')","debuginfo":"cohorts => Invalid parameter value detected (Only arrays accepted. The bad value is: '1'): Only arrays accepted. The bad value is: '1'"}
  • Picture of Brendan McNamara
    Mon, Sep 7, 2020, 9:51 PM
    When creating a coupon you can specify the enrolment period. Should this automatically remove a user from the cohort when the enrolment period is up?
    If so this isn't happening for me. Is there anything else I need to do to get this to work?
  • Picture of Rogier van Dongen
    Mon, Sep 14, 2020, 6:18 PM
    Dear Brendan,
    Thanks for the heads up, the first service call is basically the correct one, but there seems to be something wrong with the result of the call (which you may have noticed due to the "invalid response value" error).
    The cohort enrolment is not cleaned up as far as I can see (i.e. it does not remove the enrolment).
    I'll be looking into these issues and a new version can be expected soon where both of these will be addressed.
    Cheers,
    Rogier
  • Picture of Rogier van Dongen
    Mon, Sep 14, 2020, 11:14 PM
    Another new version is here!
    This time we've looked into and fixed the issues as indicated by Brendan as shown above (mon, sept 7th 2020).
    Cheers! Rogier
  • Picture of George Shomali
    Tue, Sep 22, 2020, 4:13 PM
    Hello there,
    I've installed the plugin on moodle 3.9.1, works great, however, I have an issue with Personalised coupons, they got generated, but are not sent. Can any one help me in this?
    I chose to generate coupons to non-registered users so that they can sign up using the coupon code using (https://mymoodle.localhost/blocks/coupon/view/signup.php?id=37)
    Appreciated!
    George
  • Picture of Rogier van Dongen
    Tue, Sep 22, 2020, 4:28 PM
    Hi George,
    Can you confirm your background tasks are running? Sending of personalised coupons is done apart from the coupon generating process due to the possibly lenghty process.
    If you have access to the database tables themselves (if not you could install the local_adminer plugin to get access from within moodle but you'd have to know the db credentials), can you also see if the "issend" (excuse the typo) field is marked 0 or 1? You should also be able to see this through the coupon overview tables in the plugin itself. If marked as 0 (or "no"), they're definitiely not sent. If marked as 1 (or "yes") they should have been sent out and the problem is likely to be beyond the plugin scope.
    Thanks for your reply in advance,
    Cheers,
    Rogier
  • Picture of George Shomali
    Tue, Sep 22, 2020, 5:02 PM
    Hi Rogier,
    I checked the database tables, the issend was set to 0. I forced run the background tasks using the cron.php, then the everything went fine, the emails were sent and the status "issend" is set to 0.
    Thanks for the useful hint and help.
    Regards,
    George.
  • Picture of George Shomali
    Tue, Sep 22, 2020, 5:03 PM
    Correction to the previous post - the new status "issend" is set to 1
  • Picture of Brendan McNamara
    Thu, Oct 22, 2020, 7:13 PM
    Thanks for making the update for the cohort clean-up, however I am still having an issue with the coupon not removing users from a cohort. I have installed the latest version of the coupon plugin and have run a test where I do the following:
    1) Create a coupon with enrolment in a cohort and set the enrolment period to 5 minutes.
    2) Log in as a user and redeem the coupon - the user is then added to the cohort and has access to all the courses associated with it.
    3) Wait 5 minutes to see if the user loses access to the courses. This doesn't happen and checking the cohort the user remains added to it, seemingly indefinitely.

    I have tried running the cron.php to see if this is needed to remove the users but that doesn't help.
    Any help you can give will be much appreciated.
  • Picture of Hiro Nakamura
    Tue, Oct 27, 2020, 2:29 PM
    Hello.
    On the "Site administration / Messaging / Notification settings" page, I understand that there are two notification settings for coupons available.
    - Coupons generated notifications
    - Personal coupons sent out notification

    What is the difference between them?

    Also, if I have both enabled, I receive two e-mails or web notifications with the same text when a coupon is issued.
    Is this correct behavior?
1 2 3 4 5 6 7 8 9 10
Please login to post comments