With the outbreak of Covid-19, researchers at Sussex decided to move swiftly to measure the psychological impact of lockdown over the course of the pandemic. We had to move quickly using the tools we had: But we had a problem, the surveys were on Qualtrics and the package our University had bought didn’t have the tools to set up a longitudinal survey with 3 weekly surveys (and extra features like reminders etc) – that would enable easily linking the data for analysis later. Moreover the Qualtrics package didn’t include access to the API – which would have made the task a lot simpler!
In the end I found it was quite simple to make an automated solution that consisted of three parts:
- Have Qualtrics survey send triggers to an email address (with IMAP and SMPT end points)
- A php script to read the address and update participants’ progress through the longitudinal survey – the ‘reader’.
- A php scripts to send any emails required to get people to do the next survey / remind them to complete – the ‘sender’.
We initially started the process manually running the scripts, verifying the behaviour, and then moved it to a CRON task, with a daily email update of new emails to be sent in the morning, with the emails themselves being sent later in the day (giving us time to inspect the email to check for any strange things going on). The process works as follows:
- A participant completes the initial baseline survey, and this triggers an email containing the date of completion and email address.
- The ‘reader’ script picks up the email, and adds the address to a table of users in the database, and assigns them a new id code. A second entry is made in a table of surveys in the database, storing the completion of this baseline survey with this user.
- Three weeks pass, and the on the daily run of the ‘sender’ script detects it is due to send a new email – it constructs a link containing URL parameters of the user’s id and the current iteration to the follow up survey. It also creates a new entry in the table of surveys (but marks it with a ‘waiting for completion’ status.
- When the participant completes the follow up survey, the URL parameters are stored with it (to allow data merging later) and a new email is triggered.
- The ‘reader’ script detects the follow up survey is complete and marks it as complete in the table of surveys – and then the process continues – unless –
- If the participant doesn’t complete a survey, the ‘sender’ script detects this from the table of surveys and sends reminders (after a few days).
The whole set up allows for a complete customisation of how to solicit follow up responses to the survey, and stores an explicit and clear representation of the state of each participant throughout the process. The database is specialised to deal only with the survey response state, and not any of the data itself, making it much easier to manage.
The main difficult of setting up was getting to grips with PHP’s imap functions such as imap_open() which wasn’t too easy, and required a fair amount of tinkering (see the comments on that page for very helpful advice). I used PHPMailer to send the emails, which was very easy to use. On the whole it was quite a satisfying small project to work on – there’s something nice and Rube Goldberg about the chain of events. I wondered for a while if it could scale into a usable piece of open source code – but decided that it was too niche to do so – especially considering the fact that the best solution would probably have been to purchase Qualtrics’s enhanced functionality – but if that’s not possible for you then consider this work around!