Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Ranking Question [Drag to Container] - Setting a range of items to rank

I am using a ranking question with the Ranking Format set to "Drag to Container".

The number of items to rank can be set to "All" or "Partial".

I have 12 items and I would like to allow the respondent to rank from 1-5 items.

How can I allow this range given I only have the 2 options available?

Appreciate your help.

asked Apr 7, 2020 by Paul Moon Platinum (99,385 points)
Saurabh informed me this was available in the Question Library. Thanks Saurabh.

Do we insert a pre-skip on the HELPER 2 text question and always skip given this was showing up when testing?

1 Answer

0 votes
Ranged items to rank is one of the features baked into "Custom Drag-and-Drop Ranking":

answered Apr 7, 2020 by Zachary Platinum Sawtooth Software, Inc. (207,300 points)
Thanks Zachary for assisting. Always appreciated.

I was using an older Drag and Drop question from the Question Library - RangedDndRanking. I think I had this working okay. I inserted a pre-skip over the HELPER2 question so a blank screen would not appear after the ranking page. Is that correct?

Now I have just downloaded the drag and drop question you kindly provided from the Question Library. I now have it imported into Lighthouse Studio.

So I started setting this up and testing. I encountered some issues.

My questions are as follows ...

1/ I do not have any other specify items to rank. I have 12 items. For lines 41-54 where your notes refer to other specify options, should I just set these other specify items to 13 and 14 (the next highest code numbers)? Or is there another method I should use to indicate I am not using any other specify items?

2/ I was trying to test this where I would only rank 1 or 2 or 3 or 4 items. As I was going backwards and forwards, I had the warning appear a few times where it would say I must rank 5 items? I did set the minimum to 1 on line 37 and the maximum to 5 on line 38.

3/ I have not changed anything in HELPER1 or HELPER2 questions. Should I be changing anything here for either of these?

4/ On line 57, I changed MINIMUM to 1 and MAXIMUM to 5. I did not touch line 58.

5/ Your notes mention HELPER2 optionally being removed. I have left it there. Should I remove it or not?

6/ Do I need to insert a pre-skip on the HELPER 2 text question and always skip given this was showing up when testing?

Hoping you can shed some light on all of the above.

Thanks Paul.
Zachary, when I was using the older Question Library question - RangedDndRanking, I thought I had this working perfectly but I noticed when I only ranked 1 or 2 or 3 or 4 items, 5 items had actually had been ranked in the data?

For example, if I ranked only 3 items, the data was correct for the 1st and 2nd and 3rd items, but for some reason, data appeared as if I ranked a 4th and 5th item also?

Hoping you can help with both the RangedDndRanking and Custom Drag and Drop Ranking issues I have raised? Thanks.
Using the old question should be fine so long as you don't have other specify fields.  I just only plan on making changes to the new one in the future.

In either version, the second helper question is optional.  You could pre-skip past it, but that's effectively the same as just deleting it.  At the end of the day, the second helper's code just removes fake responses from the ranking question.  Respondents not reaching this code is fine so long as you take this into consideration come analysis: the data will always claim that the respondent answered the maximum number of items, but the first helper will tell you how many they actually answered.

Having respondents visit the second helper question should handle this for you.  Keep in mind that the second helper doesn't have to be on its own page.  Slipping it onto whatever page a respondent is meant to see after the ranking question will work.
Apologies Zachary for the constant queries.

I'm having a bit of trouble getting this working?

First of all, I agree making changes to the new question is how you should approach things going forward. The old question can just sit there as stay as is right?

I was trying to do the following ...

1/ Get the old question working
2/ Get the new question working

I'm having a bit of trouble with both at the moment.

I'm probably not understanding all the steps here. Is the ranking question being populated with fake ranking data for the maximum number of ranked items specified in the ranking question? Then the ranking question is answered and then the fake data is removed by HELPER2? Have I got that right?

And you are saying that I can put HELPER2 on the next survey page (with another question) to technically hide it?

Have I missed anything?

I have now been getting this error in my log file for the old question ...

