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

Name is shown instead of label in hierarchy view for external itemsets #1758

Closed
lognaturel opened this issue Dec 28, 2017 · 11 comments
Closed
Labels
bug help wanted Issues that are well-specified and don't require too much context.

Comments

@lognaturel
Copy link
Member

Software and hardware versions

Collect v1.12.2

Problem description

Name is shown instead of label in hierarchy view for external itemsets.

Steps to reproduce the problem

Load a form with external itemsets such as cascading_select_external_itemsets.xml.txt and
itemsets.csv.txt. Select some options and go to the jump screen / hierarchy view. Notice that the value names rather than the labels are shown. For that specific form above, the first choice (state) is from internal choices so it works properly. The following cascading choices are from the external csv. Choose Texas > Cameron > This is a test to see the problem clearly.

Expected behavior

The labels should be shown in the jump screen / hierarchy view.

@lognaturel lognaturel added bug help wanted Issues that are well-specified and don't require too much context. good first issue Good for newcomers! Experienced ODK devs, only take these if they need to be fixed quickly. =) labels Dec 28, 2017
@codedsun
Copy link
Contributor

@lognaturel how can I load the form, I am unable to reproduce the problem. Can u tell me how to do that plz

@lognaturel
Copy link
Member Author

Hi @codedsun! You can start with step 3 at https://github.com/opendatakit/collect#testing-a-form-locally. In this case, you'll push the form to /sdcard/odk/forms and you'll also need to push the csv file to a media folder. What I usually do is adb shell to go into the device and then mkdir /sdcard/odk/forms/cascading_select_external_itemsets-media to create the media folder. Then you can adb push itemsets.csv /sdcard/odk/forms/cascading_select_external_itemsets-media

@codedsun
Copy link
Contributor

@lognature in the hierarchy view, we are getting city as test1? is this the issue as far as I have understood, it should be showing the value?

@lognaturel
Copy link
Member Author

Yes, that’s right.

@codedsun
Copy link
Contributor

codedsun commented Jan 2, 2018

@lognaturel Could you guide me more on which class file corresponds to showing name from datasets :( I am unable to track

@akshay-ap
Copy link
Contributor

@opendatakit-bot claim

@akshay-ap
Copy link
Contributor

akshay-ap commented Jan 23, 2018

Initial analysis show that in org.odk.collect.android.utilities.FormEntryPromptUtils.getAnswerText() is returning name. i.e if Label is This is a test then its name test1 is returned.
This is due to FormEntryPrompt.getAnswerText()
In given cascading_select_external_itemsets.xml. form, this happens for county and city. But, works correctly for state.

@getodk-bot
Copy link
Member

Hello @akshay-ap, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 7 days. Are you still working on this issue?

If so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 3 days.

If you've decided to work on something else, simply comment @opendatakit-bot unclaim so that someone else can claim it and continue from where you left off.

Thank you for your valuable contributions to Open Data Kit!

@akshay-ap
Copy link
Contributor

The issue needs a bit of understanding of javarosa library source code. I would need more time to find the cause of the problem. I am learning gradle build process to make changes in javarosa and easily test it on collect.
There has been discussion on it here :
https://opendatakit.slack.com/archives/C389J6X0W/p1516726596000326

@akshay-ap
Copy link
Contributor

Flow goes like this:
To display the selected labels :
In FormHierarchyActivity
line 304 :
String answerDisplay = FormEntryPromptUtils.getAnswerText(fp, this);

In FormEntryPromptUtils
The method getAnswerText(FormEntryPrompt fep, Context context)
uses javarosa API org.javarosa.form.api.FormEntryPromt

In org.javarosa.form.api.FormEntryPromt.java
Line 176 onwards :

        if(data instanceof SelectOneData) {
            //This is Excecuted for selecting `state` (for the mentioned form cascading_select_external_itemsets.xml.txt )
            text = this.getSelectItemText((Selection)data.getValue());
        } else if(data  instanceof SelectMultiData) {
            StringBuilder b = new StringBuilder();
        List<Selection> values = (List<Selection>)data.getValue();
            for(Selection value : values) {
                b.append(this.getSelectItemText(value)).append(" ");
            }
            text = b.toString();
        } else {
            //This is Excecuted for selecting `city` and `county`
            // `data` is an instance of `StringData` class
            text = data.getDisplayText();
        }

In StringData class name is stored and getDisplayText() method returns it. This is the reason why name is displayed in hierarchy view.

Hope I am able to explain the senario.

The solution is to query the label instead of name. I am working on it to find where and how label is stored. @lognaturel Do you know how label is stored during form loading?

@getodk-bot
Copy link
Member

getodk-bot commented Feb 9, 2018

Hello @akshay-ap, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 10 days.

You can reclaim this issue or claim any other issue by commenting @opendatakit-bot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

@lognaturel lognaturel removed the good first issue Good for newcomers! Experienced ODK devs, only take these if they need to be fixed quickly. =) label Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Issues that are well-specified and don't require too much context.
Projects
None yet
Development

No branches or pull requests

4 participants