#1 by ML_UIS
Dear oTree community, I want to use a form to let users rank a list of items and store the ranking in a form field called ranking. I am using the otree snippet "rank_widget" (Sortable and toArray) for this. In the data, the variable ranking mostly stores strings which contain the IDs of the items to sort (which in my case are the numbers from 1 to 5 with commas between). However, occasionally, about 10% in my data, it would store a string where one of the IDs appears twice, i.e., the array has length 6. The duplicate ID always appears at the end of the array, i.e., if 6 elements appear, then the first 5 elements are unique, and the 6th element is a duplicate of one of the previous elements. Example: 2,5,3,1,4,3 I expect an array of length 5 from each input. I tried to replicate such data entries myself, but couldn't. Did anyone else use this snippet and experienced similar patterns? Could it be an issue related to a specific browser? Since the duplicate is always at the end, can I potentially assume that the first n elements represent the actual ranking submitted by the participant? Cheers, Marco
#2 by ML_UIS
In case this matters to anyone else: I was told that the "onChange"-event may read out a Sortable placeholder element. It was suggested to use "onUpdate" instead. In the end, I actually used the solution provided by "BonnEconLab" in this forum a while ago, see https://www.otreehub.com/forum/899/ for details. To my understanding, this one uses a repeated function "recordOrderContinuously" instead of "onChange" or "onUpdate". Best wishes, Marco