docassemble
                                
                                
                                
                                    docassemble copied to clipboard
                            
                            
                            
                        Ordering of Optional questions
Hi,
I am fairly new to docassemble and I have been trying to work out a way ask some questions which are deemed optional in a decision tree kind of manner.
Say I ask Question A. If the user answers Yes, it will proceed to ask Question B. If the user again answers Yes, it then asks Question C before it goes on to ask Question D. If Question A gets a No, it will just skip B and C for D. If B gets a No, it will then skip to D.
Is there a way to do this in docassemble? I tried events but events are only for giving an end and not for asking questions. I have looked through the interview logic repeatedly but it's not quite clear how I should try to approach this. Or are the alternatives like deactivating questions. Thanks in advance.
See: https://suffolklitlab.org/legal-tech-class/docs/practical-guide-docassemble/controlling-interview-order
and https://suffolklitlab.org/legal-tech-class/docs/classes/assignment-branch-logic
Have you managed to do this?
I have this 2 questions
mandatory: True question: | Was there risk of contagium at entry and exit points? yesno: risk_entrance
question: | What was the level of the risk? field: risk_level_entrance choices:
- High: High
 - Medium: Medium
 - Low: Low
 
and then have this code block
mandatory: True code: |
if risk_entrance: if risk_level_entrance=="High" or risk_level_entrance=="Medium": ... else: ...
but this always ask the question even tho risk_entrance is false
There might be a reference to risk_level_entrance elsewhere in your interview.  When the interview asks for risk_level_entrance, you can click the Source tab and look at "how this question was asked," which will show you the thought process leading up to the asking of the question.  I assume that some question, code block, or document needed to know the value of  risk_level_entrance.
This example works correctly for me:
question: |
  Was there risk of contagium at entry and exit points?
yesno: risk_entrance
---
question: |
  What was the level of the risk?
field: risk_level_entrance
choices:
  - High: High
  - Medium: Medium
  - Low: Low
---
mandatory: True
code: |
  if risk_entrance:
    if risk_level_entrance=="High" or risk_level_entrance=="Medium":
      answer = "high or medium"
    else:
      answer = "low"
  else:
    answer = "no risk"
---
mandatory: True
question: |
  The answer is ${ answer }
                                    
                                    
                                    
                                
I am closing this issue because there has been no activity, but feel free to reopen if you have further questions.