display a question is an audio (which is embedded in a choice text) is activiated | XM Community
Skip to main content

Hello,
In one of my experiment tasks, I will ask subjects to listen to a few songs and rate them. I have the below design:

(1) I set a “Multiple Choice" question to display all the songs and put the song within the choice text as shown in the below picture:
image.pngFigure 1.

(2) Thus, subjects can click and listen to these songs; when a choice is selected, it will be highlighted in a yellow square.
image.pngFigure 2.

(3) When a subject clicks a button (choice), a question will display in page and ask them to rate the song. And I have set the display logic for each song as follows: When a choice is selected, display the rate question.
image.pngFigure 3.
However, if a subject just clicks the "play" button for a song (see the highlighted part, the song is now playing), the rate question cannot be displayed. Because the choice is "not selected" according to Qualtrics' definition (so it does not have the yellow background as shown in Figure 2). Can anyone suggest how the rating question can be displayed as a song as the corresponding song is playing?
image.pngFigure 4.


By the way, I have already set the logic that a song will automatically stop if another song is playing:

Qualtrics.SurveyEngine.addOnReady(function()
{
jQuery("audio").bind("play",function (){
 jQuery("audio").not(this).each(function (index, audio) {
  audio.pause();
 });
});


As always, thank you so much for your help!!

If the respondent need to rate all the songs, then we can use loop and merge where in the song name and link can be put in the loop and merge field, which can be piped in the question. OR If they can rate only one song of their choice then you can add event on audio play to select its parent choice using JS.


https://community.qualtrics.com/XMcommunity/discussion/comment/45136#Comment_45136Thank you, Rondev. The latter approach is exactly what I want. Could you specify the JS code to add the event to audio play to select parent choice? Thanks again for your help!!


Use this code:
Qualtrics.SurveyEngine.addOnReady(function()

{

jQuery("audio").bind("play",function (){

 jQuery("audio").not(this).each(function (index, audio) {

 audio.pause();

 });

jQuery(this).closest('.Selection').find("input:eq(0)").prop("checked",true)

});


});


https://community.qualtrics.com/XMcommunity/discussion/comment/45142#Comment_45142Thank you so much for your quick reply! I tried the code above but I think something went wrong. My expectation is that, when a user clicks the "play" button of a song, the whole choice in which the song is embedded into (parent choice)will be selected. Thus, I can use the display logic to display the rating question.
So far, I updated the code above, when I click the song "play" button, the rating question cannot be displayed. The rating question only gets displayed if I manually select the whole choice.
Could you help take a further look? Thank you!!



Leave a Reply