Audio Files Randomized | XM Community
Skip to main content

Hi,

 

I am trying to do a survey that has two questions based on an audio clip, except I have 20 different audio clips that need to have one chosen randomly to each participant. 

I have tried to loop and merge but I am unsure if I am doing it right.

I am not a coder so would need thorough instructions if it involves java script.

I am running out of time as it is for a dissertation and my data collection period is coming to an end. I am really hoping I wont have to make 20 different questionnaires!

Please help!

You shouldn’t need Javascript, just:

 

  1. Put in a loop and merge with your 20 audio URLs as 20 different rows of the first column (Field 1).
  2. At the bottom of the loop and merge window, click that you only want to randomly show a subset of loops to the participant - in your case, show 1 loop only.
  3. Then go to the HTML code view of your question, find the audio URL, and replace it with ${lm://Field/1}. 

You shouldn’t need Javascript, just:

 

  1. Put in a loop and merge with your 20 audio URLs as 20 different rows of the first column (Field 1).
  2. At the bottom of the loop and merge window, click that you only want to randomly show a subset of loops to the participant - in your case, show 1 loop only.
  3. Then go to the HTML code view of your question, find the audio URL, and replace it with ${lm://Field/1}. 

Hi, thank you so much!

I have done this, except now my audio wont play even in preview and it still isn’t randomly looping. I think I am putting the replacement in the wrong source, there is two?

 

 


You shouldn’t need Javascript, just:

 

  1. Put in a loop and merge with your 20 audio URLs as 20 different rows of the first column (Field 1).
  2. At the bottom of the loop and merge window, click that you only want to randomly show a subset of loops to the participant - in your case, show 1 loop only.
  3. Then go to the HTML code view of your question, find the audio URL, and replace it with ${lm://Field/1}. 

Hi, thank you so much!

I have done this, except now my audio wont play even in preview and it still isn’t randomly looping. I think I am putting the replacement in the wrong source, there is two?

 

 

You should put src=”${lm://Field/1}” in both places.

Are you previewing the entire experiment or only the block? There is an annoying bug in Qualtrics where loop and merge piping doesn’t work when previewing only a block or question, you have to preview the entire survey.


You shouldn’t need Javascript, just:

 

  1. Put in a loop and merge with your 20 audio URLs as 20 different rows of the first column (Field 1).
  2. At the bottom of the loop and merge window, click that you only want to randomly show a subset of loops to the participant - in your case, show 1 loop only.
  3. Then go to the HTML code view of your question, find the audio URL, and replace it with ${lm://Field/1}. 

Hi, thank you so much!

I have done this, except now my audio wont play even in preview and it still isn’t randomly looping. I think I am putting the replacement in the wrong source, there is two?

 

 

You should put src=”${lm://Field/1}” in both places.

Are you previewing the entire experiment or only the block? There is an annoying bug in Qualtrics where loop and merge piping doesn’t work when previewing only a block or question, you have to preview the entire survey.

Unfortunately, this just stops the video from being able to play! 


You shouldn’t need Javascript, just:

 

  1. Put in a loop and merge with your 20 audio URLs as 20 different rows of the first column (Field 1).
  2. At the bottom of the loop and merge window, click that you only want to randomly show a subset of loops to the participant - in your case, show 1 loop only.
  3. Then go to the HTML code view of your question, find the audio URL, and replace it with ${lm://Field/1}. 

Hi, thank you so much!

I have done this, except now my audio wont play even in preview and it still isn’t randomly looping. I think I am putting the replacement in the wrong source, there is two?

 

 

You should put src=”${lm://Field/1}” in both places.

Are you previewing the entire experiment or only the block? There is an annoying bug in Qualtrics where loop and merge piping doesn’t work when previewing only a block or question, you have to preview the entire survey.

Unfortunately, this just stops the video from being able to play! 

Can you take a screenshot of what your loop and merge window looks like?


Hi @carac This can be achieve, you can utilize JavaScript to dynamically select a random audio clip for each participant

  1. Prepare your audio clips: Ensure you have all the audio clips available and accessible online. Make a note of their URLs or file paths.

  2. Create a Loop & Merge block: , set up a Loop & Merge block that will repeat the audio question for each participant. Follow these steps:

    • Create a new block and select "Loop & Merge" from the question type options.
    • Add the audio question to the Loop & Merge block.
  3. Add a JavaScript question: Inside the Loop & Merge block, add a JavaScript question. This will be used to execute the necessary JavaScript code to randomly select the audio clip for each participant. Follow these steps:

    • Add a new question and select "Text Entry" as the question type.
    • Click on the question text and switch to HTML mode.
    • Add a <script> tag to enclose your JavaScript code.
  4. Write the JavaScript code: Insert the following JavaScript code inside the <script> tag. This code will randomly select an audio clip for each participant.

 

Qualtrics.SurveyEngine.addOnload(function() {
  var audioClips = l
    "URL_OR_FILE_PATH_1",
    "URL_OR_FILE_PATH_2",
  ];
  var randomClipIndex = Math.floor(Math.random() * audioClips.length);
  var randomClipURL = audioClipsLrandomClipIndex];
  var audioElement = document.getElementById("QID_OF_AUDIO_QUESTION");
  audioElement.src = randomClipURL;
});
 

  • Replace "URL_OR_FILE_PATH_1", "URL_OR_FILE_PATH_2", etc., with the actual URLs or file paths of your audio clips.
  • Replace  "QID_OF_AUDIO_QUESTION" with the Question ID of your audio question. To find the Question ID, inspect the audio question element in your browser and locate the id attribute.

Kindly check the below post:

 

Audio won't play | XM Community (qualtrics.com)


Leave a Reply