Bug on Hidden Type using relevance calculation under repeat questions

odk-collect
#1

1. What is the problem? Be very detailed.
I used hidden type to hold a value to use in a relevance calculation inside repeat question. But unfortunately using that mentioned type, relevance is not working. When i tried to use hidden type on a single question it is working well but does not inside repeat question .

2. What app or server are you using and on what device and operating system? Include version numbers.
Use version android api 15-28, Emulators and real device

4. What steps can we take to reproduce the problem?

Create questions inside repeat

  1. Set a value on a hidden type(e.g age) inside repeat
  2. Create a text type question e.g Education Type and set the relevance calculation if(age > 13 and age < 17) means "High School" and show high school questions.
0 Likes

#2

What version of Collect are you using? Can you attach a small sample XLSForm with the bug?

0 Likes

#3

Hello @yanokwa , Attached is the excel form, some of the values are passed from an external app. I using the latest version of ODK Collect

hidden_type_form.xlsx (20.4 KB)

0 Likes

#4

How do you want to set values of those hidden questions to use it in relevance calculation?

0 Likes

#5

I tried different scenarios to test that one @Grzesiek2010,

  1. Setting the values for the hidden type from the text type and check if the relevance is working under repeat question. -> NOT WORKING
  2. Setting the values from hidden type then use the hidden values to a calculation type-> NOT WORKING ALSO.

To summarize, hidden type is not working on the relevance calculation under repeat questions.

Using text type on a relevance calculation under repeat works well.

0 Likes

#6

Bit of a stab in the dark, but it sounds like pre-populated elements in the instance XML might not be getting replicated when creating new repeat group instances? @Grzesiek2010 is this something that can be easily confirmed?

[all 'hidden' does is pre-populate static values in the instance XML. So this may have nothing to do with relevance calculations per se.... If these defaults arent getting replicated when new groups are added to the instance XML for a repeat group, this might explain why any calculations - relevance or otherwise - that happen to reference these instance XML elements are misbehaving]

0 Likes

#7

Hello @Grzesiek2010 Thanks for your support always, was it verified as a bug?

0 Likes

#8

Can you please describe what you expect the form shared here to do? The user_id and no_of_children fields have nothing in the form that will set their values. You mention wanting to use an external app but you don't have any of what is described in the documentation. Can you please describe exactly what you are doing to set those values?

0 Likes

#9

Hello @LN , thanks for the reply and sorry for the short details.

Here's what i am currently implementing:

Launch ODK Collect and map the intent values to the questions from an external app. I populate the values on the questions(single or repeat) by manipulating the instance xml. I am not sure if this is a good solution though but the testing works well on my side and don't have issues on the performance prior on launching the form.

How do i map the values unto the questions?
-I get the TreeElement from the form instance root. Using the extras hashmap data from an external app and TreeElement from the form i just match the key with the tree element name and set the answer.

How do i know that the data being passed are working well?

|begin repeat|children_questions|Children Questions|
|text|child_name|Child Name|

I am able to see the names being passed on the form inside repeat.
I am able to see the data from the saved form.

<children_questions_count>2</children_questions_count>
<children_questions>
<child_name>Jose Maria</child_name>
<child_age_text />
<child_age>15</child_age>
</children_questions>
<children_questions>
<child_name>Roy Maria</child_name>
<child_age_text />
<child_age>5</child_age>
</children_questions>

Here's the updated excel form:

hidden_type_form.xlsx (19.8 KB)

Issue:

Using child_age(hidden type) is not working on the relevance calculation inside repeat.

begin_group school type question should be visible under "Jose Maria" since his age is 15.

relevance is ${child_age} > 13 and ${child_age} < 17

How can I say that this might be a bug on the form?
Using text type(child_age_text) everything works well but using hidden type does not. I think the 2 types(hidden and text) are the same it just that hidden type is hidden from the form.

0 Likes

#10

That's beyond the scope of typical usage! If you think there might be a bug, please build a form that demonstrates that bug without the unusual use of an external application. For example, you could populate those fields with a calculation.

Since it sounds like you've forked Collect and are modifying its code, you might want to step through a debugger and make sure the values you expect are there when the expressions are evaluated.

0 Likes

#11

FYI, you can try running this simple form to confirm whether the constant 'hidden' value is correctly replicated over repeat group instances.

hiddenrepeat.xls (19 KB)

this is the actual XML, showing the hidden value in the instance XML:

<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:odk="http://www.opendatakit.org/xforms" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
    <h:title>hiddenrepeat</h:title>
    <model>
        <instance>
            <hiddenrepeat id="hiddenrepeat" version="vc4gkEGfVQcuX3ET9jyu8k">
                <repeatgroup jr:template="">
                    <hiddenvalue>this is a hidden value</hiddenvalue>
                    <showhidden/>
                </repeatgroup>
                <meta>
                    <instanceID/>
                </meta>
            </hiddenrepeat>
        </instance>
        <bind nodeset="/hiddenrepeat/repeatgroup/hiddenvalue" type="string"/>
        <bind nodeset="/hiddenrepeat/repeatgroup/showhidden" readonly="true()" type="string"/>
        <bind calculate="concat('uuid:', uuid())" nodeset="/hiddenrepeat/meta/instanceID" readonly="true()" type="string"/>
    </model>
</h:head>
<h:body>
    <group ref="/hiddenrepeat/repeatgroup">
    <label>repeat group</label>
    <repeat nodeset="/hiddenrepeat/repeatgroup">
    <input ref="/hiddenrepeat/repeatgroup/showhidden">
    <label>hidden value is '<output value=" ../hiddenvalue "/>'</label>
</input>
</repeat>
</group>
</h:body>
</h:html>
0 Likes

#12

Hello @LN and @Xiphware thanks for the reply i will conduct more testing and different scenarios and will update you guys.

1 Like