From 9d600223af6806c7e8ff11f513b9b6897d488156 Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Sat, 13 Jul 2024 10:15:00 +0200 Subject: [PATCH 1/4] MBS-9118: Button added that opens the QR code enlarged in a modal --- db/access.php | 8 ++--- edit_form.php | 2 +- lang/de/block_qr.php | 1 + lang/en/block_qr.php | 1 + templates/qr.mustache | 78 +++++++++++++++++++++++++------------------ version.php | 2 +- 6 files changed, 54 insertions(+), 38 deletions(-) diff --git a/db/access.php b/db/access.php index 8106863..179e190 100644 --- a/db/access.php +++ b/db/access.php @@ -30,10 +30,10 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => array( - 'user' => CAP_ALLOW + 'user' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'moodle/my:manageblocks' + 'clonepermissionsfrom' => 'moodle/my:manageblocks', ), 'block/qr:addinstance' => array( @@ -43,9 +43,9 @@ 'contextlevel' => CONTEXT_BLOCK, 'archetypes' => array( 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ), - 'clonepermissionsfrom' => 'moodle/site:manageblocks' + 'clonepermissionsfrom' => 'moodle/site:manageblocks', ), ); diff --git a/edit_form.php b/edit_form.php index d94f7e1..599a9a9 100644 --- a/edit_form.php +++ b/edit_form.php @@ -222,7 +222,7 @@ protected function specific_definition($mform) { $sizeoptions = [ QR_SIZE_SMALL => get_string('small', 'block_qr'), QR_SIZE_MEDIUM => get_string('medium', 'block_qr'), - QR_SIZE_LARGE => get_string('large', 'block_qr') + QR_SIZE_LARGE => get_string('large', 'block_qr'), ]; $selectsize = $mform->addElement( 'select', diff --git a/lang/de/block_qr.php b/lang/de/block_qr.php index aadaa0a..c2f4a8f 100644 --- a/lang/de/block_qr.php +++ b/lang/de/block_qr.php @@ -45,6 +45,7 @@ $string['event_start'] = 'Startdatum'; $string['event_summary'] = 'Titel'; $string['externalurl'] = 'URL'; +$string['fullscreen'] = 'Im Vollbild anzeigen'; $string['geo'] = 'Geo'; $string['geolocation'] = 'Geokoordinaten (Breite/Länge)'; $string['internalcontent'] = 'Link zu einem Abschnitt oder Aktivität'; diff --git a/lang/en/block_qr.php b/lang/en/block_qr.php index df8fc9b..e0645e1 100644 --- a/lang/en/block_qr.php +++ b/lang/en/block_qr.php @@ -45,6 +45,7 @@ $string['event_start'] = 'Start date'; $string['event_summary'] = 'Title'; $string['externalurl'] = 'URL'; +$string['fullscreen'] = 'Show in full screen'; $string['geo'] = 'Geo'; $string['geolocation'] = 'Geolocation (lat/lon)'; $string['internalcontent'] = 'Link to a section or activity'; diff --git a/templates/qr.mustache b/templates/qr.mustache index 6902d57..f4df2f4 100644 --- a/templates/qr.mustache +++ b/templates/qr.mustache @@ -47,14 +47,19 @@ {{#qrurl}} {{/qrurl}} -
- {{^qrcodecontent}} - {{#str}} nocontent, block_qr {{/str}} - {{/qrcodecontent}} -
+
+ {{^qrcodecontent}} + {{#str}} nocontent, block_qr {{/str}} + {{/qrcodecontent}} +
{{#qrurl}}
{{/qrurl}} +
+ +

{{^calendar}}

{{description}}

@@ -90,47 +95,56 @@ {{#wifissid}}

- {{#str}} - ssid_label, block_qr - {{/str}}: {{{wifissid}}}
- {{#str}} - config_wifiauthentication, block_qr - {{/str}}: {{{wifiauthentication}}}
- {{#str}} - passkey_label, block_qr - {{/str}}: {{{wifipasskey}}}
+ {{#str}} + ssid_label, block_qr + {{/str}}: {{{wifissid}}}
+ {{#str}} + config_wifiauthentication, block_qr + {{/str}}: {{{wifiauthentication}}}
+ {{#str}} + passkey_label, block_qr + {{/str}}: {{{wifipasskey}}}

{{/wifissid}} - {{#fullview}} -{{#configshortlink}} -

- - - {{#str}} - urlshortlabel, block_qr - {{/str}} - -

-{{/configshortlink}} + {{#configshortlink}} +

+ + + {{#str}} + urlshortlabel, block_qr + {{/str}} + +

+ {{/configshortlink}} {{/fullview}} +
+
{{#qrcodecontent}} {{#js}} if (typeof QRCode !== 'undefined') { + // Configuration for QR Code let config{{id}} = { - content: "{{{qrcodecontent}}}", - color: "#000000", - background: "#ffffff", - ecl: "M", // Error correction level (L, M, H, Q). - container: "svg-viewbox", // Responsive use. - join: true // Crisp rendering and 4-5x reduced file size. + content: "{{{qrcodecontent}}}", + color: "#000000", + background: "#ffffff", + ecl: "M", // Error correction level (L, M, H, Q). + container: "svg-viewbox", // Responsive use. + join: true // Crisp rendering and 4-5x reduced file size. }; - // eslint-disable-next-line no-undef + let qrcode{{id}} = new QRCode(config{{id}}); let svg{{id}} = qrcode{{id}}.svg(); document.getElementById("container{{id}}").innerHTML = svg{{id}}; + // Add event listener to button + document.getElementById("qrcodeModalButton{{id}}").addEventListener("click", () => { + // Creating the modal with the QR code content inside the button click event + require(['core/modal'], (MF) => { + MF.create({title: '{{{description}}}', body: svg{{id}}}).then((modal) => modal.show()); + }); + }); } {{/js}} {{/qrcodecontent}} diff --git a/version.php b/version.php index fe7cf8e..de0aede 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->release = 'v0.0.1'; -$plugin->version = 2024012900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024071300; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'block_qr'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_BETA; // This is considered as ready for production sites. From 8b8b2979a395c3fc88e76cd3cc8bbd6f737d49ff Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Sat, 13 Jul 2024 10:21:17 +0200 Subject: [PATCH 2/4] MBS-9118: Button added that opens the QR code,code style --- templates/qr.mustache | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/templates/qr.mustache b/templates/qr.mustache index f4df2f4..a9d01e4 100644 --- a/templates/qr.mustache +++ b/templates/qr.mustache @@ -47,19 +47,19 @@ {{#qrurl}} {{/qrurl}} -
- {{^qrcodecontent}} - {{#str}} nocontent, block_qr {{/str}} - {{/qrcodecontent}} -
+
+ {{^qrcodecontent}} + {{#str}} nocontent, block_qr {{/str}} + {{/qrcodecontent}} +
{{#qrurl}}
{{/qrurl}} -
- -
+
+ +

{{^calendar}}

{{description}}

@@ -108,15 +108,15 @@ {{/wifissid}} {{#fullview}} - {{#configshortlink}} -

- - - {{#str}} - urlshortlabel, block_qr - {{/str}} - -

+{{#configshortlink}} +

+ + + {{#str}} + urlshortlabel, block_qr + {{/str}} + +

{{/configshortlink}} {{/fullview}}
@@ -125,14 +125,14 @@ {{#js}} if (typeof QRCode !== 'undefined') { - // Configuration for QR Code - let config{{id}} = { - content: "{{{qrcodecontent}}}", - color: "#000000", - background: "#ffffff", - ecl: "M", // Error correction level (L, M, H, Q). - container: "svg-viewbox", // Responsive use. - join: true // Crisp rendering and 4-5x reduced file size. + // Configuration for QR Code + let config{{id}} = { + content: "{{{qrcodecontent}}}", + color: "#000000", + background: "#ffffff", + ecl: "M", // Error correction level (L, M, H, Q). + container: "svg-viewbox", // Responsive use. + join: true // Crisp rendering and 4-5x reduced file size. }; let qrcode{{id}} = new QRCode(config{{id}}); From 29ef31aa81516017c8c50a1ea33d180eb4f1db47 Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Sat, 13 Jul 2024 10:51:43 +0200 Subject: [PATCH 3/4] ci.yml customized --- .github/workflows/ci.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46d030b..0fd7199 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,24 +30,23 @@ jobs: strategy: fail-fast: false matrix: - include: - - php: '8.1' + - php: '8.3' moodle-branch: 'master' database: 'pgsql' - - php: '8.0' + - php: '8.2' moodle-branch: 'master' database: 'pgsql' - php: '8.1' - moodle-branch: 'MOODLE_401_STABLE' + moodle-branch: 'master' database: 'pgsql' - - php: '8.0' - moodle-branch: 'MOODLE_401_STABLE' + - php: '8.3' + moodle-branch: 'MOODLE_404_STABLE' database: 'pgsql' - - php: '8.1' - moodle-branch: 'MOODLE_402_STABLE' + - php: '8.3' + moodle-branch: 'MOODLE_404_STABLE' database: 'pgsql' - - php: '8.0' - moodle-branch: 'MOODLE_402_STABLE' + - php: '8.1' + moodle-branch: 'MOODLE_401_STABLE' database: 'pgsql' steps: From ce83d7efae34f3065796eccf289eb00454057866 Mon Sep 17 00:00:00 2001 From: Florian Dagner Date: Sat, 13 Jul 2024 10:53:43 +0200 Subject: [PATCH 4/4] ci.yml customized --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fd7199..1995235 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,7 @@ jobs: strategy: fail-fast: false matrix: + include: - php: '8.3' moodle-branch: 'master' database: 'pgsql'