-
Notifications
You must be signed in to change notification settings - Fork 36
How to combine formr with surveys from SoSci survey
We're not jealous. If a different survey engine fits your needs better, but you want to use formr to organise e.g. when invitations to your diary will be sent, we want you to be able to integrate the two.
Integrating with https://www.soscisurvey.de is fairly simple:
In your run, you include an "External" module with a link to your survey and the user's code, e.g.
https://www.soscisurvey.de/demo/?q=fb1&r={{login_code}}
That way the variable called "session" in formr will be stored in a variable called "REF" in your SoSciSurvey data. With these, you can link data between formr and SoSciSurvey.
But maybe you would not just like to redirect users to the survey, but you'd like to know whether they finished it. To do this, turn on "end using API". We'll get to what this means in the next step.
In SoSciSurvey make a new page in your survey towards the end. Click PHP code and paste and edit the following snippet:
$ref = value('REF');
debug($ref);
$call_formr = sendPOST( "https://formr.org/api/post/end-last-external/",
array( "request" =>
'{ "run" : { "name" : "NAME_OF_YOUR_RUN" , "session" : "' . $ref . '" } }') );
debug($call_formr);
With the first line, you get the "REF" value. The lines starting with "debug" are useful to see what's happening in SoSciSurvey's testing mode.
The statement starting with $call_formr makes SoSciSurvey call formr and tell it that the user with the code stored in "REF" has finished the SoSciSurvey.
Until SoSciSurvey has called or the External link has expired in formr, the run in formr will not move on.
Now, if you want to loop a SoSciSurvey for e.g. experience sampling in formr, you can implement a SkipBackward with the condition finished(externals) < 10
. Until your participant has finished ten external surveys, the run will loop back.
- You have to send your participants a link to the formr run (e.g. in an email use {{login_link}}), otherwise formr won't know they've starting filling out the external survey.
- You have to change NAME_OF_YOUR_RUN above to the name of your run.