Naming New Plugin

Naming New Plugin

by Michael Backus -
Number of replies: 4

I'm planning to create a new submission type that uses QR codes to quickly grade assignments completed in class. The most appropriate name is qrcode, but it looks like there is already a qrcode plugin. Since mine is a submission type is it okay to use the name qrcode, or will there be a conflict? Also, I have already created an activity type called qrcode that is installed on my local server. Will it cause problems to have an activity and a submission plugin with the same name?

Average of ratings: -
In reply to Michael Backus

Re: Naming New Plugin

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

If it's a custom plugin that you don't intend on sharing - I'd advise you prefix it with the initials of your organisation name - just in case someone does write a plugin with the same name and you want to move to using that instead of your custom plugins. If you would like to share it, you will need to rename the activity plugin so it doesn't conflict with the other one, but you can use the same name for both as the actual name is the full frankenstyle prefix.

Also - Moodle does already have a QR code library as part of tcpdf so you might be able to re-use that instead of including a separate lib if you're doing something straightforward - here's an example of it's use:

require_once($CFG->libdir.'/tcpdf/tcpdf_barcodes_2d.php');
$qrcodeurl = $CFG->wwwroot;
$barcode = new TCPDF2DBarcode($qrcodeurl, 'QRCODE');
$image = $barcode->getBarcodePngData(15, 15);
echo html_writer::img('data:image/png;base64,' . base64_encode($image));

I discovered that by accident when adding QR code support to the attendance plugin:
https://github.com/danmarsden/moodle-mod_attendance/blob/master/password.php

Average of ratings: Useful (1)
In reply to Dan Marsden

Re: Naming New Plugin

by Michael Backus -

Thanks for your reply. I finally submitted the activity version of my plugin to the Moodle plugins directory: https://tracker.moodle.org/browse/CONTRIB-7476

Source code for the activity version

Source code for the submission version (not working)

Looks like the frankenstyle name for my activity plugin will be mod_qrcode. I'm guessing that means the frankenstyle name for my submission plugin would be something like mod_assignsubmission_qrcode. I named the activity module GradeQR. I assume that means I'll have to name the submission plugin something else (assuming I can figure out how to get it to work). Is my assumption correct?

Thanks for the tidbit about generating QR codes. I'm currently using goqr.me, but I'll update my plugin to use your suggestion as soon as I have some free time.

In reply to Michael Backus

Re: Naming New Plugin

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

mod_ is the prefix for activity modules.

assignsubmission_ is the correct prefix for an assignment submission plugin (without the 'mod_' part).

For a full list of the plugin type prefixes (and the locations where their files should be stored) take a look at: https://docs.moodle.org/dev/Plugin_types


Average of ratings: Useful (1)
In reply to Michael Backus

Re: Naming New Plugin

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

yeah - the QR code work in the attendance plugin was originally written by someone else who started using goQR.me too. The goQR.me site states "The easiest way to help us to keep this online for free is to link to us on your website" 

If you want to continue using goQR.me in your plugin you should do 2 things prior to approval in the plugins db.

  • In the plugins db entry - make it really clear that goQR.me is being used to generate the QR codes.
  • Ideally in the UI for teachers, include some information to say that the QR code was generated by goQR.me.

I started down that path and was looking at allowing people to install the local_qrlinks plugin to generate them locally, but then accidentally discovered the qr support in tcpdf and just rewrote it all to use that instead.

Average of ratings: Useful (1)