survey-library icon indicating copy to clipboard operation
survey-library copied to clipboard

Checkbox - The `hasComment` option

Open SamMousa opened this issue 1 year ago • 2 comments

Are you requesting a feature, reporting a bug or asking a question?

Feature

What is the current behavior?

Multiple choice question configuration happens on 2 "levels". There's the definition of choices and then there are modifiers that also add choices: hasOther and hasNone. While these modifiers work they are limited.

What is the expected behavior?

My idea would be to move the configuration to a single level, that of the choices. Each choice could then get additional options:

  • isExclusive
  • hasComment
  • fixedPosition

isExclusive

This option would implement logic similar to the option added by hasNone (and could replace its functionality). There are use cases for multiple exclusive options and this also allows the user to program the value for the option.

hasComment

This option would implement logic similar to the option add by hasOther, but to specific items. When such an item is checked a text area shows up.

isFixedPosition

When randomizing answer order it is sometimes desirable to have some control over the choices. Checking this box would fix the position of this item in the list. Randomization happens by taking the spots and randomizing over them; this is relatively simple to implemented and I have done so in other use cases:

  1. Choices look like this, where F means fixed: x F x x F x x
  2. Copy the choices that need to be randomized (5 elements) to an array
  3. Loop over the original choices array and for each index check if it is fixed, if not, replace it with a random element from 2
  4. Remove the inserted element from 3 from the array
  5. Repeat until array from 2 is empty

Ideally when adding this one would phase out hasNone, hasOther and hasComment. hasComment could be implemented as a default value for the individual hasComment setting on a choice.

SamMousa avatar Aug 26 '22 07:08 SamMousa

Hello @SamMousa, Thank you for your valuable suggestions.

Regarding adding the hasComment option to a Checkbox item configuration: this would require significant changes to survey logic. We noted down this idea for further consideration. In the meantime, we suggest that you create a Text/Comment question and toggle its visibility using the visibleIf option based on selected Checkbox items. Here is a simple example. For more information, refer to this help topic: Question Visibility.

Regarding two other suggestions: I decided to extract them to separate issues:

Please refer to them for further details.

JaneSjs avatar Aug 29 '22 17:08 JaneSjs

Thanks for the feedback @JaneGaid, I'm aware of the workaround (s), just posted this here for improvement in the lib!

SamMousa avatar Aug 29 '22 21:08 SamMousa

@SamMousa We have introduce a new functionality that is related to this issue. You can find it in v1.9.117: Reorder "None", "Other", and "Select All" in Select-Based Questions..

Thank you, Andrew

andrewtelnov avatar Nov 23 '23 13:11 andrewtelnov