Closed joshid-ims closed 1 year ago
Can you give me a small self contained example of equals/notEquals failing?
In the following question, we had equals and doesNotEqual instead of doesNotExist and exists. That gave error.
[DRINKSWTR2F?,displayif=equals(DRINKSWTR1,55)] In a usual week, about how often do you use tap water from your home to make |displayif=exists("DRINKSWTR1_OTH")|{$DRINKSWTR1_OTH}||displayif=doesNotExist("DRINKSWTR1_OTH")|other beverages|? We are interested in all tap water, whether or not it has been filtered or treated. (0) times per day |||id=DRINKSWTR2F_NUM min=0 max=999| (1) 5 to 6 times per week (2) 3 to 4 times per week (3) 1 to 2 times per week (4) Less than once per week (5) I drink tap water in |displayif=exists("DRINKSWTR1_OTH")|{$DRINKSWTR1_OTH}||displayif=doesNotExist("DRINKSWTR1_OTH")|other beverages| but don’t know how often.
Can you also give me a SCCCE for this question also. It needs a few other questions, or remove the references to them, please.
[DRINKSWTR1?] In a usual week, which of these beverages do you make with tap water from your home? We are interested in all tap water, whether or not it has been filtered or treated. Select all that apply. [0] A cup of coffee [1] A cup of hot tea [2] A glass of iced tea [3] Any other beverage or soup made with your tap water (such as fruit juice made from concentrate and beverages made from powder) [55] Other: Please describe |__|id=DRINKSWTR1_OTH|
[DRINKSWTR2F?] In a usual week, about how often do you use tap water from your home to make |displayif=doesNotEqual(DRINKSWTR1_OTH,"")|{$DRINKSWTR1_OTH}||displayif=equals(DRINKSWTR1_OTH,"")|other beverages|? We are interested in all tap water, whether or not it has been filtered or treated. (0) times per day |||id=DRINKSWTR2F_NUM min=0 max=999| (1) 5 to 6 times per week (2) 3 to 4 times per week (3) 1 to 2 times per week (4) Less than once per week (5) I drink tap water in |displayif=doesNotEqual(DRINKSWTR1_OTH,"")|{$DRINKSWTR1_OTH}||displayif=equals(DRINKSWTR1_OTH,"")|other beverages| but don’t know how often.
[END] end
This renders like: (does not display "other beverages"
@joshid-ims. NEW SYNTAX You can now use:
{# valueOrDefault("DRINKSWTR1_OTH","other beverages") }
The functions work just like in the display if case. I changed your code to:
[DRINKSWTR1?] In a <b>usual week</b>, which of these beverages do you make with tap water from your home? We are interested in all tap water, whether or not it has been filtered or treated. Select all that apply.
[0] A cup of coffee
[1] A cup of hot tea
[2] A glass of iced tea
[3] Any other beverage or soup made with your tap water (such as fruit juice made from concentrate and beverages made from powder)
[55] Other: Please describe |__|id=DRINKSWTR1_OTH|
[DRINKSWTR2F?] In a <b>usual week</b>, about how often do you use tap water from your home to make <b>{#valueOrDefault("DRINKSWTR1_OTH","other beverages")}</b>? We are interested in all tap water, whether or not it has been filtered or treated.
(0) times per day |__|__|id=DRINKSWTR2F_NUM min=0 max=999|
(1) 5 to 6 times per week
(2) 3 to 4 times per week
(3) 1 to 2 times per week
(4) Less than once per week
(5) I drink tap water in <b>{#valueOrDefault("DRINKSWTR1_OTH","other beverages")}</b> but don’t know how often.
I think this will simplify many displayif use cases. Let me know if this works for you...
I have used exists and doesNotExist and it is working. But I will keep this in mind. Thanks!
While making a content change in https://github.com/episphere/questionnaire/issues/216, we found an issue while testing that the Other text box value was not getting inserted. It was resolved by replacing equals and doesNotEqual by doesNotExist and exists. It was working before. Since those equals and doesNotEqual were working before I am wondering if they do not work now and should be replaced in all places?