Coupon

Blocks ::: block_coupon
Maintained by Sebsoft BV, 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.
Latest release:
647 sites
431 downloads
105 fans
Current versions available: 5

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

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

Comments RSS

Comments

  • Thodoris Pilarinos
    Thu, 27 June 2019, 2:25 PM
    I have the same issue. When I create a new batch of coupons there is a message in moodle with a link to the files for download and an email is sent containing the same link. I have tried both ways to download the files and none is working. There is always a message that notifies you these files have been downloaded.
  • Rogier van Dongen
    Thu, 27 June 2019, 3:19 PM
    @guiseppe/teo,
    is it possible for either of you to confirm that there are in fact zip files (coupon should be in the name, along with a code) containing the generated coupons in the moodle data directory?
    Even though the new version has been tested by multiple persons seperately and we've never encountered this specific issue ourselves, something is clearly not working right.
    Thanks in advance, cheers.
  • Wade Colclough
    Mon, 1 July 2019, 6:54 PM
    Hi, recently deployed this plugin and it has alot of nice features however I have been unable to receive any emails from it when sending coupons to specific recipients. The Moodle site has no issues sending emails (registration, bulk messages etc) but this plugin always reports the coupons as "Sent? No", when checking the scheduled date its always the date of issue e.g. 01/07/2019 but with a time of 12:00AM .

    I've also noted that the cleanup tab cannot be accessed with the below error:
    SELECT COUNT(*) FROM (SELECT MOODLELIB.UNDO_MEGA_HACK(MOODLELIB.TRICONCAT(c.id, '-', e.id)) as idx,
    c.submission_code as coupon, e.*, null as action
    FROM m_block_coupon c
    JOIN m_block_coupon_errors e ON e.couponid=c.id) AS t
    [array (
    )]
    Error code: dmlreadexception
    line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 277 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->query_end()
    line 1179 of /lib/dml/oci_native_moodle_database.php: call to oci_native_moodle_database->query_end()
    line 1571 of /lib/dml/moodle_database.php: call to oci_native_moodle_database->get_records_sql()
    line 1109 of /lib/dml/oci_native_moodle_database.php: call to moodle_database->get_record_sql()
    line 1644 of /lib/dml/moodle_database.php: call to oci_native_moodle_database->get_record_sql()
    line 1854 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
    line 141 of /blocks/coupon/classes/tables/errorreport.php: call to moodle_database->count_records_sql()
    line 170 of /blocks/coupon/classes/tables/errorreport.php: call to block_coupon\tables\errorreport->query_db()
    line 84 of /blocks/coupon/classes/tables/errorreport.php: call to block_coupon\tables\errorreport->out()
    line 119 of /blocks/coupon/renderer.php: call to block_coupon\tables\errorreport->render()
    line 77 of /blocks/coupon/view/errorreport.php: call to block_coupon_renderer->page_error_report()
    Continue

    Any help would be very appreciated.
  • Rogier van Dongen
    Mon, 1 July 2019, 7:05 PM
    @Wade, sent you a private message. Thanks for reporting, we'll look into it ASAP.
    @Teo / Guiseppe: there will be an updated version of the plugin soon. Reason for not finding the archive of coupons when downloading turned out to be character conversion (the download option required ALPHANUMEXT as parameters, so basically all letters, number plus underscore and dash character). This will be fixed in the new version.

  • Anisorf Avecok
    Fri, 7 Feb 2020, 1:10 AM
    Hi, first of all thanks for your work on coupon block, it is a great contribution to the moodle community.

    I would like to ask some (development) guidlines, since I would like to use it in a little bit different scenario where the coupons are not personalized nor specific to a course, but one coupon code can be used to enroll a user in only one course.

    With one coupon code a user (whichever loged-in user) could enroll only to a course that he will choose (this means that the coupon code is not attached to a specific course).

    From a user point of view, I immagine that:
    - a user will click on a course that he/she is interested in,
    - this redirects him on the enrol page (moodle/enrol?id=course_id) where he has the coupon code field and the submit coupon
    - he enters the coupone code and with that he gets enrolled to the specific course. From this point on the coupon code is claimed and can't be used any more.
    Also if there is a different flow that can easy the implementation of my user case, I accept any suggestions.

    Thanks in advance,
    Frosina
  • Andy Hill
    Sun, 1 Mar 2020, 4:32 PM
    Hi Guys, just tried to use the plugin after upgrade to moodle 3.8 and when clicking on signup with coupon code it gives this error:-, tried uninstalling the plugin and re-installing but no joy.

    Coding error detected, it must be fixed by a programmer: verify_https_required() cannot be used anymore.

    Please speak with your admin to resolve this error

    Any help or fix would be great as love this plugin.
    Thanks
  • Alessandro Iannella
    Wed, 18 Mar 2020, 5:25 PM
    Hello... does anyone know if it's possible to use predetermined codes instead of generating them?
    Thank you
  • Rogier van Dongen
    Mon, 30 Mar 2020, 7:21 PM
    Hello Allessandro,
    Unfortunately, this is not a possibility at this very moment.
  • alfonso marotta
    Tue, 31 Mar 2020, 5:45 PM
    Hi, i need to switch language from "en" in "it", i have seen a folder callede "lang/en" i have created "lang/it" and i have made some translation from the file "block_coupon.php" now how can i swith into it language?
  • Rogier van Dongen
    Tue, 31 Mar 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
  • Rogier van Dongen
    Thu, 2 Apr 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
  • Owais Sonija
    Wed, 8 Apr 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?
  • Rogier van Dongen
    Fri, 10 Apr 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
  • Brendan McNamara
    Mon, 7 Sept 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'"}
  • Brendan McNamara
    Mon, 7 Sept 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?
Please login to post comments