Welcome to the LimeSurvey Community Forum

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

Upload modal - Strange behavior after upgrade to version 5

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #231260 by tpartner
What happens when testing with the vanilla theme?

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.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 3 months ago #231261 by squidy
Same thing with vanilla theme...

Using LS 5.x

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #231289 by tpartner
Can you attach a sample survey (.lss file) containing only the relevant question(s).

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.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 3 months ago #231303 by squidy
Sure.. The file is attached.

Using LS 5.x

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #231325 by tpartner
Your image above does not resemble the attached sample survey. I cannot reproduce the problem in that survey using the vanilla theme.

 

 

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.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 3 months ago #231326 by squidy
Hmm..
I noticed that the problem only happens when I activate the hideEmptyColumn plugin... Disabling hideEmptyColumn works, but I don't want the radio button in the question :-(

Using LS 5.x

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago - 2 years 3 months ago #231331 by tpartner
If you don't want radio buttons, use an array-texts type question.

- www.limesurvey.org/manual/Question_type_-_Array_(Texts)/en

Cheers,
Tony Partner

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

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #231332 by tpartner
Here is an example of the code required to insert "Upload" buttons into an array-texts type question:

Code:
<script type="text/javascript" data-author="Tony Partner">  
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify the questions
    var qArrayID = '{QID}';
    var qArray = $('#question'+qArrayID);
    var arrayLength = $('tr[id^="javatbd"]', qArray).length;
    var qUploads = qArray.nextAll('.upload-files:lt('+arrayLength+')');
 
    // Add some classes
    qArray.addClass('array-with-uploads-question');
    $(qUploads).addClass('hidden');
 
    // Insert the "Upload" buttons
    $('tr[id^="javatbd"] .answer-item:last-child', qArray).each(function(i) {
      $('*', this).remove();
      $(this).append('<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#upload-'+qArrayID+'-'+(i+1)+'" data-backdrop="static" data-keyboard="false">Anexar comprovante</button>');
    });
 
    // Loop through the upload questions
    $(qUploads).each(function(i) {
      // Create a modal
      $('body').append('<div class="modal upload-modal" id="upload-'+qArrayID+'-'+(i+1)+'" tabindex="-1" role="dialog">\
                <div class="modal-dialog" role="document">\
                  <div class="modal-content">\
                    <div class="modal-header">\
                      <h5 class="modal-title">'+$('.ls-label-question', this).html()+'</h5>\
                    </div>\
                    <div class="modal-body">\
                    </div>\
                    <div class="modal-footer">\
                      <button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>\
                    </div>\
                  </div>\
                </div>\
              </div>');
 
      // Move this question into the modal
      $('#upload-'+qArrayID+'-'+(i+1)+' .modal-body').append($(this));
      $(this).removeClass('hidden');
    });
 
    // Interrupt the Next/Submit function (to put upload questions back in the form)
    $('#ls-button-submit').on('click', function(e) {    
      $('.upload-modal .upload-files').appendTo($('.group-container:eq(0)')).addClass('hidden');
    });  
  });
</script>

 

Sample survey attached: 

File Attachment:

File Name: limesurvey...3217.lss
File Size:40 KB

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.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 3 months ago #231333 by squidy
Very nice.. So thanks, Tony.

Using LS 5.x

Please Log in to join the conversation.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 3 months ago #231672 by squidy
Hi Tony...
Everything is working fine, except when the participant saves the files in this modal and goes back to a page before this question. When he comes back to this question page again, the files are gone (not saved).

Using LS 5.x

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 years 3 months ago #231736 by tpartner
This script will fix that bug:
 
 
Code:
<script type="text/javascript" data-author="Tony Partner">  
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify the questions
    var qArrayID = '{QID}';
    var qArray = $('#question'+qArrayID);
    var arrayLength = $('tr[id^="javatbd"]', qArray).length;
    var qUploads = qArray.nextAll('.upload-files:lt('+arrayLength+')');
 
    // Add some classes
    qArray.addClass('array-with-uploads-question');
    $(qUploads).addClass('hidden');
 
    // Insert the "Upload" buttons
    $('tr[id^="javatbd"] .answer-item:last-child', qArray).each(function(i) {
      $('*', this).remove();
      $(this).append('<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#upload-'+qArrayID+'-'+(i+1)+'" data-backdrop="static" data-keyboard="false">Anexar comprovante</button>');
    });
 
    // Loop through the upload questions
    $(qUploads).each(function(i) {
      // Create a modal
      $('body').append('<div class="modal upload-modal" id="upload-'+qArrayID+'-'+(i+1)+'" tabindex="-1" role="dialog">\
                <div class="modal-dialog" role="document">\
                  <div class="modal-content">\
                    <div class="modal-header">\
                      <h5 class="modal-title">'+$('.ls-label-question', this).html()+'</h5>\
                    </div>\
                    <div class="modal-body">\
                    </div>\
                    <div class="modal-footer">\
                      <button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>\
                    </div>\
                  </div>\
                </div>\
              </div>');
 
      // Move this question into the modal
      $('#upload-'+qArrayID+'-'+(i+1)+' .modal-body').append($(this));
      $(this).removeClass('hidden');
    });
 
    // Interrupt the Previous/Next/Submit function (to put upload questions back in the form)
    $('#ls-button-previous, #ls-button-submit').on('click', function(e) {    
      $('.upload-modal .upload-files').appendTo($('.group-container:eq(0)')).addClass('hidden');
    });  
  });
</script>

Sample survey attached: 

File Attachment:

File Name: limesurvey...7(1).lss
File Size:46 KB

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.

  • squidy
  • squidy's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
2 years 3 months ago #231750 by squidy
It worked.. Thank you very much Tony..

Using LS 5.x

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose