episphere / quest

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

How to implement ELSE in 'IF - THEN - ELSE' #407

Closed joshid-ims closed 2 years ago

joshid-ims commented 2 years ago

Currently, we can specify the skips based on variable values and go to certain questions. But if there is an ELSE condition, that is like skipping a bunch of questions that are asked after this question, then there is no easy way to implement that. We need help with that.

Like,

Display Q1 if A= 1 or 0 OR B= 1 OR C = 1 or 0 (then Q2,3,4 will be displayed.) else go to Q5. Q5 will be displayed for all values of A, B, C.

danielruss commented 2 years ago

looking into it .. one sec

danielruss commented 2 years ago

Does this answer your question?


[A] <b>Question A:</b> Select 0, 1, or 2.
(0) 0
(1) 1
(2) 2

[B] <b>Question B:</b> Select 0, 1, or 2.
(0) 0
(1) 1
(2) 2

[C] <b>Question C:</b> Select 0, 1, or 2.
(0) 0
(1) 1
(2) 2

[Q1,displayif=valueIsOneOf("A",0,1) or valueIsOneOf("B",0,1) or valueIsOneOf("C",0,1)]
  This Question &lpar;Q1&rpar; should be displayed if A is 0 or 1, or B is O,1 or c is 0,1

[Q2,displayif=valueIsOneOf("A",0,1) or valueIsOneOf("B",0,1) or valueIsOneOf("C",0,1)]
  This Question &lpar;Q2&rpar; should be displayed if A is 0 or 1, or B is O,1 or c is 0,1

[Q3,displayif=valueIsOneOf("A",0,1) or valueIsOneOf("B",0,1) or valueIsOneOf("C",0,1)]
  This Question &lpar;Q3&rpar; should be displayed if A is 0 or 1, or B is O,1 or c is 0,1

[Q4,displayif=valueIsOneOf("A",0,1) or valueIsOneOf("B",0,1) or valueIsOneOf("C",0,1)]
  This Question &lpar;Q4&rpar; should be displayed if A is 0 or 1, or B is O,1 or c is 0,1

[Q5] Welcome to question 5!

[END] All finished.
danielruss commented 2 years ago

you cannot jump directly to Q5. I would like to add a feature like this, but only if I can get rid of displayif...

danielruss commented 2 years ago

updated example

huip-ims commented 2 years ago

@danielruss Daniel - can you give us a skip example without the use of displayif? I don't think we necessarily have to use displayif, just some IF-THEN code that can make skipping questions more efficiently.

danielruss commented 2 years ago

@huip-ims do you need to ask questions B and c if A does not equal 0 or 1? The skip logic only works with the current question. There is only (1) yes -> ID, there is no (1) yes (if -> ID)

huip-ims commented 2 years ago

@danielruss @joshid-ims Daniel - Questions A, B, and C are all independent questions that have already been asked. Suppose there 25 questions Q1-Q25 following A, B, and C where [Q1] is only asked if A= 1 or 0 OR B= 1 or 0 OR C = 1 or 0. Otherwise, we want to skip straight to Q25. Currently, we are doing what have you in your example code by using displayif statements for Q1-Q24. We are wondering if there is a way to add a feature that can help us make skipping questions more efficiently without having to add displayif statements on all the questions we want to skip. What we have in the Biospecimen survey is that A, B, and C are all inside of a loop that can be asked up to 25 times, so these displayif statements are really long. In addition, there are other skips between Q2-Q24 that's making these displayif statements long and complicated. Let us know if you think we should have a call to discuss this further.

danielruss commented 2 years ago

This is not a currently a feature. I see why it would be useful to skip a section. As I said yesterday we would need some kind of state-based transition so in question C would look like:

(1) yes 
(0) no
< if (STATE) -> Q25 >

We need to think about this.

FrogGirl1123 commented 2 years ago