time= 7 Apr 2020 - 12:09:37 EST | Lighthouse Version= 9_3_1 | ErrorNum= 269 | msg= Database error. Error in "SetValue" function. Cannot update data row. | Server Error: DBD::mysql::st execute failed: Incorrect integer value: '' for column 'Q5_3' at row 1 at C:/inetpub/wwwroot/s/mlccvai/cgi-bin/authlib9_3_1.pl line 17, <GEN2> line 16. | params= Q5Helper1_Ranked=>1, Q5_1=>, Q5_10=>4, Q5_11=>, Q5_12=>, Q5_2=>1, Q5_3=>3, Q5_4=>, Q5_5=>, Q5_6=>, Q5_7=>, Q5_8=>5, Q5_9=>2, hid_backup=>mlccvai,1,899410834,5,1, hid_checksum=>899410834, hid_destination=>Q5, hid_javascript=>1, hid_list_Q5=>9,2,3,10,8,12,5,4,1,6,7,11, hid_pagenum=>6, hid_pagetime=>1586279371, hid_prev_Q5=>12,Q5,5,2788dd215f5cb46b2767bf6f5f9fefea, hid_prev_Q5Helper1=>13,Q5Helper1,5,13ba3fdf0ad8a25c950b73e64ba2c6af, hid_previous=>0, hid_q_Q5=>Q5, hid_q_Q5Helper1=>Q5Helper1, hid_respnum=>1, hid_s=>Av8AAJ0dt7PHSEVhJBhTZtUB16cmAAAArTGPiv58dFEcK2dK5y3mkqUrhYT-e3JQCCl_Vvlsu8Q3tx0ZbeLvy46yMBC0aPuX, hid_screenwidth=>1522, hid_studyname=>mlccvai, sys_next_hop=>16, IP= , client= Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36

Can you spot what I have done wrong here?
That's basically how the question works, yes.  When the next button is clicked, the code records how many items the respondent ranked, then invisibly ranks extra ones to satisfy the server's partial items requirement.  The second helper just attempts to undo those fake responses.

I've seen that problem on SQL Server databases before, but I'm not used to it happening with MySQL.  You could get around it by having the second helper set a value like 0 or 999 rather than the empty string, or just by not including the second helper at all.
If I remove the second helper, how do I wipe the fake ranked data?
One option would be post-collection data processing.  An Excel macro or something similar could clear out the unnecessary columns.

If you need something during data collection, I think a constructed list could be up to the task.  If you run AddSorted on the ranking question and SetListLength with the variable from the first helper question, you should end up with a constructed list of items actually ranked by the respondent.
OK, so there's a few options within the survey or post survey.

I could do a SETVALUE approach within (if ranking=0, setvalue=null).

And as you pointed out, the constructed variable approach.

Strange that the database disliked setting the fake data to an empty value?

I just conducted a test where I changed ...

        SETVALUE($rankingQ . '_' . $i, '');

to this ...

        SETVALUE($rankingQ . '_' . $i, 0);

Now this set all fake data to "0". So it worked fine.

One easy option is to download the data after survey closure and do a search and replace of the 0's in the ranking question variables and replace with a null.

Thanks for clearing that up.

I'd like to get the new question working. I'll move on to that a little later after I have this project under control.
Things get tricky because there are three different sort of databases: SQLite (Test Survey), MySQL (Sawtooth Software hosting / self hosting), and SQL Server (self hosting).  Then among those there are different data column types which could be different across different versions of Lighthouse Studio.  So where one database in one version is okay with writing an empty value, another database in another version might not be.  Perhaps the better solution would be for this code to just always write -1 or something; not as convenient as simply clearing the column, but less buggy.

Backing up to the new question not working right is news to me.  I usually test that case, but perhaps there's an edge case I haven't considered or perhaps something in ranking questions has changed between 9.3.0 and now that's messing stuff up.  I'll have to look into that one more.
I'm okay with the old question and having to whip up a cleaning step.

As you mentioned, I can do it post survey in Excel or via a constructed list approach using AddSorted or using SetValue. So that's all good news.

When I was testing the new question, assume I have set the maximum items to 5. I then ranked say 1 or 2 items, went forward, then went back, then tried to go forward again and it barked at me saying I did not rank 5 items. I just hit NEXT one more time and it would go forward.

If you could check this issue out in the meantime, that would be super.

Right now, I have the old question working for this upcoming urgent survey. So that makes me happy for now.

I forgot to mention that your notes for the new question in the Question Library did not indicate updating the names in HELPER2 for the ranking question and the HELPER1 question.

Thanks for all your generous input.

If I have spotted a bug, then it's a good thing that we can get it fixed.

Stay safe and well.