Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ukanga opened this issue Jan 27, 2025 · 0 comments

Comments

@ukanga
Copy link
Contributor

ukanga commented Jan 27, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant