Note that "In Page Display Logic" can be used to give direct feedback, but it's the email part that I am having trouble with.
My solutions so far are to use Javascript and a Descriptive Text element, or to use Javascript with a Text Entry element.
`$answer1 = "${q://QID1/ChoiceGroup/SelectedChoices}";`
`$answer1 = "${q://QID5/ChoiceGroup/SelectedChoices}";`
`$advice = "<div class=\\"QuestionText BorderColor\\"><strong>Your feedback:<\\/strong>";`
`switch ( $answer1 ) {`
` case "lorem ipsum": $advice = $advice + "<br \\/>Feedback 1a"; break;`
` case "dolor sit amet": $advice = $advice + "<br \\/>Feedback 1b"; break;`
` case "consectetur adipiscing elit": $advice = $advice + "<br \\/>Feedback 1c"; break;`
`}`
`switch ( $answer2 ) {`
` case "sed do eiusmod": $advice = $advice + "<br \\/>Feedback 2a"; break;`
` case "tempor incididunt": $advice = $advice + "<br \\/>Feedback 2b"; break;`
` case "ut labore et dolore": $advice = $advice + "<br \\/>Feedback 2c"; break;`
`}`
`$advice = $advice +"<\\/div>";`
`jQuery("#"+this.questionId).html($advice);`
This generates a custom text with a proper layout. I can reference the Descriptive Text element through Piped Text. It does not show up in the Piped Text menu (it apparently does not show static content), but you can create it yourself. It's ${q://QIDn/QuestionText} where n is the number of the element.
However, the email shows the original text instead of the updated text. Probably because it's static content and there's no permanent document.write taking place. So this solution does not work unless Qualtrics can remember my changes.
The second solution tries to fix this by using a Text Entry element. Main differences are that I have to use \\n instead of br and the command to write the feedback text to the element uses val instead of html:
`jQuery("#"+this.questionId+" .InputText").val($advice)`
The email shows the custom text, but the layout is terrible. Even the linebreaks are gone, so it becomes one long sentence.
A textbox will not allow any HTML codes inside it so if I use HTML codes those will be shown literally in my email.
I am now experimenting with a Descriptive Text element to show feedback to the user, and multiple Text Entry elements for each line of advice. But that only works if every answer provides feedback and that's not really the case. We are only supposed to provide feedback on certain answers.
If I can't get it to work in Qualtrics we will just export the answers and solve the problem (easily) in Excel with a mail merge, but it seems a bit silly that Qualtrics can not do something as basic as this. I am probably overlooking something. Any help would be much appreciated.
Maybe this discussion helps: https://www.qualtrics.com/community/discussion/comment/6190#Comment_6190
If you use a textarea (text entry essay) you can use JavaScript to replace the line feeds (\\n) with html breaks (
) and save the new string to an embedded data field.
Thank you for your suggestions.
@kof: The solution you are referring to is only suitable for very small surveys. The number of email variants one would have to create quickly gets out of hand when the number of questions and/or answer options increases.
@TomG: I'll definitely have to give that a try. This time I "solved" it in the mail merge by adding a lot of conditional logic in Word, along with some helper columns in Excel.
Would be nice if Qualtrics could implement this functionality. It shouldn't be out of scope.
Nico: Sorry, I added the wrong link - I meant the first accepted comment in this thread: https://www.qualtrics.com/community/discussion/comment/6190
This worked for me by adding branches to the survey flow where the condition for each branch is the particular answer of a question. I then fill an embedded data field in that branch. This ED field can then be piped into the e-mail (e.g., in an e-mail task or in a thank-you e-mail).
However, this method has other issues such as formatting (cf. https://www.qualtrics.com/community/discussion/10822/personalized-e-mail-how-to-format-embedded-field#latest).
@kof: Thank you once again. Perhaps TomG's solution will solve both our layout issues.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.