episphere / quest

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

QuestionType_9 Special Missings rendering/storing not working as expected. #347

Closed Davinkjohnson closed 2 years ago

Davinkjohnson commented 3 years ago

I was just testing a question in the renderer and encountered something unexpected. Previously when you selected a checkbox for a special missing, it would essentially lock you out of the alternative numeric/text field. Now, if you enter a value, then click on the checkbox for the special missing, the value clears. But if you then enter a value again (with the checkbox still checked), it allows you to without clearing the checkbox. When you click next, it appears to clear the checkbox just as you are directed to the next screen, but the special missing is still stored on the backend (along with the numeric value). Here are screenshots of this using MOMAGE:image imageAfter clicking on ‘Don’t Know’, then entering 75, just before clicking ‘Next’

danielruss commented 3 years ago

@iqbal-singh I still seem to have problems with this test module:

Test Module:

[MOMDEATH] At what age did your mother die?

|__|__|__|id=MOM_DEATH_NUM min=5 max=125| Mother’s age

[77*] Don’t Know

[END] Thank you

When you click don't know the value of Mom's age should clear.

FrogGirl1123 commented 3 years ago

We had an additional communication from Jen that a similar issue was occurring with the XOR questions as well. This was from yesterday morning, so I don't know if it's still an issue with the changes made by Iqbal yesterday but I wanted let you know.

FrogGirl1123 commented 3 years ago

@iqbal-singh We are meeting with IMS today at 3pm. Do you have any updates I can share for this issue? Is it ready for them to test again?

iqbal-singh commented 3 years ago

@iqbal-singh We are meeting with IMS today at 3pm. Do you have any updates I can share for this issue? Is it ready for them to test again?

The issue seems to be resolved now based on what I've tested. It's ready for them to test out now to see if they still have the same issue.

boyd-mj commented 3 years ago

Hi all,

We've tested this issue. It appears the data is being stored correctly on the backend, but we're still seeing the unexpected behavior in the renderer. For instance, if you check the checkbox for 'Don't Know' for MOMAGE, and then click in the age field, you can still enter an age while the checkbox remained checked. When you hit next, it now only stores the age, but the user will see both the checked checkbox and the age until just before the screen changes.

Likewise, with the XOR, the user can still enter data in both fields. Only the most recently entered field will be stored, but the user will see both on the screen (see example). xor2

In both cases, the earlier data will be cleared from the screen if you click anywhere on the screen outside of the responses.

Jen

iqbal-singh commented 3 years ago

Hi all,

We've tested this issue. It appears the data is being stored correctly on the backend, but we're still seeing the unexpected behavior in the renderer. For instance, if you check the checkbox for 'Don't Know' for MOMAGE, and then click in the age field, you can still enter an age while the checkbox remained checked. When you hit next, it now only stores the age, but the user will see both the checked checkbox and the age until just before the screen changes.

Likewise, with the XOR, the user can still enter data in both fields. Only the most recently entered field will be stored, but the user will see both on the screen (see example). xor2

In both cases, the earlier data will be cleared from the screen if you click anywhere on the screen outside of the responses.

Jen

Hi Jen, Are you able to provide the markdown for that is being used for that section? Thanks

boyd-mj commented 3 years ago

Hi Iqbal,

This is the code for the XOR question:

[SKINCANC?] <b>Cancer</b>

Has a doctor or other health professional ever told you that you have or had <b>non-melanoma skin cancer</b>?
(1) Yes -> SKINCANC2
(0) No -> MHGROUP1
< #NR -> MHGROUP1 >

[SKINCANC2?] What type(s) of skin cancer did a doctor or other health professional tell you that you have or had? Select all that apply.
[0] Basal cell
[1]Squamous cell
[77*] Don’t know
< #NR -> SKINCANC3 >

[SKINCANC3?] How old were you when a doctor or other health professional <b>first</b> told you that you have or had skin cancer?
|__|__|xor=SKINCANC3 id=SKINCANC3_AGE min=0 max=isDefined(AGE,age)| Age at diagnosis

