O'Reilly logo

Moodle 3.x Developer's Guide by Ian Wild

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating files with the File API

The QR Code library we are using generates an image that we need to display in our block. But what is the best way of handling the image? It doesn't make sense to generate a QR Code image every time a user views the page (as this would be very inefficient). It would clearly be far better to create the image file and then import it into Moodle's file storage area using the File API then display the image there. In this section, we explore how.

Each block will have one QR code, meaning code images can be identified by each block's instance ID (the instance ID is the ID of the row in Moodle's block table). We can generate the QR Code in Moodle's \temp directory. Then we can import the file into Moodle's file ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required