Saving l&m fields as embedded data | XM Community
Skip to main content

Hello, everyone!
I came across a tricky question when implementing an experiment in Qualtrics and could use your help. I searched in the forums, but I could not find the answer to the question anywhere, so I am assuming it has not been answered yet; in any case, if it has been addressed before, please do not hesitate to send the post my way.

I want to run an experiment in which participants go through a set of faces in order to build a lineup. These faces are grouped by similarity relative to one suspect (very high, high, low, very low). These subsets are randomized and saved as embedded data fields. The presentation of stimuli follows a specific order - very high_1, high_1, low_1, very low_1, very high_2, high_2, low_2, very low_2, etc... So, each participant is bound to see one face belonging to each category in this specific order, though the order within each category is specific to the individual (i.e., very high_1 can be the 5th picture in the original array for one individual, but the last one in the original array for other).
Participants are asked whether they would like to add each picture to the lineup (pressing '1' = yes, '2' = no). I have a counter going that takes the participant out of the loop and merge that I used to compute the block of trials the moment they select 5 suspects.
Up to this point, everything seems to work fine. The problem is that I would like to register the faces that the participants select so that I could show them the final lineup in the end. The code I wrote is below:

Qualtrics.SurveyEngine.addOnload(function()
{
this.hideNextButton(); //Blocks from advancing
this.hidePreviousButton(); //Blocks from retreating
**Preventing participants from advancing or retreating using the arrow icons**
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) { //Set values for keys
  var choiceID = null;
switch (e.keyCode) {
  case 49: // '1' was pressed
choiceID = 1;
 }
switch (e.keyCode) {
  case 50: // '2' was pressed
choiceID = 2;
 }
**Defining allowed key inputs**
 if (choiceID) {
  Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
  that.clickNextButton();
 }
**Advance when a key is pressed**
 if (choiceID == 1) {
let temp = Number("${e://Field/counter_b}");
temp++;
Qualtrics.SurveyEngine.setEmbeddedData('counter_b', temp);
**Update the counter**
let loop_html = "${lm://Field/1}";
Qualtrics.SurveyEngine.setEmbeddedData('lineup_b' + temp, loop_html);
**This is where the issue lies: The idea would be for the l&m field which holds the html to the stimuli to be registered when participants say that they would use it in the lineup. For this, I created 5 embedded data fields (i.e., lineup_b1 to lineup_b5) that I wanted to see associated with this l&m field. I am no expert with javascript, and it is most likely the case that "${lm://Field/1}" is not the adequate way to refer to the l&m field, I adapted it from how I have referenced embedded data fields in the past (i.e., by putting the piped text associated with them within " "'s).
Also, these two lines mess up the remainder of the code: not only do they not work (i.e., lineup_b1 to lineup_b5 remain empty), but they also make it so that answering with the keys no longer works, preventing the first chunk of code from working properly as well (i.e., the icons become available again, and for one to initiate the next trial an answer must be selected with the mouse - instead of the desired keys - before the mentioned icon is pressed).**
 }
});
});

I have no idea how to go around the issue, does anyone have any tips? All help is appreciated!
Best,
Francisco

Be the first to reply!

Leave a Reply