Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

One piece of audio playing uniterrupted across several questions

  • paul.emmines
  • paul.emmines's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228286 by paul.emmines
Please help us help you and fill where relevant:
Your LimeSurvey version: 5.3.13
Own server or LimeSurvey hosting: LS
Survey theme/template: Bootwatch
==================
I want to be able to get responses on a piece of audio, with an opening question and then a number of conditional questions.  I would like the audio clip to play throughout the opening Q and the subsequent Qs without interruption. 

I tried putting my audio player into the Question Group (as each piece of audio will be a Group) description rather than the individual Qs - but it doesn't then appear anywhere in the questions (I'm presenting Q by Q.)

If I could swap the question text on my questions in each group for the question group description, would that work (and how would I do it with js?)  Or is there another solution?
 

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago - 1 year 11 months ago #228293 by holch
It won't work, because with each click on "next" a new "page" is called and this would interrupt anything that was happening on the previous "page". I don't really see how this could possibly work in question by question mode.

I don't even think it would work with Javascript uninteruptetly.

It is like in real life: If you leave one concert hall to go to the next concert hall, you won't be able to hear the music from concert hall 1 on the way to concert hall 2 or at concert hall 2. Only if you carry an iPod or something and listen to your own music. ;-)

I don't want to completely exclude that there is some possibility via Javascript or an Iframe or something. But I currently don't see how this might work.

The only option that I really see is to go for "group by group" and then show/hide the questions via Javascript one after the other or something.

Maybe Tpartner has an idea.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

Last edit: 1 year 11 months ago by holch.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228302 by tpartner
That is exactly what you will need to do. Use group-by-group mode and show sequential questions via JavaScript. It gets a little complex if you allow backwards navigation or have conditional questions.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • paul.emmines
  • paul.emmines's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228319 by paul.emmines
That all makes sense. So... I have a bunch of conditional Qs. The survey is now displaying by group (but I only see the first Q as the others are conditional.) The question text itself is the same for all the Qs, so I've hidden that and replaced it with the Group Description (which gives me the audio player.)

What would the js look like in this example:

Question 1 (code Q1) is answered with answer 1 (code A1) which then needs to submit that result, and bring up the conditional Q answers (code Q2.) When Q2 is answered with answer code A6, the answer needs to be submitted and the group is then completed.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228322 by tpartner
Can you attach a small sample survey (.lss file) containing only a small sample group?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • paul.emmines
  • paul.emmines's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228351 by paul.emmines
Attached here.

So what I'm doing is asking people to identify the genres of the music - one initial question for the bigger genres, then digging down into the individual genres for the conditional follow up Qs.  The player is housed in the group description - currently just HTML5 but planning on replacing with a js player.  I'm using CSS to hide the actual Q text and replace it with the group description now that I've switched from presenting by question, to presenting by group.

I've removed the SUBMIT button (with your help!) so that clicking the answer takes you to the next question, or completes the group.

What I need is to be able to make the presentation by group "feel like" question-by-question presentation, so that the player in the Group Description plays continuously through all the questions in that group.

 

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago - 1 year 11 months ago #228368 by tpartner
I'll try to have a look but I'm on vacation for two weeks so limited access to my server.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 1 year 11 months ago by tpartner.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 11 months ago #228390 by Joffm
Hi,
there was still this "trigger('click')" in the first question. So after this the sound starts again.

Here a solution, which - I am sure - will beimproved by Tony.

1. Add a css class "hidden" to all second questions.
2. Insert this in the source code of the first question.
Code:
<script type="text/javascript">    
    $(document).on('ready pjax:scriptcomplete',function(){
 
        // Hide the submit button
        $('#ls-button-submit').hide();
 
        // Listener on the (hidden) radio inputs 
        $('#question{QID} :radio').on('change', function(e) {
           $('#question{QID}').hide();
 
// Here you have to adapt the questionIDs of your survey
           $('#question5684').removeClass('hidden');
           $('#question5685').removeClass('hidden');
           $('#question5686').removeClass('hidden');
           $('#question5687').removeClass('hidden');
        });
    });
</script>

Now, at the start only the first question is visible.
After the click the first question is hidden, but all second questions get visible.
Because of the condition only the relevant is displayed.

The disadvantage that has to be improved: the questionID of the second questions is hard coded.

Some last remarks:
What means <brk>?
If you set the "maximum numbers of buttons in a row" to "1" you don't need to set the width to 100%
Better to hide the asterisk in the "custom.css" of an extended theme


Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • paul.emmines
  • paul.emmines's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 11 months ago #228441 by paul.emmines
That's amazing! Thank you for the help. (I've also tidied up the CSS as you suggested!)

Please Log in to join the conversation.

  • paul.emmines
  • paul.emmines's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
1 year 10 months ago #229451 by paul.emmines
Taking this code one step further - could I hold the first question back from appearing until the audio begins playing?

So putting something like onplay="handleFirstPlay(event) in the HTML for the audio (which is located in the Group header.)

The first question would have the css class hidden.

How would I handle the event, to display the first question when the audio either autoplays or is started by the user pressing play?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 10 months ago #229455 by Joffm
Hi,
there is this script to hide the "submit" button until the video is finished.
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {  // Hide the "Previous" button
  $('#ls-button-submit').hide();
  var vid = document.getElementById("myvideo");
  vid.volume = 0.3;
  vid.onended = function() {
    $('#ls-button-submit').show();
  }
});
</script>
As this function fires when the video is finished (onended) I could imagine that there is something similar in the API of the player (like "play"! or "playing") when the video starts.
[url] www.w3schools.com/tags/ref_av_dom.asp [/url]

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 10 months ago #229456 by Joffm

// Hide the "Previous" button

This is obviously nonsense.
The usual copy/paste error.

Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose