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

Fixed <output> inside repeat has absolute path instead of relative #450

Merged
merged 8 commits into from
Jul 24, 2020
Merged

Fixed <output> inside repeat has absolute path instead of relative #450

merged 8 commits into from
Jul 24, 2020

Conversation

gushil
Copy link
Contributor

@gushil gushil commented Jun 10, 2020

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2020

Codecov Report

Merging #450 into master will increase coverage by 0.27%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     enketo/enketo-core#450      +/-   ##
==========================================
+ Coverage   83.11%   83.39%   +0.27%     
==========================================
  Files          25       25              
  Lines        3595     3595              
  Branches      833      834       +1     
==========================================
+ Hits         2988     2998      +10     
+ Misses        460      454       -6     
+ Partials      147      143       -4     
Impacted Files Coverage Δ
pyxform/survey_element.py 94.44% <ø> (+4.27%) ⬆️
pyxform/survey.py 91.51% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b0bd9d4...818c452. Read the comment docs.

@MartijnR
Copy link
Contributor

MartijnR commented Jun 10, 2020

Thanks @gushil, and OpenClinica, for stepping in so quickly! I've tried to break the fix with some black-box testing, and was not able to, so that's good. 👍

@ukanga this is the fix for the issue Ona reported recently. I'll add you as a reviewer, in case you have time (and to share the load with @lognaturel). I think, it would be great to get a fix merged soon, considering the problems this is causing for Enketo users. This is the kind of bug that is most urgent, because it is producing incorrect XForms and most (all?) servers don't have a way to automatically re-convert those forms to correct them.

@MartijnR MartijnR requested a review from ukanga June 10, 2020 22:37
@MartijnR
Copy link
Contributor

@ukanga, just pinging to check if you're able to look at this Ona-reported issue. :)

@MartijnR MartijnR requested a review from lognaturel June 23, 2020 17:02
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.

I've done an initial pass with a few questions and observations. Any more hints you can give to how you approached this, what you're confident about, what questions might have come up for you would be really helpful.

pyxform/tests_v1/test_repeat.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
@MartijnR
Copy link
Contributor

MartijnR commented Jul 8, 2020

Thanks for your review @lognaturel! Just wanted to let you know OpenClinica has slightly delayed deploying the new pyxform version (they use a very old version), and I've heard @gushil may pick this up in a few weeks.

Copy link
Contributor Author

@gushil gushil left a comment

Choose a reason for hiding this comment

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

Added new commit that addressed some of the feedbacks above.

Thanks for the feedbacks @lognaturel !

pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/tests_v1/test_repeat.py Outdated Show resolved Hide resolved
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.

Thanks! This is making more sense to me. I think there's either some code you can cut down or some possible bugs. :D I've also made a couple of test suggestion.

pyxform/survey.py Show resolved Hide resolved
pyxform/tests_v1/test_repeat.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
pyxform/survey.py Show resolved Hide resolved
pyxform/survey.py Outdated Show resolved Hide resolved
@lognaturel
Copy link
Contributor

@MartijnR I don't think there's anything in the spec that specifically addresses output in a text translation for labels in secondary instances. It seems wacky but people use it in lieu of enketo/enketo#721: https://forum.getodk.org/t/xlsform-index-repeat-calculate-filter-choice-odk-collect-v1-27-crash/27411. Is that supposed to be supported? If so, this PR should generate relative refs for those.

@MartijnR
Copy link
Contributor

@lognaturel, you're referring to the output below, right? (using the test.xlsx form from that forum thread)

 <instance id="hm_name">
                <root>
                    <item>
                        <filter>1</filter>
                        <label>${name1}</label><!-- uh oh -->
                        <name>1</name>
                    </item>

I tried to figure out a syntax below. Not sure if I succeeded in that, and whether this implementable in pyxform. It wouldn't work in Enketo in the near future. It also wouldn't work for external instances, which to me is a fair argument to not support it all.

It is extremely convoluted xlsform (and xform) syntax indeed. I agree that #38 would seem so much more sensible.

<itext>
      <text id="a1">
             <value><output value="../name1"></value>
      </text>
</itext>

 <instance id="hm_name">
                <root>
                    <item>
                        <filter>1</filter>
                        <itextId>a1</itextId>
                        <name>1</name>
                    </item>

...

            <itemset nodeset="instance('hm_name')/root/item[filter &lt; ( /data/qb_1 +1)]">
                <value ref="name" />
                <label ref="itext(itextId)" />
            </itemset>
</select>

@MartijnR
Copy link
Contributor

Oh LOL #403

@lognaturel
Copy link
Contributor

Ahhh! I knew I'd seen something fly by related to this but couldn't think of where. Let's not worry about it here and instead try to get enketo/enketo#721 which would be really great. So I think this is very close to being ready.

@pbowen-oc
Copy link

@lognaturel @MartijnR - I can't tell from the discussion above - will this update remove the existing behavior that allowed item references in choice labels? We have used this to very good effect (never in a translated form configuration). It is very helpful for allowing the user to (for example) associate a medication and an adverse event or associate a procedure with a previously identified tumor.

In our experience, the only restriction we found was that we needed some text in the label other than the item reference itself.

@lognaturel
Copy link
Contributor

Can you please share a minimal XLSForm on enketo/enketo#434 that illustrates the pattern you want to use, @pbowen-oc? This PR doesn’t change existing behavior around this so let’s continue the conversation there.

@pbowen-oc
Copy link

@lognaturel - Thanks, I have added an example file to enketo/enketo#434

@@ -743,15 +752,13 @@ def itext(self):
)
continue

if media_type == "long":
value, output_inserted = self.insert_output_values(media_value)
if media_type == "form":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to make changes to this line if I changed translation_key to form.

@gushil gushil requested a review from lognaturel July 17, 2020 14:16
@@ -593,7 +593,7 @@ def _setup_choice_translations(name, choice_value, itext_id):
for d in element.get_translations(self.default_language):

translation_path = d["path"]
translation_key = "long"
translation_key = "form"
Copy link
Contributor

Choose a reason for hiding this comment

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

I meant changing the name of the variable to form. long and guidance are values for the form attribute.

@@ -271,6 +271,7 @@ def get_translations(self, default_language):
for lang, text in constraint_msg.items():
yield {
"path": self._translation_path("jr:constraintMsg"),
"output_context": self,
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, great! There was a bug before because all of these need relative paths as well.

lognaturel
lognaturel previously approved these changes Jul 23, 2020
@lognaturel lognaturel self-requested a review July 23, 2020 20:31
@lognaturel
Copy link
Contributor

I took the liberty of renaming the variable that represents the translation form and adding tests for the additional translated columns. Unfortunately it looks like I forgot to run black and I had to quickly leave my computer so things are in a weird state. I’ll fix and merge this evening.

Thanks for doing this and for taking my feedback, @gushil!

@lognaturel lognaturel merged commit b6093a1 into XLSForm:master Jul 24, 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.

5 participants