episphere / quest

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

Problem with two text box Question #410

Closed danielruss closed 2 years ago

danielruss commented 2 years ago

@huip-ims had an issue with COVID question in loop with 2 two text boxes, which was the subject of a prior closed issue #393.

I created a test module that contains the question exactly as in the module.

[S] Test module for issue 393

[SRVBLU_COV2_V1R0?] How many times have you had COVID-19?

|__|__| min=1| Times
<loop max=25>
[SRVBLU_COV3_V1R0!,displayif=greaterThanOrEqual(SRVBLU_COV2_V1R0,#loop)] When was the <b>{##}</b> time that you had COVID-19? If you are not sure, please make your best guess.

Month |__|__|id=SRVBLU_COV3_MONTH_V1R0 required min=1 max=12|
Year |__|__|__|__|id=SRVBLU_COV3_YEAR_V1R0 required min=2020 max=#currentYear|
// Month and Year drop down lists are not currently supported
</loop>

[END] that the end

This module works for me. @huip-ims does this work for you?

huip-ims commented 2 years ago

@guinevere83 @danielruss Daniel - this test module does not work in the renderer.

  1. It's allowing you to proceed if 1 of the 2 text boxes is filled in, when both are required.
  2. It looks like it's storing the Month and Year responses incorrectly.

image

danielruss commented 2 years ago

@huip-ims Thank you for the update. I see the problem. My module does not exercise the bug. But this one does. The Id is somehow getting "required" stuck in it. Let me track down who is writing it and get back to you.

[S] Test module for issue 410

[SRVBLU_COV2_V1R0?] How many times have you had COVID-19?

|__|__| min=1| Times
<loop max=25>
[SRVBLU_COV3_V1R0!,displayif=greaterThanOrEqual(SRVBLU_COV2_V1R0,#loop)] When was the <b>{##}</b> time that you had COVID-19? If you are not sure, please make your best guess.

Month |__|__|id=SRVBLU_COV3_MONTH_V1R0 required min=1 max=12|
Year |__|__|__|__|id=SRVBLU_COV3_YEAR_V1R0 required min=2020 max=#currentYear|
// Month and Year drop down lists are not currently supported

[SRVBLU_COV22_V1R0?] How long did it take you to recover to your usual state of health from the date you first realized you had COVID-19?

Months |__|__|id=SRVBLU_COV22_MONTHS_V1R0 min=0 max=(#currentYear - _value("SRVBLU_COV3_YEAR_V1R0_1"))*12 + (#currentMonth - _value("SRVBLU_COV3_MONTH_V1R0_1"))|
Days |__|__|__|id=SRVBLU_COV22_DAYS_V1R0 min=1 max=365|

</loop>

[END] that the end
danielruss commented 2 years ago

@huip-ims There are two problems related to changes that we made.

  1. Because min/max are allowed to have spaces and quotes, we allowed the arguments to be more flexible. This causes problems with single word arguments like "required". Notice in question SRVBLU_COV3_V1R0 each input element has a "required" argument. Please use required=true. Yes, this is new.
  2. In question SRVBLU_COV22_V1R0, for months, you are looking at the value of SRVBLU_COV3_YEAR_V1R0_1. The code looks for ID for the loop and appends "_n" to ID. So you are looking for a variable "SRVBLU_COV3_YEAR_V1R0_1_n" which does not exist. Use SRVBLU_COV3_YEAR_V1R0 instead. If you want the value of the FIRST iteration of the loop, that is not currently available. We can discuss it later.
huip-ims commented 2 years ago

@danielruss Daniel - Question SRVBLU_COV22_V1R0 is asked after the loop has finished. Wouldn't both SRVBLU_COV3_MONTH_V1R0_1 & SRVBLU_COV3_YEAR_V1R0_1 exist then. COV22 worked before when we tested the code back in early May.

danielruss commented 2 years ago

@huip-ims Sorry, you are correct. The question is out of the loop, so the name wont get mangled and using SRVBLU_COV3_YEAR_V1R0_1 is valid. However, still change the code to use required=true

please let me know if that fixes your issue.