๐Ÿ“ฑ QR Code Integration Guide

Certificate Plugin - Complete Implementation
โœ… Fully Implemented & Working

๐ŸŽฏ What is QR Code Integration?

QR Code integration allows you to add a scannable verification code to your certificates. When scanned with a smartphone, it instantly verifies the certificate's authenticity and displays the student's details.

โœจ Key Benefits:
  • Instant certificate verification
  • Tamper-proof security
  • Mobile-friendly validation
  • Professional appearance
  • No manual checking required

๐Ÿ”„ Complete Flow: Design to Verification

๐ŸŽจ
1. Design
Open editor and add QR code element to your certificate design
๐Ÿ’พ
2. Save
Save layout with QR code position and size
๐Ÿ‘๏ธ
3. Preview
View QR code placeholder in preview page
๐ŸŽ“
4. Issue
Student completes course and receives certificate
๐Ÿ“„
5. Generate
System generates PDF with real QR code
๐Ÿ“ฑ
6. Scan
Anyone can scan QR to verify certificate

๐Ÿ“‹ Step-by-Step Guide

Step 1: Add QR Code in Editor

// QR Code automatically added to layout JSON { "type": "qrcode", "x": 720, "y": 475, "width": 100, "height": 100 }
โฌ‡๏ธ

Step 2: Save Layout

โฌ‡๏ธ

Step 3: Preview Certificate

๐ŸŽ“ Certificate of Achievement
This is to certify that
Hassan Eikial
has successfully completed
Web Development Course
26 October 2025
๐Ÿ“ฑ
QR Code
โฌ‡๏ธ

Step 4: Create Certificate in Course

๐Ÿ’ก Important: Make sure to select "Custom Editor" as the certificate type. This is the only type that uses your visual editor design!
โฌ‡๏ธ

Step 5: Student Receives Certificate

// System automatically: 1. Creates certificate issue record 2. Generates unique verification code 3. Creates QR code image: certificate_ABC123XYZ.png 4. Embeds QR in PDF at specified position 5. Outputs final certificate
โฌ‡๏ธ

Step 6: Verification

โš™๏ธ Technical Implementation

Preview Page (certificate_preview.php)

QR code rendered as placeholder for visual reference:

else if (element.type === "qrcode") { // Create QR placeholder div const qrDiv = document.createElement("div"); qrDiv.style.width = (element.width || 100) + "px"; qrDiv.style.height = (element.height || 100) + "px"; qrDiv.style.border = "2px dashed #667eea"; qrDiv.style.background = "#f0f7ff"; qrDiv.innerHTML = "๐Ÿ“ฑ QR Code Verification"; el.appendChild(qrDiv); }

PDF Generator (type/custom_editor/certificate.php)

Real QR code generated and embedded in PDF:

if ($element['type'] === 'qrcode') { // Get certificate issue $certissue = $DB->get_record('certificate_issues', [ 'certificateid' => $certificate->id, 'userid' => $USER->id ]); if ($certissue && !empty($certissue->code)) { // Load QR library require_once($CFG->dirroot . '/local/qr/lib.php'); // Create verification URL $verifyurl = new moodle_url('/mod/certificate/verify.php', [ 'code' => $certissue->code ]); // Generate QR code image $qrfile = $qrdir . 'certificate_' . $certissue->code . '.png'; local_qr_generate_qrcode($verifyurl->out(false), $qrfile, 'M', 6, 1); // Add QR code to PDF $pdf->Image($qrfile, $x, $y, $width, $height); } }

๐Ÿ“ Position Recommendations

Position X Y Size Best For
Bottom Right โญ 720px 475px 100x100px Most professional, doesn't distract
Bottom Left 20px 475px 100x100px Alternative placement
Top Right (Small) 740px 20px 80x80px Subtle, unobtrusive
Bottom Center 370px 475px 100x100px Centered design

โœ… Good Placement

  • Corners (especially bottom right)
  • Clear background area
  • Away from important text
  • Good contrast with background
  • Easily scannable

โŒ Bad Placement

  • Center of certificate (distracting)
  • Over busy background
  • Too close to text
  • Too close to edge
  • Over important content

๐Ÿ“ Size Recommendations

Size Pixels Millimeters Use Case Scanability
Small 60x60px 15.9mm Corners, subtle โš ๏ธ Difficult
Standard 80x80px 21.2mm Top corners โœ… Good
Recommended โญ 100x100px 26.5mm Bottom corners โœ… Excellent
Large 150x150px 39.7mm High visibility โœ… Perfect
Too Large 200x200px 52.9mm - โš ๏ธ Distracting
๐Ÿ’ก Pro Tip: Use 100x100px for the perfect balance between visibility and aesthetics. This size is easily scannable while maintaining a professional appearance.

๐Ÿ” Security Features

๐Ÿ”‘
Unique Codes
Each certificate gets a unique verification code
๐Ÿ—„๏ธ
Database Linked
Code linked to student, course, and date
โฑ๏ธ
Timestamped
Issue date and time recorded
๐Ÿšซ
Tamper-Proof
Cannot be duplicated or modified
โœจ Security Benefits:
  • Instant Verification: Real-time database check
  • Cannot Be Forged: Unique codes cannot be guessed
  • Full Audit Trail: All certificate issues logged
  • Mobile Friendly: Verify anywhere with smartphone
  • No Manual Work: Automatic validation

๐Ÿ”ง Troubleshooting

Problem: QR Code Not Showing in Preview

Symptoms:
  • QR code added in editor but not visible in preview
  • Layout saved but QR missing
Solutions:
  • โœ… Check layout saved correctly (click Save Layout)
  • โœ… Refresh preview page (Ctrl+F5)
  • โœ… Clear browser cache
  • โœ… Check browser console for JavaScript errors
  • โœ… Verify layout JSON contains QR element

Problem: QR Code Not in PDF

Symptoms:
  • PDF generated but QR code missing
  • Preview shows QR but PDF doesn't
Solutions:
  • โœ… Ensure certificate was issued (not just previewed)
  • โœ… Check /local/qr/ directory exists
  • โœ… Verify file permissions on /local/qr/image/
  • โœ… Check QR library loaded correctly
  • โœ… Look for errors in PHP error log

Problem: QR Code Won't Scan

Symptoms:
  • Phone camera can't read QR code
  • QR code appears blurry
Solutions:
  • โœ… Increase QR size (100px โ†’ 150px)
  • โœ… Ensure good contrast (white background best)
  • โœ… Don't place over busy background
  • โœ… Check PDF quality settings
  • โœ… Use better lighting when scanning
  • โœ… Hold phone steady, 15-30cm away

โœ… Testing Checklist

Editor Testing

Preview Testing

PDF Testing

Verification Testing

๐ŸŽ‰ Summary

โœ… What's Working Now:

  • Editor: Add QR code button, drag & drop, resize
  • Preview: QR placeholder visible, matches design
  • PDF: Real QR code embedded, scannable
  • Verification: Instant validation, mobile-friendly
  • Security: Unique codes, tamper-proof, timestamped
๐Ÿš€ Ready to Use!
The QR code integration is fully implemented and ready for production use. Follow the steps above to add QR codes to your certificates and provide instant verification for your students!

๐Ÿ”— Quick Links

๐ŸŽจ Certificate Editor ๐Ÿ‘๏ธ Preview Page ๐Ÿ”ค Font Manager ๐Ÿงช Test Page

๐ŸŽ‰ Everything is Ready!

Start adding QR codes to your certificates now!

Last Updated: October 26, 2025 | Status: Production Ready โœ