Randomize mp3 between blocks | XM Community
Skip to main content
Hi all

I have a questionnaire with 4 blocks with 3 questions in each block.

The 2nd question in each block should contain 1 out of 4 mp3 audio.

I wish to be able to randomize only the mp3 audio between the blocks in a way that each mp3 file will be played only once.

(unfortunately randomizing the blocks doesn't work for me)

Any suggestions?

Thanks in advance,

Ran
I assume Loop and Merge does work if block randomization doesn't work either?



The solution to this is pretty straightforward. First save your MP3 files to your Qualtrics library and copy the file URL. Anytime I refer to MP3-1 (or 2 or 3 or 4) I am referring to that URL.



At the top of the survey flow, add a randomizer block with 4 embedded data (ED) blocks nested under it. Assign the randomizer to present only 1 of these elements. In each ED block create a data element called _Block File 1_ and set it equal to MP3-1 (2,3,4 for each block).



Duplicate this randomization but change _Block File 1_ to _Block File 2_ and put a branch logic above each ED block that says IF _Block File 1_ IS NOT EQUAL TO MP3-1(2,3,4 as applicable).



Duplicate this randomization block but change _Block File 2_ to _Block File 3_ and change the branch logic to IF _Block File 1_ IS NOT EQUAL TO MP3-1(2,3,4) AND IF IF _Block File 2_ IS NOT EQUAL TO MP3-1(2,3,4).



Duplicate this randomization block but change _Block File 3_ to _Block File 4_ and change the branch logic to IF _Block File 1_ IS NOT EQUAL TO MP3-1(2,3,4) AND IF IF _Block File 2_ IS NOT EQUAL TO MP3-1(2,3,4) AND IF IF _Block File 3_ IS NOT EQUAL TO MP3-1(2,3,4).



Should look something like this by the end:

!



Now just pipe _Block File (1,2,3,4)_ to the appropriate blocks.
Hello @Ran ,



Assuming you have added audio using HTML audio tag

Please follow the below steps:



Step 1: Create 4 embedded data ( A1, A2, A3, A4 ) as the first element of the survey flow.



Step 2: Paste the attached code in the js(onReady) of the first question of the survey ( assuming first question is not the block question and is on separate page )



Step 3: In second question of each block replace scr attribute value of audio tag with embedded data as shown in below code



<audio controls>

<source src="${e://Field/A1}" type="audio/ogg">

Your browser does not support the audio element.

</audio>



Similarly for all second question with changed embedded data(A2, A3, A4)



Explanation: In JS code replace the AudioSrc1 with the source of first audio tag and similarly for other three. The js randomizes the array and assign random values to embedded data. Hence we see random audio in question two
Hi

Thank you both for your fast and very informative replies!



@Akdashboard I'm not sure I understand where in the process I refer to the question number in the block. Just a reminder, it is important to me that the song will be played on the second question of each block.



@Shashi Community Member, I followed your instructions but got no shuffle when previewing the survey. any suggestions?



I really appreciate your time and effort. Thank you for that!
> @Ran said:

> Hi

> Thank you both for your fast and very informative replies!

> @Shashi Community Member, I followed your instructions but got no shuffle when previewing the survey. any suggestions?

>

> I really appreciate your time and effort. Thank you for that!





Please find the attached QSF for reference. Take multiple test runs to see the randomization of audio. For test link click here
Hi @Shashi

I works like a MAGIC!

Thank you

Do you happen to know if there's any way to view which song was playing when exporting the data?

Thanks again,

Ran
> @Ran said:

> Hi @Shashi

> I works like a MAGIC!

> Thank you

> Do you happen to know if there's any way to view which song was playing when exporting the data?

> Thanks again,

> Ran



In data export file you view the sequence using the embedded data i.e. A1, A2, A3.....etc, they are in sequence. These embedded data will contain the URL of audio files.
Hi @Shashi

I just wanted to update you that it works perfectly!

I don't know how I would have done it without you help.

Thank you very much

I really appreciate it

Leave a Reply