Hi @danielruss , we are trying to complete delivery of the modules for final testing and launch. As our testing window is diminishing (we'll only have Monday and Tuesday next week), we need all modules as functional as possible by COB Friday. What is the status of this fix, if the STATE is too difficult to implement in the time available are alternative markups for functions already in place that could be used instead.

danielruss commented 2 years ago

@FrogGirl1123 I gave a workaround earlier. This issue was that @huip-ims wanted a solution that does not involve displayif. After thinking about that problem I come to the conclusion that the developers struggle with < -> QID > vs. < #NR -> QID >, where QID is the question id; I didn't think it wise to make it more complicated by add < (STATE) -> QID >. I probably should have closed the issue.

This would also be difficult to implement, because I cannot think of an easy way for the developers to implement (STATE). As evident from my initial debacle that led to what I refer to as the tower of or where you have questions with displayif=or(or(or(or(or(or(or..., dealing with STATE is not trivial and would not be completed by COB FRIDAY (AKA tomorrow).

My vote would be to add this as a low priority feature for future development. Low priority because it is a optimization and does not address a core requirement of the application. Please let me know if you feel differently.

@naiyume do you have an opinion on this? Keep in mind that you cannot use a simple regex to find and replace the (STATE)->QID pattern.

danielruss commented 2 years ago

So this is the problematic logic?

SRVBLU_COV23_V1R0,displayif=and(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(equals(SRVBLU_COV1_V1R0,0),equals(SRVBLU_COV1_V1R0,77)),equals(SRVBLU_COV5_V1R0_1_1,0)),equals(SRVBLU_COV6_V1R0_1_1,0)),equals(SRVBLU_COV5_V1R0_2_2,0)),equals(SRVBLU_COV6_V1R0_2_2,0)),equals(SRVBLU_COV5_V1R0_3_3,0)),equals(SRVBLU_COV6_V1R0_3_3,0)),equals(SRVBLU_COV5_V1R0_4_4,0)),equals(SRVBLU_COV6_V1R0_4_4,0)),equals(SRVBLU_COV5_V1R0_5_5,0)),equals(SRVBLU_COV6_V1R0_5_5,0)),equals(SRVBLU_COV5_V1R0_6_6,0)),equals(SRVBLU_COV6_V1R0_6_6,0)),equals(SRVBLU_COV5_V1R0_7_7,0)),equals(SRVBLU_COV6_V1R0_7_7,0)),equals(SRVBLU_COV5_V1R0_8_8,0)),equals(SRVBLU_COV6_V1R0_8_8,0)),equals(SRVBLU_COV5_V1R0_9_9,0)),equals(SRVBLU_COV6_V1R0_9_9,0)),equals(SRVBLU_COV5_V1R0_10_10,0)),equals(SRVBLU_COV6_V1R0_10_10,0)),equals(SRVBLU_COV5_V1R0_11_11,0)),equals(SRVBLU_COV6_V1R0_11_11,0)),equals(SRVBLU_COV5_V1R0_12_12,0)),equals(SRVBLU_COV6_V1R0_12_12,0)),equals(SRVBLU_COV5_V1R0_13_13,0)),equals(SRVBLU_COV6_V1R0_13_13,0)),equals(SRVBLU_COV5_V1R0_14_14,0)),equals(SRVBLU_COV6_V1R0_14_14,0)),equals(SRVBLU_COV5_V1R0_15_15,0)),equals(SRVBLU_COV6_V1R0_15_15,0)),equals(SRVBLU_COV5_V1R0_16_16,0)),equals(SRVBLU_COV6_V1R0_16_16,0)),equals(SRVBLU_COV5_V1R0_17_17,0)),equals(SRVBLU_COV6_V1R0_17_17,0)),equals(SRVBLU_COV5_V1R0_18_18,0)),equals(SRVBLU_COV6_V1R0_18_18,0)),equals(SRVBLU_COV5_V1R0_19_19,0)),equals(SRVBLU_COV6_V1R0_19_19,0)),equals(SRVBLU_COV5_V1R0_20_20,0)),equals(SRVBLU_COV6_V1R0_20_20,0)),equals(SRVBLU_COV5_V1R0_21_21,0)),equals(SRVBLU_COV6_V1R0_21_21,0)),equals(SRVBLU_COV5_V1R0_22_22,0)),equals(SRVBLU_COV6_V1R0_22_22,0)),equals(SRVBLU_COV5_V1R0_23_23,0)),equals(SRVBLU_COV6_V1R0_23_23,0)),equals(SRVBLU_COV5_V1R0_24_24,0)),equals(SRVBLU_COV6_V1R0_24_24,0)),equals(SRVBLU_COV5_V1R0_25_25,0)),equals(SRVBLU_COV6_V1R0_25_25,0)),equals(SRVBLU_COV19C6A_V1R0,1))

