Hi community,
I have a Highlight Question with a paragraph of text. There's only 1 category: "Contains a G." I ask participants to highlight all of the words that contain a G.
How do I set embedded data representing the number of words that they highlighted?
I want to tell participants in the next block, "You selected ${e://Field/num_gs_highlighted} words that round." I can't find anything in Scoring, unfortunately.
Thanks, as always!
Solved
Set embedded data: Counting the number of words selected in a Highlight Question
Best answer by wscampbell
This was solved on a different thread by GrumpyCivet. The solution here involves to steps:
- Create an embedded data field that captures the selected words from the Highlight question.
- Use JavaScript in a subsequent question to count the length of that embedded data field (by counting the number of commas).
How to do this:
- In the survey flow, set embedded data from the selected choices of the Highlight question. For instance, set
high_string
to ${q://QIDXXXXX/ChoiceGroup/SelectedChoices} - Also in your survey flow, create an additional embedded data field (e.g., called
word_count
) before the block that contains the Highlight question. Then, implement this solution is from GrumpyCivet HERE: In a later question, embed the following JS:
var myString = Qualtrics.SurveyEngine.getEmbeddedData("high_string");
var wordCount =0;
wordCount = myString.trim().split(',').length;
Qualtrics.SurveyEngine.setEmbeddedData("word_count", wordCount);
Voila! Thanks to GrumpyCivet for solving this one!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