Or, if it is easier to remember the year, enter that here:
|__|__|__|__|xor=SKINCANC3 id=SKINCANC3_YEAR minval=difference(difference(#currentYear,isDefined(AGE,age)),1) max=#currentYear| Year at diagnosis
< #NR -> MHGROUP1 >

And this is the code for MOMAGE:

[MOM] The next questions ask about your family and if people in your family have had <b>cancer</b>.
< -> MOM1>

[MOM1?] <b>Parents</b>

Is your biological mother still living?
(0) No -> MOMDEATH
(1) Yes -> MOMAGE
(77) Don’t know -> MOMCANC
< #NR -> MOMCANC >

[MOMAGE?] How old is your mother today?
|__|__|__|id=MOM_AGE minval=max(isDefined(AGE,age),5) max=125| Mother’s age
[77*] Don’t know
< -> MOMCANC >

[MOMDEATH?] At what age did your mother die?
|__|__|__|id=MOMDEATH_NUM min=5 max=125| Mother’s age
[77*] Don’t know
< #NR -> MOMCANC >

[MOMCANC?] |displayif=equals(MOM1,1)|Has a doctor or other health professional ever said that your mother has or had any type of <b>cancer</b>?| |displayif=or(equals(MOM1,0),or(equals(MOM1,77),equals(MOM1,undefined)))|Did a doctor or other health professional ever say that your mother had any type of <b>cancer</b>?|
(0) No -> DAD
(1) Yes -> MOMCANC2
(77) Don’t know -> DAD
< #NR -> DAD >
danielruss commented 3 years ago

Some of your skips go to questions that don't exist in your test module. ~I've changed the module and errors now pop up.~. I've change the module and it works as expected. Try this:


[AGE] how old are you?
|__|__|

[SKINCANC?] <b>Cancer</b>

Has a doctor or other health professional ever told you that you have or had <b>non-melanoma skin cancer</b>?
(1) Yes -> SKINCANC2
(0) No -> END
< #NR -> END >

[SKINCANC2?] What type(s) of skin cancer did a doctor or other health professional tell you that you have or had? Select all that apply.
[0] Basal cell
[1]Squamous cell
[77*] Don’t know

[SKINCANC3?] How old were you when a doctor or other health professional <b>first</b> told you that you have or had skin cancer?
|__|__|xor=SKINCANC3 id=SKINCANC3_AGE min=0 max=isDefined(AGE,age)| Age at diagnosis

Or, if it is easier to remember the year, enter that here:
|__|__|__|__|xor=SKINCANC3 id=SKINCANC3_YEAR minval=difference(difference(#currentYear,isDefined(AGE,age)),1) max=#currentYear| Year at diagnosis
< #NR -> END >

[MOM] The next questions ask about your family and if people in your family have had <b>cancer</b>.
< -> MOM1>

[MOM1?] <b>Parents</b>

Is your biological mother still living?
(0) No -> MOMDEATH
(1) Yes -> MOMAGE
(77) Don’t know -> END
< #NR -> END >

[MOMAGE?] How old is your mother today?
|__|__|__|id=MOM_AGE minval=max(isDefined(AGE,age),5) max=125| Mother’s age
[77*] Don’t know
< -> END >

[MOMDEATH?] At what age did your mother die?
|__|__|__|id=MOMDEATH_NUM min=5 max=125| Mother’s age
[77*] Don’t know
< #NR -> END >

[END] End of Test Module
danielruss commented 3 years ago

Ok, the error is related to the fact that AGE or age is not defined, so it is returning "undefined". If you add age (or AGE) to the localforage it works as expected. Edited the module above to work.

FrogGirl1123 commented 2 years ago

@iqbal-singh @Davinkjohnson Let's have IMS or Julie test this before we close it. I think we are still going to have the issue that the extra field doesn't clear unless the background is clicked on before hitting the "next" button, in which case we need to decide if it's high priority.

danielruss commented 2 years ago

@FrogGirl1123 - @iqbal-singh updated the code so that when a user updates the "year" the age clears and vice-versa. Do longer do you have to click outside. If you are happy, please close the issue.

boyd-mj commented 2 years ago

@FrogGirl1123 I've assigned this for testing at IMS

boyd-mj commented 2 years ago

@iqbal-singh @danielruss We encountered a new issue when testing this fix. If a textbox has any kind of warnings or limits, those will trigger the moment you type anything in the box. Generally, this just displays a warning immediately until you finish typing. In the case of stronger warnings though like the one in the screenshot, the box appears with each number you type weight .

danielruss commented 2 years ago

@iqbal-singh When I have a simple XOR case, it no longer works.

[WEIGHT?] How much do you weigh without clothes or shoes on? |displayif=or(equals(SEX,0),equals(SEX,2))|If you are pregnant, how much did you weigh before your pregnancy?|
|__|__|__|min=0 max=999 softedit=true modalif=value<70 modalvalue='Is this weight correct?'| #Pounds (lbs)

[XX] 
a |__|xor="fred" id=a|  or
b |__|xor="fred" id=b|

[END] good bye

even with your PR.

boyd-mj commented 2 years ago

Hi @iqbal-singh and @danielruss - Has there been progress on this issue lately? Please let us know if you'd like us to do any testing.

Thanks, Jen

danielruss commented 2 years ago

@boyd-mj I think this was fixed a while ago. The example I gave to @iqbal-singh works as expected (if weight < 70 show modal). The original issue was with the XOR, and it appears to work fine. Please test and close the issue if it passes.

boyd-mj commented 2 years ago

@danielruss we ran into a similar issue today when testing a change to MENSHIS:

[MENSHIS?] How old were you when you had your first menstrual period? Please make your best guess if you are not sure.

Age |||id=MENSHISA min=0 max=sum(isDefined(AGE,age),1)| [44*] Never -> MENSHIS9 < #NR -> MENSHIS9 >

In this case, we see the behavior again where if you check the box for Never, then enter a number in the field, you see both. I tested this both defining age by asking the question in the markup and by using the previous results field and in both cases it stored both the '44' and the age when I clicked next:

... Response stored in LF: Questionnaire {"MENSHIS":{"MENSHIS":["44"],"MENSHISA":"13"}}

If you enter an age and then click never, it does clear the age and appears to store only the never properly: ... Response stored in LF: Questionnaire {"MENSHIS":{"MENSHIS":["44"]}}

However, if you click never, then enter an age, then click on the background, it clears the never, but the never is still stored: ... Response stored in LF: Questionnaire {"MENSHIS":{"MENSHIS":["44"],"MENSHISA":"13"}} questionnaire.js:787:19

I am not the experienced tester, but I was careful to clear my memory each time. Could you see if your team can repeat this?

Thanks, Jen

danielruss commented 2 years ago

@FrogGirl1123 I would like to make a fix, but I need to know if this "breaks" the logic. For all involved, let's remind everyone of the background...

Once upon a time, a participant fills out a user profile. On this user profile we ask them their age. Then in module 1, we asked them if for some reason under the stress of filling out this user profile, they panicked and got their age wrong ¯_(ツ)_/¯. So we ask them their AGE. We now have two variables (age, AGE) which may hold the user's age.

Now we ask women their age of menarche, and validate it against AGE or age (if AGE does not exist). The validation uses max=function_that_fails(whatever). I am giving the developers a function. valueOrDefault('AGE','age'), which would return AGE or age if AGE does not exist. But what if neither exist? The function currently returns null, which will cause a disaster. I suggest that they use max=valueOrDefault('AGE','age',99) this would return 99 if neither exists. The in-module validation will accept ages older than the participant, but the module will continue.

Is this behavior acceptable? Do the module developer (PI's) prefer crash or poorly validated data.

danielruss commented 2 years ago

While we are on this question, the logic dictates that if the user selects "I have never had a menstrual period" the next question should be about pregnancies. Maybe we should reconsider that logic....

danielruss commented 2 years ago

@boyd-mj the code is ready for testing... try

[MENSHIS?]
How old were you when you had your <b>first</b> menstrual period? Please make your best guess if you are not sure.

Age |__|__|id=MENSHISA min=0 max=valueOrDefault("AGE","age",99)|
[88*] I have never had a menstrual period -> PREG
< #NR -> PREG >
boyd-mj commented 2 years ago

I've passed this along to our tester

guinevere83 commented 2 years ago

I tried that out and it seemed to work correctly.

danielruss commented 2 years ago

@Davinkjohnson ok to close this issue?

boyd-mj commented 2 years ago

While we are on this question, the logic dictates that if the user selects "I have never had a menstrual period" the next question should be about pregnancies. Maybe we should reconsider that logic....

This was reviewed by the content team and they determined that no changes are needed.

boyd-mj commented 2 years ago

@Davinkjohnson ok to close this issue?

I believe @FrogGirl1123 was going to review your post below and confirm before we finalized this.

@FrogGirl1123 I would like to make a fix, but I need to know if this "breaks" the logic. For all involved, let's remind everyone of the background...

Once upon a time, a participant fills out a user profile. On this user profile we ask them their age. Then in module 1, we asked them if for some reason under the stress of filling out this user profile, they panicked and got their age wrong ¯(ツ)/¯. So we ask them their AGE. We now have two variables (age, AGE) which may hold the user's age.

Now we ask women their age of menarche, and validate it against AGE or age (if AGE does not exist). The validation uses max=function_that_fails(whatever). I am giving the developers a function. valueOrDefault('AGE','age'), which would return AGE or age if AGE does not exist. But what if neither exist? The function currently returns null, which will cause a disaster. I suggest that they use max=valueOrDefault('AGE','age',99) this would return 99 if neither exists. The in-module validation will accept ages older than the participant, but the module will continue.

Is this behavior acceptable? Do the module developer (PI's) prefer crash or poorly validated data.

boyd-mj commented 2 years ago

@danielruss @naiyume I am reviving this thread as we are encountering the issue again where if a user checks a checkbox with an asterix, they can still enter a value in the text box field as outlined above and there are some oddities in how the data is stored on the backend. For instance, when testing this:

[HOMEMOVEOUT2?] What year did you move out of address one?
If you still live at this address, select “I still live here.”

Year moved out |__|__|__|__|id=HOMEMOVEOUT2_YEAR|
[0*] I still live here

If you check the checkbox for 'I still live here', then enter a value for year (checkbox remains checked) and click 'Next' you see this: Response stored in LF: Questionnaire {"HOMEMOVEOUT2":{"HOMEMOVEOUT2_YEAR":"2000"}}

Or if you enter 2000, then click the box, the 2000 clears and if you click next the data is stored properly: LF: Questionnaire {"HOMEMOVEOUT2":{"HOMEMOVEOUT2":["0"]}}

But if click instead of clicking next, you reenter the 2000, the checkbox remains checked and when you click next you see this:

LF: Questionnaire {"HOMEMOVEOUT2":{"HOMEMOVEOUT2":["0"],"HOMEMOVEOUT2_YEAR":"2000"}}

At one point an update had been made so that you could not see data in a text field while a special missing text box was also checked, and without having to click outside of the fields, but that is no longer the case.

Thanks, Jen

danielruss commented 2 years ago

@boyd-mj #375 was just opened to address this question.

boyd-mj commented 2 years ago

@danielruss we came across this while testing the issue in that other thread, but this is a different issue pertaining to questions with only one text box and one check box.

danielruss commented 2 years ago

@boyd-mj As I said in #375. This is the desired behavior in quest. You can override this using

[HOMEMOVEOUT2?] What year did you move out of address one?
If you still live at this address, select “I still live here.”

Year moved out |__|__|__|__|id=HOMEMOVEOUT2_YEAR name=HOMEMOVEOUT2|
[0*] I still live here
boyd-mj commented 2 years ago

My understanding was that the desired behavior is to only let the user answer one or the other when the asterix is used. In other words, if they select zero, they shouldn't also be able to enter a year. Admittedly my brain is mush after a long day - are you planning to join our 3 pm call tomorrow? Might be easier to discuss briefly then?

danielruss commented 2 years ago

The desired behavior for quest is that when the user clicks a choice with an asterisk all other checkboxes are cleared, as are text boxes in the labels. We can fake it, by giving the input box the same name. This is how we clear the text boxes in the label.

danielruss commented 2 years ago

switched to #376