Score:0

Webform Conditional based on previous webform entry

us flag

I have a webform that we have people fill out two times - for a pre-test and a post-test and I am looking for a way to determine if a pre-test has been taken an if so, set a specific value on form element.

Currently we have people manually select whether they are taking the pre-test or post-test in a webform element, but they are not doing so very accurately. Given we have the data to know that, I am hoping to be able to determine that automatically in a webform field.

Here are some more details:

  • We gather a unique participant id (c_ID)
  • Based on that participant ID I am hoping to validate if a previous webform submission with that participant ID exists.
    • If not: Provide a value of "pre-test"
    • If so: Provide a value of "post-test"

Does anyone have any recommendations on how something like this could be done?

in flag
Are the pre- and post-test submissions the same submission? Or are they separate submissions? Do both submissions have the same fields? And where does participant ID come from?
us flag
Thanks @Joseph - pre and post-test both use the exact same webform with the same fields, but are completed at different times, usually days or weeks apart. Currently whether it is a pre- or post-test is a select box in the same field. The participant ID is entered manually by the person filling out the form.
Score:1
in flag

Configure the select element containing "pre-test" and "post-test" options to have "Prepopulate" checked. Remember the machine name of the element, that will be the query parameter for the succeeding steps (e.g. submission_type)

Then create a block with a textfield asking for a participant ID. On submit, it would look for a webform submission already containing the ID. Then one of two things can happen:

  • If a submission doesn't exist yet, redirect the user to the webform with the "pre-test" pre-selected (e.g. ?submission_type=pre-test)
  • If a submission already exists, redirect the user to a webform with "post-test" pre-selected. (e.g. ?submission_type=post-test)

Then pop this block wherever you want to start this workflow, like on some page. As an added bonus, you could make the block ask for the query parameter name used in the redirect during its configuration. That way, you can match the webform element name without having to dive into code later should you rename it.

I also recommend putting a warning saying the field was pre-filled based on participant ID's existence. Prefills are easy to overlook.


Alternatively, just provide two links to the webform, one with ?submission_type=pre-test bolted onto its url and the other with ?submission_type=post-test. Same effect minus the participant ID checking and custom block (assuming the user chooses the right link).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.