Prevent question from reloading

More
1 month 1 day ago #188987 by hamstr
Dear LimeSurvey community!

I am facing a quite complicated issue and I hope someone might be able to help me out...

Participants are asked to rate short musical excerpts. The question group is designed in a way that first only a text display question is shown with the audio being played one time while all other questions (comprising the rating) as well as the next button are hidden. When the audio has ended, the hidden questions appear and the audio is triggered to be played a second time. Now as all questions are mandatory, the whole page is refreshed if participants forget to answer a question. Then this whole process starts all over, including the rating questions and the next button to be hidden.

Is there any way to stop the page from refreshing in case a question has not been answered but only show the warning message that there are unanswered items left? I'm using LS 2.64.1.

Any kind of advice is highly appreciated!

Best,
hamstr

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 weeks 6 days ago #189069 by Bigred01
You can add some JS to validate your questions and prevent the form submit if anything is invalid. I am not aware of anything in lime that would allow for this out of the box.

How are you initially triggering your questions to show when the audio is done? I imagine you are already using some JS to accomplish this. I usually store the progress of a media file in a hidden input so i can reference it again on page load. So when a media file has fully finished playing, store something like 'done' in a hidden field. Then when the page loads and I see done, there is no need to force them to view/listen to the media again, they can just start answering where they left off. This also allows you to make use of the limesurvey expressions for skip logic. Be sure to run checkconditions() on your inputs though when setting values like this.
The following user(s) said Thank You: hamstr

Please Log in or Create an account to join the conversation.

More
3 weeks 5 days ago #189076 by DenisChenu
Not 2.64.1, butr Skelvanilla can disable move next using HTML5 input attributes. Th aria-live javascript

For mandatory part :
$("[id^='question'].mandatory").each(function() {
            $(this).find('.text-item:not(.other-text-item):not(.slider-item):not(.comment-item) input:text,.text-item:not(.other-text-item):not(.comment-item) textarea,.dropdown-item select,.radio-item input:radio').attr('required',true);
        });
can work in 2.64 too.

But +1 for @Bigred01 : you already have a JS for media, then adding a question to track media is done or not can be the best solution.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
2 weeks 5 days ago - 2 weeks 5 days ago #189404 by hamstr

Bigred01 wrote: I usually store the progress of a media file in a hidden input so i can reference it again on page load. So when a media file has fully finished playing, store something like 'done' in a hidden field. Then when the page loads and I see done, there is no need to force them to view/listen to the media again, they can just start answering where they left off.


Thanks so much for this input, Bigred01!

It actually did not occur to me to store a value in a hidden field. I've now set up a hidden short-text question where "done" is stored after the first musical excerpt has ended. The ratings remain hidden as long as the short-text is empty. It was essential to trigger the value via java script (as described here: www.limesurvey.org/forum/can-i-do-this-w...nswer-via-javascript ) which resulted in the following code that now works perfectly fine for me:

<script type="text/javascript" charset="utf-8">
       $(document).ready(function(){
     document.getElementById("myAudio").addEventListener('ended',myHandler,false);
         function myHandler(e) {
             if(!e) { e = window.event; }
        $('#answer{SGQ}').val('done');
        $("#answer{SGQ}").trigger('keyup');
         }    });    
</script>
Last edit: 2 weeks 5 days ago by hamstr.

Please Log in or Create an account to join the conversation.

More
2 weeks 5 days ago #189405 by Bigred01
Nice.

I have resorted to using the limesurvey checkconditions() function directly for triggering Expression Manager logic rather than firing an arbitrary event on an input. Sooner or later you end up fighting other event listeners, propagation etc ... and it just becomes dirty and annoying. I recommend checking that function out from the survey_runtime.js file.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!