Forum Discussion

anoyatis's avatar
anoyatis
Community Member
13 years ago

Multiple AND and OR conditions in the same trigger

I've run into a scenario when I am implementing a "show layer X" trigger 5 times (with different conditions), when I really should be just using one trigger (with all conditions combined). How does storyline evaluate a trigger with conditions that include both AND and OR statements?

For example :

29 Replies

  • RajuMN's avatar
    RajuMN
    Community Member

    Dear friends,

    few of my friends are discussing how make test more interesting,

    like

    getting limited questions from question bank each time:

    for example if we have 50 questions in question bank each time( attempt ) can we get 20 different question ?

  • RajuMN's avatar
    RajuMN
    Community Member

    hi 

    got the answer,

    i got it with include options.

    thanks for baring me

    • MattOckenfels-c's avatar
      MattOckenfels-c
      Community Member

      Seven years later and I have come up with this issue.  Thanks for this tester.

      I started by modifying the results display:

       

      Note the AND groupings. I worked through different scenarios and the logic seems correct.

      Additionally, the current formatting of the trigger conditions lead to this conclusion:

      The ANDs are indented, leading me to believe they are evaluated before the ORs.

      Can any of our hard-working Articulate reps confirm I am on the right track? Thanks!

      • Nedim's avatar
        Nedim
        Community Member

        Let's put it this way: in JavaScript, where && represents AND and || represents OR, the evaluation would follow these rules:

        Trigger 1:
        let result = (var1 && var2) || (var3 && var4);

        • If both var1 and var2 are true, result will be true.
        • If both var3 and var4 are true, result will also be true.
        • If neither of these conditions is satisfied, result will be false.


        Trigger 2:
        let result = (var1 && var2) || var3 || var4;

        • If both var1 and var2 are true, result will be true.
        • If either var3 or var4 is true, result will also be true.
        • If none of these conditions is satisfied, result will be false.


        Trigger 3:
        let result = var1 || (var2 && var3) || var4;

        • If var1 is true, result will be true.
        • If both var2 and var3 are true, result will be true.
        • If var4 is true, result will be true.
        • If none of these conditions are met, result will be false.


        Needless to say, when both && and || operators are used in an expression/trigger, the AND operator will be evaluated first. I'd say your logic seems correct, but I’d suggest breaking it down the JavaScript way, especially when the conditions in the trigger become complex with too many mixed OR and AND statements.

  • Hello,

    I am trying to use the trigger to do this action:

    When a user click on the policy button they can move to the next slide, if they do not click the policy button they get a popup saying" Please make sure to ready the policy" and they will not be able to move to the next page without clicking that policy button.

     

  • You will need two triggers:

    Jump to next slide when learner clicks on Policy button.

    Show layer "Please Read Policy First Popup" when timeline ends on this slide.

    FYI, this seems to me like a strange request. Are you sure you don't need to refine the definition of your question a bit more?