Skip to content

Commit

Permalink
Update default predicate for choices from previous repeat answers
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM committed Sep 24, 2020
1 parent ba03680 commit 41c36ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pyxform/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ def build_xml(self):
depth = len(path)
if depth > 2:
name = path[-1]
nodeset = "/".join(
path[:-2] + [path[-2] + "[string-length(./" + name + ") > 0]"]
)
# Choices must have a value. Filter out repeat instances without
# an answer for the linked question
nodeset = "/".join(path[:-2] + [path[-2] + f"[./{name} != '']"])
itemset_children = [node("value", ref=name), node("label", ref=name)]
result.appendChild(node("itemset", *itemset_children, nodeset=nodeset))
else:
Expand Down
2 changes: 1 addition & 1 deletion pyxform/tests_v1/test_repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_choice_from_previous_repeat_answers(self):
self.assertPyxformXform(
md=xlsform_md,
xml__contains=[
'<itemset nodeset="/pyxform_autotestname/rep[string-length(./name) &gt; 0]">'
"<itemset nodeset=\"/pyxform_autotestname/rep[./name != '']\">"
],
run_odk_validate=True,
)
Expand Down

0 comments on commit 41c36ad

Please sign in to comment.