episphere / quest

experimenting with the idea of a questionnaire markup
https://episphere.github.io/quest/
2 stars 11 forks source link

Module 3 - valueOrDefault inconsistencies #403

Closed huip-ims closed 2 years ago

huip-ims commented 2 years ago

@danielruss @naiyume @boyd-mj Hi Daniel & Brian - While testing Module 3 Question T69 (Quest ID: SECSMLF2) using the renderer, we noticed that we’re getting different results using the same inputs. Could you please help us understand why the following 2 examples are happening?

For this code:

|grid?|id="GRID_SECSMLF2"|Thinking about your usual adult life, about how often were you around the tobacco smoke of others, for example in your home, work, or school?|[ 

[SECSMLF2A] Age 0 to age {$e:min(17,valueOrDefault("AGE","age",100)) };
[SECSMLF2B,displayif=greaterThan(difference(isDefined(AGE,age),2),18)] Age 18 to age {$e:min(24,valueOrDefault("AGE","age",100)) };
[SECSMLF2C,displayif=greaterThan(difference(isDefined(AGE,age),2),25)] Age 25 to age {$e:min(29,valueOrDefault("AGE","age",100)) };
[SECSMLF2D,displayif=greaterThan(difference(isDefined(AGE,age),2),30)] Age 30 to age {$e:min(39,valueOrDefault("AGE","age",100)) };
[SECSMLF2E,displayif=greaterThan(difference(isDefined(AGE,age),2),40)] Age 40 to age {$e:min(49,valueOrDefault("AGE","age",100)) };
[SECSMLF2F,displayif=greaterThan(difference(isDefined(AGE,age),2),50)] Age 50 to age {$e:min(59,valueOrDefault("AGE","age",100)) };
[SECSMLF2G,displayif=greaterThan(difference(isDefined(AGE,age),2),60)] Age 60 to age {$e:min(69,valueOrDefault("AGE","age",100)) };
[SECSMLF2H,displayif=greaterThanOrEqual(isDefined(AGE,age),70)] Age 70 and older;]|

(0:Every day, at least 2 hours each day)
(1:Every day, less than 2 hours each day)
(2:Most days of the week)
(3:A few days per week)
(4:One day per week)
(5: A few days per month)
(6: One day per month)
(7: few days per year)
(44: Never)|

If we use {"age":"45", "AGE":"56"} in the “Previous Results” box and add JSON to memory, the renderer gives us the expected grid results below, with the age ranges correctly labeled. image1

However, for this code:

[AGECOR!] To start, please tell us a bit about yourself.

Based on the information you provided when you enrolled in this study, you are {$u:age} years old today. Is that correct?
(0) No -> AGE
(1) Yes -> GRID_SECSMLF2

[AGE!] How old are you today?
Age: |__|__|min=40 max=70|

|grid?|id="GRID_SECSMLF2"|Thinking about your usual adult life, about how often were you around the tobacco smoke of others, for example in your home, work, or school?|[ 

[SECSMLF2A] Age 0 to age {$e:min(17,valueOrDefault("AGE","age",100)) };
[SECSMLF2B,displayif=greaterThan(difference(isDefined(AGE,age),2),18)] Age 18 to age {$e:min(24,valueOrDefault("AGE","age",100)) };
[SECSMLF2C,displayif=greaterThan(difference(isDefined(AGE,age),2),25)] Age 25 to age {$e:min(29,valueOrDefault("AGE","age",100)) };
[SECSMLF2D,displayif=greaterThan(difference(isDefined(AGE,age),2),30)] Age 30 to age {$e:min(39,valueOrDefault("AGE","age",100)) };
[SECSMLF2E,displayif=greaterThan(difference(isDefined(AGE,age),2),40)] Age 40 to age {$e:min(49,valueOrDefault("AGE","age",100)) };
[SECSMLF2F,displayif=greaterThan(difference(isDefined(AGE,age),2),50)] Age 50 to age {$e:min(59,valueOrDefault("AGE","age",100)) };
[SECSMLF2G,displayif=greaterThan(difference(isDefined(AGE,age),2),60)] Age 60 to age {$e:min(69,valueOrDefault("AGE","age",100)) };
[SECSMLF2H,displayif=greaterThanOrEqual(isDefined(AGE,age),70)] Age 70 and older;]|

(0:Every day, at least 2 hours each day)
(1:Every day, less than 2 hours each day)
(2:Most days of the week)
(3:A few days per week)
(4:One day per week)
(5: A few days per month)
(6: One day per month)
(7: few days per year)
(44: Never)|

If we use {"age":"45"} in the "Previous Results" box, add JSON to memory, respond "No" to Quest ID "AGECOR", and enter "56" for Quest ID "AGE", the renderer gives us the grid below with mislabeled age ranges for the last 2 rows. image2

danielruss commented 2 years ago

@huip-ims thank you for the nice self contained module. This is a complicated fix. I put in a pull request for @naiyume to double check. If @naiyume doesn't push the fix, I'll pull it in tomorrow.

danielruss commented 2 years ago

@huip-ims code updated...

huip-ims commented 2 years ago

@danielruss @naiyume @boyd-mj Thanks Daniel. It's working as expected in the renderer now. The only issue I'm seeing is that, for each row, it won't allow me to add a space between the text and the upper age number (i.e., "Age 0 to age17").

image

danielruss commented 2 years ago

😦

danielruss commented 2 years ago

Can this be closed @huip-ims @boyd-mj