Skip to main content

Multiple Choice Component

Summary

The multiple choice component lets you give users multiple choice questions in the survey. This component can also be configured as a dynamic survey, i.e., it can display certain options or choices as corresponding answers are responded.

Initial multiple choice component settings panel:

form template

Apart from the general fields, the initial multiple choice component settings panel lets you choose the type. There are four different types of multiple choice components you can choose from:

  • Collection: Make the elements of a collection the choices or options available.
  • Users: Users in the company's Cotalker database can be selected as answers. Useful for delegating or summoning purposes.
  • Item list: Make a simple list of possible answers.
  • API: Obtains data to display from an external URL or from a Cotalker module.
note

Depending on what type is chosen, new fields will be displayed in the settings panel. Each type and its corresponding fields are explained below.


1. Collection Type

This option lets you choose the collection that contains the elements to be displayed as options. You must have the collection with its elements previously created in the Database panel of the Administrator.

The collection type has the following fields for setup:

  • Filter by: Filtering allows the question to display only certain choices or elements. It can also be used to set up a dynamic survey. Setup information.
  • Hierarchy selection: Creates a dynamic survey. When selected, concatenating collections with their respective elements can be set up as possible answers. Setup information.

1.1 Filter By

Mainly, filtering allows the question to display only certain choices or elements.

Available options in the Filter by field are:

  • No filter: No filter is applied.
  • Subproperty: Filters the sub-properties of a collection based on a previously chosen element from a collection type multiple choice component in the same survey. More information.
  • Subproperty-channel: Displays the sub-properties of a collection associated with the channel as options. More information.
  • Subproperty-user: Displays the sub-properties of a collection associated with the user as options.

- Subproperty Example

The subproperty filter lets us create dynamic surveys by filtering a collection's subproperties through at least one other multiple choice component in the same survey.

tip

Usually, the hierarchy selection option is easier to use for concatenating collections, but there are instances when you might want to customize or tweak your dynamic surveys in relation to the elements that will be shown as options. For these instances, you can use the subproperty filter.

Example

For example, if you have a collection that is associated with two other collections, you can use the subproperty filter to display options from both collections of subproperties based on an initial response from another survey question.

In the following example, a collection of mammals has two elements: land and sea mammals. The collection is also associated with two other collections of mammal species for its subproperties. The survey will let users choose either land or sea mammals, and depending on their answer, choose a corresponding mammal species from the two different collections.

subproperties survey example
Setup
  1. First, add a multiple choice component with the following settings:
subproperties survey example
  • Type: Collection
  • Identifier: In this example, we chose mammal_select. This identifier will be used in the next steps to reference the other components to this one.
  • Collection: Here we chose the Mammalscollection. This should be your most general collection. In this example, the collection has two elements: Land Mammals and Sea Mammals. Each element has two other collections associated with them: Species and Other Species. The elements of these last two collections will be the subproperties that will appear as options. We will use these in the following steps.
  • Filter by: No filter
  1. Next, add another multiple choice component with the following settings:
subproperties survey example
  • Type: Collection
  • Identifier: In this example, we chose species_001.
  • Collection: For this example, Species contains the subproperties of the Mammals collection.
  • Filter by: subproperty
  • Filter data: Here we wrote mammal_select, which is the identifier of the previous component that references the greater collection.
  1. Optional step: Add another multiple choice component with the following settings:
subproperties survey example
  • Type: Collection
  • Identifier: In this example, we chose species_002.
  • Collection: For this example, Other Species is a second collection associated with the Mammals collection.
  • Filter by: subproperty
  • Filter data: Once again we wrote mammal_select, which is the identifier of the first component that references the greater collection.
  1. Press Save. You're good to go!

- Subproperty-channel Example

Fill the Filter Data field with the code of the collection to look for in the channel. The available options will be its sub-properties.

Lets take the following settings for example:

  • Collection: a collection named Brands
  • Filter by: set to subproperty-channel
  • Filter data: a collection named category_suv

This will display as options only elements that:

  • are Brands
  • and sub-properties of any property of the channel –in which the survey is called– that has the category_suv type.

This is particularly useful since a channel can have many properties assigned to it, but we need to know what type of filter to use in the Filter data field.


1.2 Hierarchy Selection

Creates dynamic surveys, i.e., users' choice in one question will determine the options available in the following question. When selected, concatenating collection trees with their respective elements can be set up as answers. This means that each answer takes you to more specific options, like choosing a country, then a region, and finally a city.

Survey Tree Selector
Setup
Pre-Requisites

First, you must create the collections and have them associated with each other through their Elements. For example, if you have a countries collection, in its Elements section add the collection corresponding to regions. And do the same with regards to the regions and the cities collection.

  • Create a survey with a multiple choice component.
  • Set the type to Collection.
  • Activate the Hierarchy selection option.
  • Set Collection to the first and most general collection.
  • Set Target collection to the last and most specific of the collections.
Survey Tree Selector

note

No matter how many collections, if they are all associated with each other through their elements section, then the survey will concatenate them accordingly, from first to last.


tip

Hierarchy selection has its own Filter by field. You can select multiple collections to filter what elements will be displayed. All the collections that should be displayed must be selected in order for the question to work properly.

2. Users Type

The choices available when using the users option will depend on the company's contact display mode configuration.

2.1 Filter Type

Filtering allows the question to display only certain choices or elements. Available filters for users are:

  • No filter
  • Jobs title
  • Subordinates
  • Bosses
  • Peers

2.2 Job Title

Company job categories can be selected to act as filters. For information on how to add job categories refer to the Company section.

3. List of Items Type

Easily create a list of items or options to choose from.

Example of how a user will see the list of items in a survey:

list of items
Setup

From the settings panel, press the + Add Item button to create a new option and set the following fields:

  • Display: Text that will be shown to the user.
  • Value: The value assigned to the item. The value will be sent internally in the answers.data.process field.

The settings panel should look something like this:

list of items

4. API Type

Multiple choice surveys can also search for answers through an API request. When trying to respond this type of survey question, each time the user enters a value in the search dialog box, an API request is sent to the endpoint with the search value.

info

This is an advanced feature that requires programming skills.


Template

list of items
  • Source: The options are External URL or Cotalker. Choosing Cotalker adds a relative Cotalker path; otherwise, an absolute address is required.
  • Method: POST is the only value available.
  • Path: Field that indicates the external URL or the relative path of the Source.
  • Identifiers: Other survey values that you want to pass to the API.

How to implement

  1. OPTIONAL: Create a custom new lambda function using any server.

  2. ENDPOINT: Create an endpoint that responds to POST /{endpoint}.

  3. PACKAGE FORMAT:
    The data at the endpoint must have the following structure:

    { 
    "data": [
    {
    "_id": "string",
    "display": "string",
    "code": "string"
    }
    ]
    }

    Here's an example:

    { 
    "data": [
    { "_id": "1234", "display": "Main Reactor", "code": "main_reactor" },
    { "_id": "5678", "display": "South Reactor", "code": "south_reactor" },
    { "_id": "9012", "display": "East Reactor", "code": "east_reactor" },
    { "_id": "3456", "display": "North Reactor", "code": "north_reactor" },
    { "_id": "7890", "display": "West Reactor", "code": "west_reactor" },
    ]
    }
  4. SEARCH:

    From the UI, when answering an API-type multiple-choice survey question, a search window appears:

    list of items

    Each time a search is done within the search window, Cotalker sends a POST request with a JSON body as shown below:

    SAMPLE REQUEST:

    curl -X POST https://apitest.com/test \
    -H "Authorization: Bearer $ACCESS_TOKEN" \
    -d "{
    "search": "search-string",
    "data": {
    "identifier_a": [question-responses],
    "identifier_b": [question-responses],
    ...,
    "identifier_n": [question-responses]
    }
    }"

    The search value in the JSON body filters the results shown in the UI. Body Schema

    • search: The search query string entered in the dialog box.
    • data.identifier_x: Names of the question identifiers that are defined in the survey component settings. Their value type, i.e., text, number, date, etc., will depend on the original question type.
  5. USAGE:

    The options the user selects from the search window are stored in a COTAnswer data model, i.e., answer.data[x].process: [string].

    Following the package format example given above, if a user selected "South Reactor" and "North Reactor", the result would be stored something like this:

    answer.data[0].process: ['south_reactor', 'north_reactor'].

    The answer would also include the data gathered from the selected identifiers.