Individual participant code

150 views
Skip to first unread message

Philipp Kersten

unread,
Feb 6, 2020, 4:14:33 AM2/6/20
to formr

Dear all,

 

I am conducting a questionnaire study and would like to ask my participants for an individual participant code. This code must comprise four letters (first and last letter of father's first name + first and last letter of mother's first name) as well as two numbers (calender day of birth date). A correct example for this would be: AAPR14.

 

Currently, I defined "text 6" in the type column of this item. However, with this being the case, participants would also be allowed to use AAPRXX or even 141414 as their code. My question is whether there is any possibility to only allow for the combination of four letters and two numbers. I would be glad if anybody could help me with this issue.

 

Best regards,

 

Philipp

Ruben Arslan

unread,
Feb 6, 2020, 4:43:17 AM2/6/20
to Philipp Kersten, formr
Two ways:

1. Use a letters 4 and a number 1,99 field separately, concatenate the code yourself.
2. Use the field you're using, add a block-type element which shows up if the regular expression for the field does not match what you want! 

participant_code.match(/^[^A-Za-z][^A-Za-z][^A-Za-z][^A-Za-z][0-9][0-9]$/g) //js_only

where participant_code is the name of your text field.

I didn't test the above code, so you might have to tinker with it, see Stackoverflow for help.

Next time, please send a reproducible example, then we can easily test the solution we send.

Best,

Ruben


--
You received this message because you are subscribed to the Google Groups "formr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to formr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/formr/8e235e4f-a6f4-4a8d-a798-ab97c588eec0%40googlegroups.com.

Philipp Kersten

unread,
Feb 6, 2020, 8:11:10 AM2/6/20
to formr
Dear Ruben,

thank you for your quick answer. I attached the example using and adjusting your suggestion. Unfortunately, however, this doesn't seem to work. I can still type in six random characters (letters as well as numbers) without getting the block message to show up. What went wrong?

Best, 

Philipp
code_example.xlsx

Ruben Arslan

unread,
Feb 6, 2020, 11:12:14 AM2/6/20
to Philipp Kersten, formr
--
You received this message because you are subscribed to the Google Groups "formr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to formr+un...@googlegroups.com.
code_example.xlsx

Sabrina Köhler

unread,
May 28, 2020, 5:02:11 AM5/28/20
to formr
HI there,

I also have a question regarding the portrayal of the participant's code. I use a similar code as Philipp but only three letters and one number (z.B. AA6B).

I decided to ask for each letter and the one number individually in a separate text field (here, an example).
 
I think it would be nice, if participants see their full code after they typed in the respective letters and number at the end of the page by using the show if function. I tried to incorporate that as well (see example)

Unfortunately, it does not work. After they fill in the fields to generate the code, the following is portrayed: 

Ihr persönlicher Teilnahmecode: NA NA NA NA

Is it possible to tell formR to exchange the NAs with the letters and numbers as they are being filled out?

Thank you!

Cheers,

Sabrina 

Ludwig Ohse

unread,
May 28, 2020, 5:36:54 AM5/28/20
to formr
Hi Sabrina,

if you want to retrieve variables like df$variable, you have to save them first by clicking on the submit button of the respective page.

That is, you can fix your problem by showing the participant code on the next page (not on the same page you ask your participants to type it).

Best, Ludwig

Sabrina Köhler

unread,
Jun 9, 2020, 6:54:22 AM6/9/20
to formr
Hi Ludwig,

I thought that this could have been the problem. I was still wondering though if there is a nice solution to this. 

I followed your advice and saved the whole code on the next page.

Thanks again!

Cheers,

Sabrina 

Luise Caesar

unread,
Jul 26, 2022, 8:34:06 AM7/26/22
to formr
Dear Ruben,

for my study i need two different codes within the same questionnaire. For the patients link i could use the example above. But for the therapists code the block function didn´t work when i tried to turn it around. Cause the code is two numbers and 4 letters.
Can you help me with this problem?

Find attached the two codes.

Cheers,
Luise
code_test.xlsx

Ruben Arslan

unread,
Jul 27, 2022, 1:37:33 AM7/27/22
to Luise Caesar, formr
Hi Luise,

In the first example, you weren't allowing numbers with a leading zero and you had "code" instead of "code_therapist".
This works:
String(code_therapist) != "undefined" && String(code_therapist) != "" && ! code_therapist.toString().match(/^[0-9][0-9][A-Z][A-Z][A-Z][A-Z]$/g) //js_only

However, if I may, 
you have a total of 
100*12*12 = 14400 options in theory, but in practice far fewer (because star sign and birth month are heavily correlated
and because there are many more people with a height between 150 and 180). If you think of the birthday problem, I
think it's quite likely that you will get a "collision" (two people with the same code) at a surprisingly low N. Of course, if it's
a study with a small sample, you might be lucky. But probably better to add more "bits" of information (and replace the 
star sign with something independent of birth month).

Best wishes,

Ruben


--
You received this message because you are subscribed to the Google Groups "formr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to formr+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages