Show selected options as selected


I have a multiple choice question where the person can select up to 3 options. However, the order in which she selects the options is important and must be maintained. I would like to know how I can make the form show the order exactly as it was selected and also record it in the database in the same order.

Welcome @LAFS
The selected items but NOT the order, is stored (blank-separated) in the variable of the select_multiple. You can see this e.g. in the table view and the xlsx download.
You may address the elements in this variable with selected-at(…) function: https://getodk.github.io/xforms-spec/#fn:selected-at.

You might also have a look at the rank type, which could be used after the multiple choice to rank the selected ones.

1 Like

Thanks for the feedback.

But could you explain with examples how you could solve it. I’m sending you a print of how my XLSFORM is structured.

As the documentation explains,
selected-at(${PER68}, 0) should give you the “first” selected element (name) related to the choice item list (NOT related to the order of the select in the UI). ${PER68} provides all elements (but unfortunately for your demand) in automatically selected order, separated by one blank/space. The automatic ordering is based on the line order of the choice items in the choice_list.

Another option, showing the labels, was explained by Kal_Lam https://community.kobotoolbox.org/t/how-do-i-display-the-responses-in-a-note-that-i-made-for-a-multiple-response-question/6983/13.

There you also find other examples for showing the selects as a note or a read-only list
https://community.kobotoolbox.org/t/how-do-i-display-the-responses-in-a-note-that-i-made-for-a-multiple-response-question/6983/9.

As we can see with a form download from 2021-01-16, this automatic re-ordering was introduced later with a KoBo update! Maybe @jnm or @josh or @Kal_Lam can explain more, and give a hint to any documentation. As far as we can see, before the responses (in the table view and in the XLSX download) were stored in the order of the select on UI level. Here an example

. “What disease” is a select_multiple question, the selection sequence from the user was done in the order B - A - J, as shown in the store variable. (A, B, … J, K are the sequential names of the choices in the choice_list.)

I think, this change helps for analysis (normally), but now there seems to be no more stored information about the sequence of the choices on UI level. Sorry, if we missed something here: We would appreciate that such changes are documented and communicated to the community, please.

Goodnight

I appreciate the help, however I would like it as I get selected (it appears in the note) in the same order as I selected it.

If you observe, when you select in the list, it is as if it sorts the items, in this way, it is not in the same sequence.

Hi @LAFS,

I might suggest a workaround for your problem, it’s a little messy but it would solve the isssue.

I think creating 3 questions with select-one option, indicating there is an order, then creating note to show answers might work as you intended.

What do you think?

1 Like

Hello @LAFS,
I am very sorry, I tested it. You are right, the order of the selection on UI level is NOT stored! As far as I can see, this is a change to the KoBo behaviour from 2021, which I had in mind (see screenshot example above). I updated both postings above.

Based on this, you have 3 options to get the select sequence / ranking:

  1. As @hakan_cetinkaya wrote Do 3 separate questions step-by-step. They can exclude the already selected item(s) by choice_filter. (Also, a repeat_group would be possible.)
  2. Add a ranking question after the initial multiple select, filtering only the selected items for the ranking. This would be my favorite (see example attached)
  3. Directly use a rank type question (disadvantage complex UI and all items appear).
  4. Using something like a likert scale for the items group, asking for the relevance of all (or optional) items with the same scale, e.g. very important … not at all important.

You might also think about the analytical relevance of this select (click) order as it may not be done with clear intention of ranking - and a ranking may even not be clear.

Rank for Multiple Choices 03.xlsx (50.1 KB)

The screenshot shows a MANUAL ranking done after a multiple selection before (in any order of the visible list).

The (code) names for the items are mixed here (see choice list, e.g. 2 for Avocado), only to illustrate the automatic re-ordering of KoBo in the select_multiple.
Text formatting is a bit tricky, against some automatic “optimisation” of KoBo.

Kind regards

2 Likes

Goodnight

Thanks for the feedback, I’ll try what you proposed.

1 Like

Goodnight

Thanks for the feedback, I tested the file you sent me as an attachment, but it didn’t work as expected… see the image I send you.

@LAFS, you will now need to order the rank manually by dragging and dropping the choices in the preferred order for RANK the selected fruits for the question that has been selected in Q1 (which gets automatically displayed in RANK the selected fruits.

2 Likes