Giter Club home page Giter Club logo

moodle-block_qrcode's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

moodle-block_qrcode's Issues

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

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

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

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.

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.

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.

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

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.

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

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.

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.

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.

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.

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.