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).