Create choices from embedded data | XM Community
Solved

Create choices from embedded data

  • 28 August 2018
  • 3 replies
  • 34 views

Badge +3
I've seen some answers that get close to this question, but nothing that hits it right on.

I have ~1500 students who are taking a variety of ~500 courses (the courses have student enrollment of 6 to 120, most are in the range of 10 to 20). I would like to survey the professors of each course, presenting them with an alphabatized multiple-answer list of the students enrolled in their course, so they can select students that they have concerns about. The choices that they make in this first question will then be carried over to subsequent questions, so that I can drill-down into the reasons for the professor's concerns.

I think I see a way to do this by having a giant question with all the students listed, and then using answer display logic to show or not show them based on embedded data in the contacts (one contact for each course, one embedded data field for each student). However, that seems like a very painful way to approach the problem. Is there a better way? If not, is there a way to add the display logic programmatically?
icon

Best answer by dsweeney 21 September 2018, 07:32

View original

3 replies

Userlevel 7
Badge +33
1.) You can manually add display logic for each student which is answer labels of your question.
2.) Create one hidden question in beginning in which punch student basis of your embedded variable storing your courses (and using this variable further) , student info by writting loop or condition in java script as an example below:
`ualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/

var ageres="${q://QID2/ChoiceTextEntryValue}";

if (ageres>="18" && ageres<="24") {this.setChoiceValue(1,true) ; }
if (ageres>="25" && ageres<="34") {this.setChoiceValue(2,true) ; }
if (ageres>="35" && ageres<="44") {this.setChoiceValue(3,true) ; }
if (ageres>="45" && ageres<="54") {this.setChoiceValue(4,true) ; }
if (ageres>="55" && ageres<="65") {this.setChoiceValue(5,true) ; }
var questionDiv = this.getQuestionContainer();
questionDiv.style.display = "none";
});`
Badge +3
Thanks @bansalpeeyush29. A couple of comments on your two suggestions:

1) Manually adding display logic would be a terrible solution: the students and courses change each semester, and updating (or really, creating anew) all the display logic on 1500 items each time would be a real waste of time & money.

2) This solution seems a bit more do-able. However, in trying to put all ~1500 students in the hidden question (through "Edit Multiple"), I'm getting errors about base64 encoded images after adding only about 1100 names --- some kind of limit on the text entry there?
Userlevel 2
Badge +5
You could programmatically create a custom QSF file that has the display logic embedded in it. Loop through the students in the course to generate the embedded data fields in the contact, the answers in the big question and the display logic for the subsequent questions. Display logic in the QSF file will look something like this for each question:

{
"DisplayLogic": {
"0":{"0":{
"LogicType":"Question",
"QuestionID":"QID6",
"QuestionIsInLoop":"no",
"ChoiceLocator":"q:\\/\\/QID6\\/ChoiceTextEntryValue",
"Operator":"EqualTo",
"QuestionIDFromLocator":"QID6",
"LeftOperand":"q:\\/\\/QID6\\/ChoiceTextEntryValue",
"RightOperand":"A",
"Type":"Expression",
"Description":"<span class=\\"ConjDesc\\">If<\\/span> <span class=\\"QuestionDesc\\">Question to base your decision on.<\\/span> <span class=\\"LeftOpDesc\\">Text Response<\\/span> <span class=\\"OpDesc\\">Is Equal to<\\/span> <span class=\\"RightOpDesc\\"> A <\\/span>"},
"Type":"If"
},
"Type":"BooleanExpression",
"inPage":false
}
}

Leave a Reply