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

Add support for choice from previous repeat answers #381

Closed

Conversation

ukanga
Copy link
Contributor

@ukanga ukanga commented Oct 2, 2019

Fix #38

@ukanga ukanga force-pushed the choice-from-previous-repeat-answers branch from c8041a0 to 21cf594 Compare October 2, 2019 19:39
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be so useful! Few comments inline.

if depth > 2:
name = path[-1]
nodeset = "/".join(
path[:-2] + [path[-2] + "[string-length(./" + name + ") > 0]"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that string-length(./" + name + ") > 0 is not intended to be hardcoded. It should just be whatever the contents of the choice_filter column is.

With the following definition:

type name label choice_filter
begin repeat rep
text food Enter food
end repeat
select_one ${food} choice Choose

There should be no predicate at all.

With the following definition:

type name label choice_filter
begin repeat rep
text food Enter food
end repeat
select_one ${food} choice Choose starts-with(., "b")

The predicate should be starts-with(., "b").

Note that the choice filter/predicate could possibly include a reference to another node (starts-with(., ${favorite_letter}).

nodeset = "/".join(
path[:-2] + [path[-2] + "[string-length(./" + name + ") > 0]"]
)
itemset_children = [node("value", ref=name), node("label", ref=name)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to #370 because the values will be user-generated and could contain spaces. If this turns out to be a popular feature, we may want to allow users to specify value and label separately. I don't think this needs to be done now but wanted to call it out in case that changes things for anyone.

self.assertPyxformXform(
md=xlsform_md,
xml__contains=[
'<itemset nodeset="/pyxform_autotestname/rep[string-length(./name) &gt; 0]">'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be a predicate.

@yanokwa yanokwa added this to the v1.0.0 milestone Nov 18, 2019
@lognaturel lognaturel removed this from the v1.0.0 milestone Jan 29, 2020
@DavisRayM
Copy link
Contributor

Superseded by #472

@lognaturel lognaturel closed this Sep 22, 2020
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 this pull request may close these issues.

Itemset from previous answers - select one from ${node}
4 participants