Skip to content

Choices have reference to the last parent in the event two or more questions use the same choices #749

@ukanga

Description

@ukanga

The generated XML is as expected but if you traverse the Survey object and request a choice parent on the first occurrence, it will point to the last question. In the example below, the questions fruita and fruitz use the same choices. With the current implementation, fruita.children[0].parent == fruitz instead of fruita.

| survey |
|        | type                   | name   | label   |
|        | begin group            | a      | Group A |
|        | select one fruits      | fruita | Fruit A |
|        | select one fruity      | fruity | Fruit Y |
|        | end group              |        |         |
|        | begin group            | b      | Group B |
|        | select one fruits      | fruitz | Fruit Z |
|        | select_multiple fruity | fruitb | Fruit B |
|        | end group              |        |         |
| choices |
|         | list name | name   | label  |
|         | fruits    | orange | Orange |
|         | fruits    | mango  | Mango  |
|         | fruity    | orange | Orange |
|         | fruity    | mango  | Mango  |
        

Note: when using choices as export headers, you may refer to the choice's parent's name to create a context-specific header, for example, fruita/orange, fruita/mango. We do this in some places in onadata hence the reason it became an issue for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions