Generate QR code of participant ID

Hi,

I am wondering whether it is possible to generate and display a QR code or barcode which contains the participant’s study Identifier?

Best wishes

Catherine

@cp622 Welcome back to the forum! Could you share a bit more detail about your workflow?
Specifically, it would help to know when the ID is generated, who needs to view or scan the QR code, and whether it’s meant for re‑identification or another purpose. With that context, we can point you toward a more precise solution.

If you wish to generate a QR code in general, with whatever text, URL, etc you want, then there a lots of free online website that will do it for you: eg https://www.the-qrcode-generator.com/ Look for one that supports plain text and not just URLs. Or, if you are comfortable with programming, then there are also tools like qrcode · PyPI that will similarly generate a PNG image file with whatever QR code content you like; this is good if you need to generate QR codes offline in the field.

However, iIf you want to generate a QR code within KoboCollect (only, this does not work in Enketo/Kobo web forms) then you can also do so, but it is a bit more involved. It requires using a text question in your form and a calculation to generate a specific HTML markup string, which is then interpreted by a printer appearance to generate the resulting QR code image that can be displayed within the KoboCollect app.

There is some documentation about how to do this here: Question Types - ODK Docs

And/or try this form and run it under KoboCollect:

CreateQRCode.xlsx (14.8 KB)

After entering your personal details, it will produce a scan-able QR code image containing the data as a space-separated string:

Hi @jorcabrera and @Xiphware

Many thanks for your replies.

@Xiphware your solution works as I hoped it would. thank you very much for providing the clear example.

I am hoping our study team can use the QR code which just has the participant StudyID, then they can scan this QR code at each station rather than re-entering studyID each time. This hopefully will reduce typos.

Best wishes

Catherine

Glad to hear its working out for you :slightly_smiling_face:

Hi @Mark-robinson and @Xiphware

Thank you for your replies. I was only informed this morning that the questionnaire would be completed in Enketo web form, rather than in the kobo collect app.

When I tested the QR code generator, it did not display as a QR code on the web form like it did in the mobile app. Maybe @Mark-robinson ‘s solution is the only one, however I am just re-posting to see if there is a solution for Enketo web like there is for the app.

An addition question I have is whether a human readable version of the studyID could appear under the QR code?

Best wishes

Catherine

Correct, this special printer appearance is new to KoboCollect only at present.

I am just re-posting to see if there is a solution for Enketo web like there is for the app.

If you wish to dynamically generate a QR code from data entered in a form in Enketo, then one approach is use an online QR code service that accepts an API request with the data you wish to encode; for example api.qrserver.com [no affiliation - they were just the first website I googled…]. You can then construct the necessary URL in your form and present it to the user to click on using a URL question type.

Here’s a simple form that encodes some raw text that you type in:

OnlineQRCode.xlsx (11.1 KB)

The concat() calculation takes the raw text that you type in ${qrdata} and constructs a suitable URL to call the above online QR code service. That URL is then presented in a read-only URL text question, so that when the user taps on the link it will open a new page to the service displaying the generated QR code image containing the provided data.

Note, since the raw data is getting passed via a URL it will need to be suitably URL escaped; eg punctuation, spaces, etc in the data will need some additional sanitizing. But if it’s only letters and digits then you should be fine as-is.

FWIW, this works under KoboCollect too! :slightly_smiling_face:

But, obviously, this requires you to be online to call the QR service. The benefit of the printer approach is the QR code is generated entirely on the device, so it works offline.