void mailResume(string personID, int mailing, int time, [string C1, string C2, string C3, string C4, string C5])
This function sends an email during the current questionnaire with a link in order to resume the questionnaire at a later point in time. This is particularly useful when combined with a specific break in multi-wave surveys (buttonHide()
).
Note: The email will only be sent if the participant is already registered in the mailing list.
false
and a suitable ID will then be automatically determined. Alternatively, the personal ID can be determined using caseSerial()
.%custom1%
to %custom5%
. When combined with value()
, you can display responses from the current questionnaire in the email, for example.
Note: A mailing can be sent multiple times to the same addressees by using mailResume()
.
Note: In the mailing, the placeholder %link%
is not replaced with a regular personalized link (by calling up the questionnaire in this way it possibly starts again from the beginning). Instead, it is replaced by a direct link to the current questionnaire.
Note: If the participants' email addresses are not known a priori, these have to be collected at the beginning of the first questionnaire so that mailResume()
can be used. Alternatively, using separate questionnaires and the function mailSchedule()
is possible (Multi-Wave Surveys with Self-Selection).
Tip: There are numerous websites on the internet that can covert a date into a Unix timestamp. For example: unixtime.de. The PHP Date/Time Functions (in particular mktime()
and strtotime()
) are also suited to this purpose.
Tip: If you do not want to send the invitation out on a particular date, but rather after a specific delay, specify the delay because mailResume()
is then able to prevent duplication of emails more efficiently.
In the following example, the participant was invited to the questionnaire via a mailing. A page where the questionnaire is paused is placed in the middle of the questionnaire (buttonHide()
) and the text “end1” is displayed. The participant receives an email after 24 hours stating he may now fill out the second part of the questionnaire. The link in the email leads him to the next page in the previously interrupted questionnaire.
Important: The caseTime()
function only works if you have not unchecked “Record time and dwell time during the survey” in the Project settings in the Privacy tab. The dwell time is required information for the interrupt pages suggested here.
// If the back button is enabled in the questionnaire // it should not appear on this page option('backbutton', false); // Check how much time has elapsed since the start of the survey // If this is less than 24 hours (24 * 3600 seconds), the questionnaire will be paused if (caseTime('begin') < 24 * 3600) { text('end1'); // displayed at the end of the first part option('resume', true); // prevent indication to resume questionnaire option('nextbutton', false); // hide the Next button (pause questionnaire) // Send ID 3 mailing tomorrow at the same time (i.e. in exactly 24 hours) mailResume(false, 3, 24 * 3600); } else { // Did the participant return after 24 hours? If so, continue questionnaire goToPage('next'); }
Alternatively, you can also check the time elapsed since the the page was first accessed (and thus the time since the email was prepared):
// Deactivate the back button as required option('backbutton', false); // Save the time the page was first accessed // Due to isset() und registerVariable(), the block is only executed for the first time if (!isset($timeBreak1)) { // Save the time $timeBreak1 = time(); registerVariable($timeBreak1); // Prepare email // Send ID 2 mailing in exactly 14 days mailResume(false, 3, 14 * 24 * 3600); } // Check how much time has elapsed since the page was first accessed // Pause, if this is less than than 14 days (14 * 24 * 3600 seconds) if (time() - $timeBreak1 < 14 * 24 * 3600) { text('end1'); // displayed at the end of the first part option('nextbutton', false); // hide Next button (pause questionnaire) } else { // Perhaps the progress bar should be adjusted? option('progress', 0); // Did the participant return after 14 days? If so, continue questionnaire goToPage('next'); }
The function mailResume()
can be “misused” to inform the project manager about incoming questionnaires. Therefore, it is necessary to import the project manager's email address into the list of contacts (Send Mailings). It is essential that the email address imported is not anonymous.
The address entry's personal ID can then be determined from the list of contacts. This is displayed when the mouse is placed over the address entry or when it is opened for editing. In the example, the person ID “ABCDE123” is used.
If an additional mailing (number 3) was created, the following PHP code informs that a partipant has reached the current page in the questionnaire.
mailResume('ABCDE123', 3, 0);
With a question of type Opt-In for mailing list you can ask for e-mail addresses in the questionnaire and enter them directly into the address list (List of Contacts), so that you can send serial mails to the e-mail addresses later.
This section explains how to use mailSchedule()
to automatically trigger the scheduled or immediate sending of a serial mail to the entered e-mail address.
There are two mechanisms for the opt-in question: The Double-Opt-In (the respondent must first confirm the address entry via confirmation email, recommended) and the Single-Opt-In, where the (possibly wrong) email address is stored directly.
mailSchedule()
is used. This is explained in more detail below.
The PHP code with the mailSchedule()
is placed (at the earliest) on the page that follows the opt-in question. Only there the survey server knows the new e-mail address and has assigned it a personal ID (SERIAL). This personal ID is required as first parameter for the function mailSchedule()
(as otherwise often used false
).Where do you get the ID from? If the respondent entered an email address in the opt-in question, it is noted in the record in a variable that has the same identifier as the opt-in question.
In the following example, the opt-in question on page 9 would have the ID “OI01”. On page 10 (or later) the following PHP code would then immediately send the serial mail with the ID 2. The value('OI01')
returns the subscriber ID (SERIAL) of the new address entry.
mailSchedule(value('OI01'), 2, 0);
The following PHP code would send the serial mail with the ID 3 after 14 days:
mailSchedule(value('OI01'), 3, strtotime('+7 days'));
Of course you can also prepare several serial mails:
mailSchedule(value('OI01'), 2, 0); mailSchedule(value('OI01'), 3, strtotime('+7 days')); mailSchedule(value('OI01'), 4, strtotime('+14 days'));
If there is a possibility that the respondent does not enter an e-mail address, an if
should be added to avoid error messages:
$serial = value('OI01'); if ($serial) { mailSchedule($serial, 2, 0); mailSchedule($serial, 3, strtotime('+7 days')); mailSchedule($serial, 4, strtotime('+14 days')); }
Note that the personal ID (SERIAL) here is cached in a PHP variable ($serial
) to be used directly in the mailSchedule()
calls. Of course you could also use value('OI01')
here.