Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CARDS-2509: Reference question should support conditions based on sou… #1791

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

acrowthe
Copy link
Contributor

@acrowthe acrowthe commented Jul 18, 2024

…rce form metadata

Add optional condition properties to reference questions:

  • conditionalProperty: A property on the referenced form to be evaluated
  • conditionalOperator: The operator that should be used for the comparison. Supports all operators supported by Conditional Sections
  • conditionalValue: The value that the property should be compared against
  • conditionalFallback: The value that should be saved instead of the referenced value if the condition is not satisfied
  • conditionalType: The type of the property that is being compared

Refactored backend conditional section code in order to reuse conditional evaluation code

Update Reference Test forms to add testing support for new conditional references

  • Added new section with 4 new questions to the bottom of ReferenceTestCopied. These questions are conditional on ReferenceTestUser being completed
  • Made one question in ReferenceTestUser mandatory to allow the form to be edited between incomplete and complete

To test:

  • Verify that form completion status works with mandatory questions in conditional sections as before as the code that updates completion status was adjusted in order to be reusable
  • Verify that the new questions in ReferenceTestCopied show:
    • Fallback values when ReferenceTestUser is incomplete
    • The values from ReferenceTestUser when that form is complete
  • Make sure to test reference answers on brand new forms and on forms that have been edited

…rce form metadata

Add optional condition properties to reference questions:
- conditionalProperty: A property on the referenced form to be evaluated
- conditionalOperator: The operator that should be used for the comparison.
                       Supports all operators supported by Conditional Sections
- conditionalValue: The value that the property should be compared against
- conditionalFallback: The value that should be saved instead of the
                       referenced value if the condition is not satisfied
- conditionalType: The type of the property that is being compared

Refactored backend conditional section code in order to reuse conditional evaluation code

Update Reference Test forms to add testing support for new conditional references
- Added new section with 4 new questions to the bottom of ReferenceTestCopied.
  These questions are conditional on ReferenceTestUser being completed
- Made one question in ReferenceTestUser mandatory to allow the form to be edited
  between incomplete and complete
@marta- marta- added the Test me! Ready for testing label Jul 18, 2024
@sashaandjic sashaandjic added the testing... Testing in progress label Jul 18, 2024
…rce form metadata

Add optional error message when a conditional reference is not satisfied
- Allows non-text questions to have a text based error display
…rce form metadata

- Add invalid source flag to reference questions with no source
@@ -50,6 +50,9 @@ public interface FormUtils
/** The name of the property of a Form node that links to other Subjects the form relates to. */
String RELATED_SUBJECTS_PROPERTY = "relatedSubjects";

/** The name of a property on an Answer, Section or Form node that holds the status flags for that node.*/
String STATUS_FLAGS = "statusFlags";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String STATUS_FLAGS = "statusFlags";
String STATUS_FLAGS_PROPERTY = "statusFlags";

/** Answer's property name. **/
public static final String VALUE = "value";
/** Property on an answer node that stores the a reference to the question. */
public static final String QUESTION = "question";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also FormUtils.QUESTION_PROPERTY

Comment on lines 218 to 226
/**
* Fill out a refernce answer with a value copied from the referenced question.
* @param versionManager A version manager to be used to checkout forms if needed
* @param checkoutPaths The list of forms that have been checkout out and need to be checked back in
* @param sourceAnswerValue The source answer value to copy the answer from
* @param referenceAnswer The reference answer to copy the value into
* @param sourceNode The source answer node that the value is being copied from
* @throws RepositoryException if an unexpected error occurs
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dangling comment?

*/

/**
* Fill out a refernce answer with the value specified as the fallback value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Fill out a refernce answer with the value specified as the fallback value.
* Fill out a reference answer with the value specified as the fallback value.

@@ -191,31 +187,234 @@ private void checkAndUpdateAnswersValues(final NodeIterator nodeIterator, final
}
}

private boolean isNotSame(final Property source, final Node reference) throws RepositoryException
/**
* Fill out a refernce answer with a value copied from the referenced question.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Fill out a refernce answer with a value copied from the referenced question.
* Fill out a reference answer with a value copied from the referenced question.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to remove things from cards-utils, not add more things to it, so I'd like to see this moved into its own module, conditions.

}
}
super(values);
this.reference = reference;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be part of the default Operand?

marta- and others added 2 commits July 25, 2024 12:21
…rce form metadata

- Updated the import script to support conditional properties of reference questions
…rce form metadata

- Clean up unused javadoc
- Add missing conditional reference columns to questionnaire import
- Add missing null checks
@sashaandjic sashaandjic added bug Something isn't working and removed Test me! Ready for testing testing... Testing in progress labels Sep 20, 2024
@sashaandjic
Copy link
Contributor

sashaandjic commented Sep 20, 2024

Steps to reproduce:

  • create Reference Test - User Answers form - fill in all fields ( I used text one, text one in section, 11, 11.11)
  • create another Reference Test - User Answers form - fill in all fields ( I used text two, text two in section, 22, 22.22)
  • create Reference Test - Copied Answers --> observe --> the form has values from the first form and everything looks good
  • go back to the first Reference Test - User Answers form and remove all values entered except in the Text question field
  • open Reference Test - User Answers form --> observe --> everything looks good
  • create another Reference Test - User Answers form - fill in all fields ( I used text three, text three in section, 33, 33.33)
  • open Reference Test - User Answers form --> observe --> the form has values from the first and the last form
    testRes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants