Prevent question from reloading

Plus d'informations
il y a 4 semaines 1 jour #188987 par 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

Connexion ou Créer un compte pour participer à la conversation.

LimeSurvey Partners
Plus d'informations
il y a 3 semaines 4 jours #189069 par Bigred01
Réponse de Bigred01 sur le sujet Prevent question from reloading
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.
Les utilisateur(s) suivant ont remercié: hamstr

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 3 semaines 3 jours #189076 par DenisChenu
Réponse de DenisChenu sur le sujet Prevent question from reloading
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 .

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 3 jours - il y a 2 semaines 3 jours #189404 par hamstr
Réponse de hamstr sur le sujet Prevent question from reloading

Bigred01 écrit: 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>
Dernière édition: il y a 2 semaines 3 jours par hamstr.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 semaines 3 jours #189405 par Bigred01
Réponse de Bigred01 sur le sujet Prevent question from reloading
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.

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!