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