Coder Social home page Coder Social logo

learnweb / moodle-block_qrcode Goto Github PK

View Code? Open in Web Editor NEW
11.0 8.0 11.0 13.95 MB

:camera: Block that provides a QR code that teachers can show on introductory slides

License: GNU General Public License v3.0

PHP 91.80% CSS 1.71% Gherkin 5.12% JavaScript 1.37%
students teachers moodle qrcode plugin slides search

moodle-block_qrcode's Introduction

Block: QR Code

Build Status

A moodle block to display a QR code link that leads to the course page. The QR code can be downloaded by teachers, e.g. to put them into introductory slides. Teachers can download the QR code as svg or png files. The administrator can upload a custom logo that is displayed in the center of the QR code, defaulting to the Moodle logo if none is specified.

This plugin is developed by Tamara Gunkel and is maintained by Learnweb (University of Münster).

Installation

This plugin should go into blocks/qrcode. Afterwards, a custom logo may be defined (see Administrators' view)

Screenshots

Students' view

The students can only see the QR code.

Teachers' view

The teachers see the QR code and the download options. If you choose png as file format, you can download a small (150px) or big (300px) image. If you choose the svg format you cannot choose a size, because it is a vector graphic that always scales nicely.

Administrators' view

The administrator can change the logo. She must upload separate png and svg versions of the same logo, which are then used in the respective QR code formats. She can also configure that no logo should be displayed inside the QR code.

Background and Motivation

We wanted to have a configuration-free, ready-to-use QR code that leads you into a course when you photograph it. Since it is a block, a teacher only needs to add it his/her your course and then see the code right away (including a "Download" button to include it into introduction slides or to print it as a handout to students). If you leave the block where it is, it will also help students switch devices (e.g. start learning on the computer and continue on a mobile device merely by photographing the QR code).

With more than 2000 courses starting every term, many of them have short names along the lines of IT or SE or other ambiguous abbreviations. Students search for these abbreviations using course search and may get some hundred, rather unrelated, results. This drives up our servers' loads and does not really help our students anyway, which is why we looked for alternative means to get them into their courses for the first time. It might make sense to activate this block by default in all new courses, hoping that teachers will put their QR codes into their introduction slides. This is made (relatively) easy as the block does not require any configuration by teachers.

moodle-block_qrcode's People

Contributors

dagefoerde avatar irinahpe avatar justusdieckmann avatar laur0r avatar ninaherrmann avatar tamaragunkel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-block_qrcode's Issues

Provide updated screenshots that show the default logo

IMO all screenshots should be changed such that they show the default logo (except the admin settings one which should intentionally display a non-standard logo).
Please update the README accordingly and let me now, so that I can change the screenshots in Moodle's plugin directory as well.

Cache invalidation for logo'ed images does not work right

$pattern = $CFG->localcachedir . '/block_qrcode/course-*-*-1.svg';
foreach (glob($pattern) as $filename) {
unlink($filename);
}

This does not work properly, because we use local caches (i.e. local to each webserver) and eight webservers. Therefore, the statement above will only delete cached images from one server, but not from the others. (Same for PNG!)

(Side note: I consider a combination of file name pattern matching and unlink harmful (who knows what the patterns will match and which files will be (accidentally?!) deleted.)

Effectively we need another form of cache invalidation that does not involve deleting. For example, append the content hash of the logo file to the cached filenames. As a result, when the logo will change, the expected cached filenames will be different so new files are created.

A cron job could take care of deleting old files. Please look for inspiration in other core plugins that use localcache to see how they clean up their old files.

We need a different default logo

The default logo does not look so good. We should consider a modification (maybe something simpler, just the M, with an added white border).

default

Use a default logo if no custom logo is specified

If no custom logo is selected, a default logo should be used. I suggest going for the Moodle logo. It is always installed with Moodle and can be read from

$CFG->wwwroot/pix/moodlelogo.png or $CFG->wwwroot/pix/moodlelogo.svg, respectively.

Ensure integer types in output_image.php

There are variables that are directly reflected in filenames of a Moodle installation:
$file = $CFG->localcachedir . '/block_qrcode/course-' . $courseid . '-' . $size . '-0';

You need to make sure that those variables (here: $courseid, $size) can never contain anything that is potentially dangerous. In this case this is simple by casting them to integer. Then, at worst, they are 0, but don't do anything wrong.

It's best to do this at the beginning, i.e. $this->size = $size; becomes $this->size = (int)$size;. courseid analogous.

Build status looks broken but isn't

The Travis badge in README.md points to Travis configured with the old repository, which is why the badge says "failing" – please update! :)

download.php can be simplified

if ($download) {
if (has_capability('block/qrcode:download', context_course::instance($courseid))) {
$outputimg = new block_qrcode\output_image($url, $fullname, $format, $size, $contextid, $courseid);
$outputimg->output_image($download);
}
} else {
$outputimg = new block_qrcode\output_image($url, $fullname, $format, $size, $contextid, $courseid);
$outputimg->output_image($download);
}

The lines within then / else are mostly identical. They could be simplified like this:

if ($download) { require_capability(...); }
$outputimg = new...

Different Logo Per Course

Hi,

Is it possible to have a different logo per course? Our Moodle Platform is multi-tenanted and we would like a different tenant logo for their respective courses.

Appreciate the assist.

Cheers,
Ray

Add link to open QR-code in new tab

Hi learnweb-team,

I'd like to propose a second link/button (e.g. next to the download button)
that opens a new window/tab in which the respective QR-code ist displayed
at maximum height.

The goal of this improvement is

  • to provide teachers with an easy way to show the QR code in class
  • as big as possible
  • without causing theme related issues (e.g. maximise via JavaScript)

Cheers,
Christian

Declare composer dependency

This is the least important, but should be done before (public) release:

Please write a composer.json that declares your dependency on QrCode.

QR Code Block Logo Not Working

Hi,

I've recently installed the QR block (in Moodle version 3.9.7) but when the "Use logo" option is selected in the configure block screen, and a logo uploaded, the QR code fails to appear on screen. The error message states that the logo is trying to pull from an invalid path, but I asked Moodle support to look into it and they couldn't find any issue with the logo's file path. They suggested it could be an issue with the block itself.

Thanks.

Add a preview in settings

Edited as per #25 (comment):

When settings are changed, particularly the logo upload, add two previews of what QR codes will look like. This allows admins to check whether the codes will look as intended. In particular, it may not be obvious from the start that there is a default logo, and that uploading just a single format type will not have an impact on all QR codes! A preview would make this more apparent.

--------- original text -------------

Hello,

Thanks for your work on this plugin.

It would be nice to add the QR code image reloading on format selecting. It is not clear for user, how it will looks like, when he/she is trying to download the png file. The image on png file could be different, because there is the possibility in the plugin settings to use different image for each format.

Best regards,
Olena Tatarintseva

Simplify output_image.php

if (get_config('block_qrcode', 'custom_logo') == 1) {
$this->logopath = $this->getlogopath();
if ($this->logopath === null) {
$file = $CFG->localcachedir . '/block_qrcode/course-' .
$courseid . '-' . $size . '-0'; // File path without file ending.
} else {
$file = $CFG->localcachedir . '/block_qrcode/course-' .
$courseid . '-' . $size . '-1';
}
} else {
$file = $CFG->localcachedir . '/block_qrcode/course-' .
$courseid . '-' . $size . '-0';
}
contains lines that are mostly similar, please simplify.

System context ID does not need to be passed around

Apparently the context ID is only used in

$file = $fs->get_file($this->contextid, 'block_qrcode', $filearea, 0, $filepath, $filename);
and always equals the system context (cf.
context_system::instance()->id);
,
context_system::instance()->id);
).

If that is correct, please do not pass the context IDs as GET parameters to download.php, but initialise it there.

-- actually, come to think about it: This is just for retrieving the logo, right? Then this shouldn't be a parameter or function argument at all. The context ID should just be obtained right where you need it, as you do in adminsettings.php.

Add utm_source=block_qrcode to (encoded) URL

It would be great to be able to trace how many people enter a course by following the QR code. With UTM Google Analytics has established a quasi-standard that is used throughout the web.

We should add such a parameter to the encoded URL so that it is present when someone opens a course by following a QR code. We would subsequently be able to measure this in Piwik or server logs. I think utm_source is suited best, but please check if one of the others has an even better fit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.