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

Multiple conditions in triggers and trigger on a question #60

Closed
andrewtelnov opened this issue Aug 25, 2016 · 8 comments
Closed

Multiple conditions in triggers and trigger on a question #60

andrewtelnov opened this issue Aug 25, 2016 · 8 comments
Labels

Comments

@andrewtelnov
Copy link
Member

andrewtelnov commented Aug 25, 2016

It is time to re-work the current trigger mechanism in the library. There are several limitation at the current moment.
At first, there is no way to have a complex condition in the trigger. You may check only one question value.
At second, sometimes, it is more convenient to have the visible trigger on the question/page level: make the question/page visible if: [Boolean expression].

The following tasks has to be implemented:

  1. Create a Boolean Expression parser to convert the expression into “Boolean” Graph/Tree. Example of expression: {age} >= 21 and ({smoke} == ‘no’ or {beerlover} == ‘no’)
  2. Implement a runner. It will run through this “Boolean” tree, using the question values as variables to get the Boolean result (true or false).
  3. Replace the current “name”, “operator” and “value” attributes with a string “condition” attribute, for example name: “age”, operator: “greaterorequal”, value: “21” will become, condition: “{age} >= 21”. Make sure, the old attributes will continue to work (convert them on the fly).
  4. Create a new attribute in a question “visibleIf” with the type of the boolean expression (string).
  5. Create a visual editor for editing Boolean Expression.
@andrewtelnov
Copy link
Member Author

visibleIf: string attribute into page and question objects is added.
The functional can be tested now. I am starting to work on visual editor.

@ItsJoeTurner
Copy link

ItsJoeTurner commented Sep 20, 2016

How can I test this function? This is pretty key for me using this. Great stuff btw.

@andrewtelnov
Copy link
Member Author

I do not publish a new version yet. However, you may follow the instruction (readme.cmd) and build the library from sources. You will have a new property: visibleIf.

andrewtelnov added a commit that referenced this issue Sep 23, 2016
@andrewtelnov
Copy link
Member Author

I am using {youquestionName} for question names in expressions.

@thegovind
Copy link

@andrewtelnov So I'm guessing this is incomplete?:

Create a Boolean Expression parser to convert the expression into “Boolean” Graph/Tree. Example of expression: {age} >= 21 and ({smoke} == ‘no’ or {beerlover} == ‘no’)

@andrewtelnov
Copy link
Member Author

andrewtelnov commented Feb 23, 2017

@git2g Sorry, I did not get the question :-(
{age} >= 21 and ({smoke} == ‘no’ or {beerlover} == ‘no’)
The tree is:

and

  1. {age} >= 21
  2. or
    2.1) {smoke} == ‘no’
    2.2) {beerlover} == ‘no’

It looks fine to me.

@varunkumar
Copy link

It would be great to have this expression parser for setValue trigger as well.

@andrewtelnov
Copy link
Member Author

andrewtelnov commented Aug 10, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants