Coupon

Blocks ::: block_coupon
Maintained by Sebsoft Plugins, 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:
643 sites
449 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 Plugins (Lead maintainer)
Rogier van Dongen
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • J. F.
    Fri, 23 Sep 2022, 5:36 PM
    @Robin
    ty for your answer. i will look forward to hear from you.
  • Rogier van Dongen
    Mon, 26 Sep 2022, 10:56 PM
    @J.F.
    Would it be possible for you to file an issue in the tracker possibly accompanied with screenshots or a screenrecording?
    If that would expose too much information another way of sharing could be discussed.
    "On the first visit, the field with the filled-in voucher code does not appear" <- This makes me wonder if the signup page has the correct scope. If the form displayed is in fact the signup form as provided by the coupon block; it forces this field before anything else (this is the only added field; the rest is "the" core signup form). It _could_ be empty if the code isn't being passed through, but at least the field itself must be visible.
    The other thing that makes me wonder: the custom (extended) signup form performs a validation on the coupon code and isn't just a required field, but also actually checks whether or not the code is valid. This basically means it shouldn't be possible to get past the custom signup page if the coupon field is left empty or if the code doesn't validate.
    Contact me if needed, either through github or by personal message.
    Thanks and cheers
  • Rogier van Dongen
    Wed, 28 Sep 2022, 10:25 PM
    New version is here!
    We've differentiated between Moodle before 4.0 and from 4.0 onwards.
    We will, unless it's extremely critical, not update the Moodle 310 and 311 branch version anymore. You're encouraged to move on to newer Moodle.
    Refer to the changelog for a more detailed overview, but the most important change is:
    You can now configure "coursegrouping" coupons, which will let the end user choose X out of Y possible courses.
    Important note: the coursegroupings are to be configured separately. The generator interface only displays a dropdown to choose the actual coursegrouping for which to generate coupons.
    Therefore, a explanatory name of the grouping is highly recommended (the generator interface/steps will not provide you with more than the grouping name).

    Cheers!
  • J. F.
    Wed, 5 Oct 2022, 3:55 PM
    @Rogier
    Thank you for your response.

    I've made two screenshots:
    https://cloud.shk.nrw/index.php/s/jwCaZSzH767pgrR

    The first one, without the voucher field, appears when the QR Code is scanned for the first time and not visited the site before.
    The second one, with the voucher field, appears when the site was visited in the past or the code is scanned a second time.
    I can repeat that and every time by deleting the cookies and the history, visited pages, it is the same. And it doesn't matter if I just visite the start page or scan the code. On the first scan I can't see the voucher field and I am not enrolled in course.

    The funny thing is, you can see the difference in the internetadress... So i am guessing it has something to do with your description and the passing through of the code. But I don't know how to solve this.
  • Rogier van Dongen
    Wed, 5 Oct 2022, 7:32 PM
    @J.F. Thanks you for those; it clarifies pretty much what I thought was the issue already.
    There's a pretty basic and easy solution, but this would involve what's known in Moodle as a so called customscript (it's a way in Moodle to override any "user" script).
    You will need direct access to the Moodle dataroot/server for this as well as the ability to change config.php.
    It's more or less as simple as (from the top of my head):
    - configuring a $CFG->customscripts entry in config.php (points to a physical disc location. Somewhere inside moodledata root is preferred).
    - dumping a file there: /login/signup.php
    - contents of that file should be extremely simple (do NOT include config.php there): redirect(new moodle_url('/blocks/coupon/view/signup.php'));exit;

    The exit statement is kind of surplus.
    Please mind: it should still work but I have no idea if or when Moodle might deprecate the customscripts ideology. We've not heard about broken sites yet but I do realize this specific "coupon signup" functionality isn't used that much.
    I'd advise you to try this method and see if it works. If it doesn't, please get back to me (and don't forget to remove the customscript again).
    This would only be a temporary solution by the way: I'm working on a more reliable, easy to deploy and stable solution that will make configuration much easier. It might take a bit of time because I'm up to my ears in other projects at the moment (I'd be able to speed this up if it were a paid project; as an employee I can't make priority decisions).
    Cheers and good luck!
  • aziz vefa
    Thu, 6 Oct 2022, 6:12 AM
    Hi. We've updated the plugin to the latest version on our Moodle site (3.11). Enabling/disabling the QR code for the pdf file is not working. The QR code is always there. Also, wouldn't it be nice to have a button that has the same link as the QR code? It's easier to click on a button instead of scanning the QR code. Thank you.
  • Rogier van Dongen
    Thu, 6 Oct 2022, 4:15 PM
    Hi Aziz,
    WOuld that, by any chance, be the preview mode?
    I've tried to reproduce, but when I uncheck the box to include a QR code, there's no QR code in the generated PDF file(s).
    However, the preview mode in fact does display the QR code regardless of the checkbox state.
    Could you confirm this?
    Cheers
  • aziz vefa
    Thu, 6 Oct 2022, 8:55 PM
    Hi Rogier,
    Thank you for the quick response. Yes, you are absolutely right. I confirm that preview mode is showing the QR code regardless of the enable/disable checkbox, but I see there is no QR code after coupon generation.
    Apart from this, we would like to add a "click here button" instead of scaning the QR code and insert the URL that includes the enrolment key that takes the users to the sign-up page. Would you please tell me the correct file to edit to insert that URL? Thank you very much.
  • Robin de Rooy
    Thu, 13 Oct 2022, 5:08 PM
    Dear Rogier,

    Is it somehow possible to name the coupons using their batchname? Now all generated coupons have the same (base)filename: coupon_xx.pdf.

    Reason: if you want to give a user 2 coupons at once to give access to different modules (in time) I need to extract the two batches in separate folders and rename the files. This can be easily solved if the pdf-(base)name is the batchname_xx.pdf.

    Kind regards,
    Robin de Rooy
  • aziz vefa
    Tue, 22 Nov 2022, 5:07 AM
    Hi. After installing the update, we are not able to see who claimed the used keys anymore. There is a column for it, but it's empty. Also, sometimes students are not able to enroll with the key. When we check it, it seems it's not used but the system doesn't let them enroll automatically. Please help. Thank you.
  • J. F.
    Wed, 23 Nov 2022, 6:00 PM
    @aziz:
    Is it the same problem with the enrollment described by me in the posts at the 17th of August and 5th of October?
  • Rogier van Dongen
    Wed, 23 Nov 2022, 6:11 PM
    @aziz
    Could you describe more of the issue, preferably in the tracker?
    Please include version, screenshots, workflow (steps to reproduce), whether or not you may have changed the codebase and all possible other information?
    Using the latest version, I cannot reproduce the fact coupon codes would remain unclaimed or in any way disappear from view.
    Cheers
  • J. F.
    Wed, 23 Nov 2022, 6:55 PM
    @Rogier:
    Is in the latest version my problem solved?

    I am having some problems with your solution because I have less experience with coding. So I don't know exactly what to write inside the config.php. Next, I already have the signup.php inside the location.
    Simply adding the redirect line in the existing signup.php brought no solution.

    Thanks for your time and response!!!
  • Rogier van Dongen
    Wed, 23 Nov 2022, 7:08 PM
    @J.F.
    Unfortunately, not resolved.
    Having said that, I've started on a specific plugin that will resolve your issue once and for all with a "correct" scope (more targeted towards a non hack-ish way). The idea is fairly simple and I sincerely hope to be able to push this to our repositories the week before Christmas (having it added here in the plugin directory is of a later concern so it would only be available from the repository until it'll be added here).
    Thanks for your patience!
    Cheers
  • Rogier van Dongen
    Mon, 9 Jan 2023, 8:34 PM
    @J.F.
    Please view our public repositories. In the week before Christmas a new plugin has been made available (2, actually) that are related to coupon and can or should aid in resolving your issue.
    They haven't been made available to the Moodle plugin directory yet but should be available from moodle.org in the (near) future.
    If you have any questions regarding usage or installation please ask (or file an issue in the dedicated issue tracker).
    Cheers
Please login to post comments