{sarcasm:cant see why it's troublesome }

This is what I meant by the tower of or. Also, Connect happily chose to create a grid in a loop.
{sarcasm: glad they didn't chose anything complicated}

joshid-ims commented 2 years ago

Daniel,

This logic is ok but it does not work for the ELSE condition to go to COV25 question directly.

Can you please take a look at questions COV19 to COV25 (and displayif for COV20A) for displayif conditions and suggest a way to code it?

We, me and Pete, can hop on a call if you want to talk about this.

Thanks, Deepti

From: danielruss @.> Sent: Thursday, June 2, 2022 1:55 PM To: episphere/quest @.> Cc: Joshi, Deepti (IMS) @.>; Mention @.> Subject: Re: [episphere/quest] How to implement ELSE in 'IF - THEN - ELSE' (Issue #407)

So this is the problematic logic?

SRVBLU_COV23_V1R0,displayif=and(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(or(equals(SRVBLU_COV1_V1R0,0),equals(SRVBLU_COV1_V1R0,77)),equals(SRVBLU_COV5_V1R0_1_1,0)),equals(SRVBLU_COV6_V1R0_1_1,0)),equals(SRVBLU_COV5_V1R0_2_2,0)),equals(SRVBLU_COV6_V1R0_2_2,0)),equals(SRVBLU_COV5_V1R0_3_3,0)),equals(SRVBLU_COV6_V1R0_3_3,0)),equals(SRVBLU_COV5_V1R0_4_4,0)),equals(SRVBLU_COV6_V1R0_4_4,0)),equals(SRVBLU_COV5_V1R0_5_5,0)),equals(SRVBLU_COV6_V1R0_5_5,0)),equals(SRVBLU_COV5_V1R0_6_6,0)),equals(SRVBLU_COV6_V1R0_6_6,0)),equals(SRVBLU_COV5_V1R0_7_7,0)),equals(SRVBLU_COV6_V1R0_7_7,0)),equals(SRVBLU_COV5_V1R0_8_8,0)),equals(SRVBLU_COV6_V1R0_8_8,0)),equals(SRVBLU_COV5_V1R0_9_9,0)),equals(SRVBLU_COV6_V1R0_9_9,0)),equals(SRVBLU_COV5_V1R0_10_10,0)),equals(SRVBLU_COV6_V1R0_10_10,0)),equals(SRVBLU_COV5_V1R0_11_11,0)),equals(SRVBLU_COV6_V1R0_11_11,0)),equals(SRVBLU_COV5_V1R0_12_12,0)),equals(SRVBLU_COV6_V1R0_12_12,0)),equals(SRVBLU_COV5_V1R0_13_13,0)),equals(SRVBLU_COV6_V1R0_13_13,0)),equals(SRVBLU_COV5_V1R0_14_14,0)),equals(SRVBLU_COV6_V1R0_14_14,0)),equals(SRVBLU_COV5_V1R0_15_15,0)),equals(SRVBLU_COV6_V1R0_15_15,0)),equals(SRVBLU_COV5_V1R0_16_16,0)),equals(SRVBLU_COV6_V1R0_16_16,0)),equals(SRVBLU_COV5_V1R0_17_17,0)),equals(SRVBLU_COV6_V1R0_17_17,0)),equals(SRVBLU_COV5_V1R0_18_18,0)),equals(SRVBLU_COV6_V1R0_18_18,0)),equals(SRVBLU_COV5_V1R0_19_19,0)),equals(SRVBLU_COV6_V1R0_19_19,0)),equals(SRVBLU_COV5_V1R0_20_20,0)),equals(SRVBLU_COV6_V1R0_20_20,0)),equals(SRVBLU_COV5_V1R0_21_21,0)),equals(SRVBLU_COV6_V1R0_21_21,0)),equals(SRVBLU_COV5_V1R0_22_22,0)),equals(SRVBLU_COV6_V1R0_22_22,0)),equals(SRVBLU_COV5_V1R0_23_23,0)),equals(SRVBLU_COV6_V1R0_23_23,0)),equals(SRVBLU_COV5_V1R0_24_24,0)),equals(SRVBLU_COV6_V1R0_24_24,0)),equals(SRVBLU_COV5_V1R0_25_25,0)),equals(SRVBLU_COV6_V1R0_25_25,0)),equals(SRVBLU_COV19C6A_V1R0,1))

cant see why it's troublesome

— Reply to this email directly, view it on GitHubhttps://github.com/episphere/quest/issues/407#issuecomment-1145150562, or unsubscribehttps://github.com/notifications/unsubscribe-auth/APPZ44YCNWNZDNFJ74HRR3TVNDYQDANCNFSM5WZ4N6UA. You are receiving this because you were mentioned.Message ID: @.***>


Information in this e-mail may be confidential. It is intended only for the addressee(s) identified above. If you are not the addressee(s), or an employee or agent of the addressee(s), please note that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender of the error.

danielruss commented 2 years ago

@huip-ims @joshid-ims @boyd-mj We fixed the more complex skip-pattern...

[Q1] Pick a number number greater than 4
|__|__|

[Q2] Hi there.  Pick two...
(1) one
(2) two
< |if=_value("Q1") > 4 and _value("Q2")==2| -> Q4>

[Q3] REALLY !!! You chose either 1 or a value <=4 

[Q4] you should see this.

[END] good bye....

see question Q2 Notice that the value of Q1 must be greater than 4 and Q2 must equal 2..

danielruss commented 2 years ago

@joshid-ims @FrogGirl1123 Can this be closed?