How can I make text entry to appear after the sound stimuli | XM Community
Question

How can I make text entry to appear after the sound stimuli

  • 2 April 2020
  • 1 reply
  • 9 views

I am currently designing an experiment that a participant listens to a sound file and records the short answer to it. The current design allows participants to record their responses while listening to sound files. I want the subjects to record their responses after the sound file is finished. In other words, I would like to have a text entry box at the end of the sound file where the participants can record their answers. I would be really grateful if you could let me know the code to make this possible.

FYI, below is the code that I have made for each trial. So far, I have added codes regarding "Next Button' and "setTimeout", so that the participants cannot move on to the next trial by themselves, but automatically move on to the next trial after 15000 ms. I have also added codes to hide audio file, so that they cannot replay the sound file after they hear it once.

Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
$('NextButton').hide();
$('PreviousButton').hide();
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
jQuery('audio').on('ended', function() { jQuery(this).hide(); });
setTimeout(function () {jQuery('#NextButton').click();},15000);

Thank you very much!


1 reply

Userlevel 7
Badge +27

If your audio file is in the question text of a Text Entry question, you could try adding the below to the OnReady section of the question’s JavaScript:

var qid = this.questionId;
jQuery("#NextButton").hide();
jQuery("#PreviousButton").hide();
jQuery("#"+qid+" .QuestionBody").hide();

jQuery("audio").on("ended", function() {
jQuery("audio").hide();
jQuery("#"+qid+" .QuestionBody").show();

setTimeout(function () {
jQuery("#NextButton").click();
},15000);

});

 

Leave a Reply