Welcome to the LimeSurvey Community Forum

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

Slow input for survey users due to array filter

  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 5 months ago #143052 by Liod_DS
Hi all,

i have a real urgent question, already posted some times ago in this thread:
www.limesurvey.org/community-services/fo...lter?start=15#143034

When i filter an array question (10 answer - 28 subquestion - filter on max 9 elements) with an hidden multi, the user have to wait 2 - 6 second for the red dot to appear...

i don't understand why, when i have already displayed correctly the grid, it takes so long to click the radio... it's like a normal array at this point..

it seems LS do a lot of JS on the click-like events, but the display is already filtred and correct ... i'm ok with a little high pageload due to filter... but it's really impossibile to go live with this delay in the navigation...

Any idead to how we can reduce this time and make the survey-taking possible ?

(sorry for the "double post", even if that one was for a slightly different problem)

keep improving
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 5 months ago #143055 by LouisGac
It's a very old bug. I've already fixed 50% of it:
bugs.limesurvey.org/view.php?id=08308
github.com/LimeSurvey/LimeSurvey/commit/...12a9f446981b51b7374e

but I have to finish other things first, so I just reverted it... As soon as I come back to LS development, I'll fix it for good. It will be probably released with next major version.

For now, the only way for you to avoid this behavior is to limit the number of questions shown in a single page.
The topic has been locked.
  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 5 months ago #143057 by Liod_DS
but it's only "one" question in that page.... just that array :!

keep improving
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 5 months ago #143058 by LouisGac
how many rows?
The topic has been locked.
  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 5 months ago #143059 by Liod_DS
(simple array - 10 response - 27 subquestion - filtred to max 9)

keep improving
The topic has been locked.
  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 5 months ago #143061 by Liod_DS
here :)

keep improving
The topic has been locked.
  • LouisGac
  • LouisGac's Avatar
  • Visitor
  • Visitor
7 years 5 months ago #143062 by LouisGac
Well, it's like 27 questions: if you reduce the screen to the size of a smartphone, you'll see it's visually like 27 questions the one after the others (In a world where small smartphone screens run the world, arrays question type are a little bit outdated... they are broken with no-more-table methodology)

So, for now, to resolve this problem, you should try to redo it with a different logic: for example, 27 individual questions, shown one after the other, with conditions.
The topic has been locked.
  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 5 months ago #143066 by Liod_DS
Yes i already thinked of that... But I have 6 of this questions during the que... 27*6 ... If they're gonna ask me some varitions it's huge.. maybe i can filter the grid manually with some js?

keep improving
The topic has been locked.
  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 5 months ago #143077 by Liod_DS
No way... i waste 2 day on this prj ... and i have to disappoint my team with a failure ...

I can't insert all the question as singles ( see attachment) ... they are too much for LS...

keep improving
Attachments:
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143085 by tpartner

maybe i can filter the grid manually with some js?

Yes, you could probably do that but, since the array is mandatory, you would probably have to add an "N/A" column that would be clicked if a row is hidden;

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago - 7 years 5 months ago #143086 by tpartner
I had a little time and came up with this JavaScript solution (using the sample survey from your other thread) which drastically improves the page-load and control element reaction times.

1) Add an "N/A" answer option to the filtered array (to be hidden with JS).

2) Remove the LimeSurvey filter from the filtered array.

3) Move the hidden multiple-choice and the "maskSetter" questions to the same group as the filtered array - directly preceding it.

4)Add the following script to the source of the filtered array (I think the comments explain what's going on):

Code:
<script type="text/javascript" charset="utf-8">    
 
  $(document).ready(function(){  
 
    // Identify the questions
    var thisQuestion = $('#question{QID}');
    var hiddenQuestion = $(thisQuestion).prevAll('.multiple-opt:eq(0)');
    var thisQID = $(thisQuestion).attr('id').replace(/question/, '');
    var hiddenQID = $(hiddenQuestion).attr('id').replace(/question/, '');
 
    // Hide the filtering question
    hiddenQuestion.hide();
 
    // Remove extra array headers
    $('table.subquestion-list tbody:first', thisQuestion).append($('tr.answers-list', thisQuestion));
    $('table.subquestion-list tbody:gt(0)', thisQuestion).remove();
 
    // Loop through all answer rows and assign fake "relevance"
    $('tr.answers-list', thisQuestion).each(function(i) { 
      var thisCode = $(this).attr('id').split('X'+thisQID)[1];
      var hiddenValue =  $('input.checkbox[id$="X'+hiddenQID+thisCode+'"]', hiddenQuestion).prop('checked');
      $(this).attr('data-relevance', hiddenValue);
    });
 
    // Hide the "N/A" column
    $('table.subquestion-list tr > *:last-child, col:last', thisQuestion).addClass('na').hide();
    var answersWidth = (($('table.subquestion-list', thisQuestion).width()-$('th.answertext:first', thisQuestion).width())/$('table.subquestion-list', thisQuestion).width())*100;
    var answersCount = $('tr.answers-list:first td.answer-item:not(.na)', thisQuestion).length;
    var answerColWidth = answersWidth/answersCount;
    $('col:not(.col-answers):not(.na)', thisQuestion).css('width', answerColWidth+'%');
    $('col.na', thisQuestion).css('width', '0%');
 
    // Click "N/A" in all "non-relevant" rows
    $('tr.answers-list td.na input.radio', thisQuestion).prop('checked', false);
    $('tr.answers-list[data-relevance="false"] td.na input.radio', thisQuestion).trigger('click');
 
    // Hide all "non-relevant" rows
    $('tr.answers-list[data-relevance="false"]', thisQuestion).hide();
  });
</script>

Modified sample survey attached:

File Attachment:

File Name: filter_test_TP.lss
File Size:72 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 5 months ago by tpartner.
The following user(s) said Thank You: LouisGac, Liod_DS
The topic has been locked.
  • Liod_DS
  • Liod_DS's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 3 months ago #161336 by Liod_DS
Today this script come out of nowhere and save my day, i don't know why the built in solution is soo slow (8+ sec on each click) but the one you provide is really fast and reliable.

Thanks a lot.

keep improving
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose