Previous/Next
Create options tutorial/Term logic tutorial
Overview
Boolean Logic (bo͞ol´ēən lä´jik) - Named after the nineteenth-century mathematician George Boole.
Boolean logic is a form of algebra in which all values are reduced to either "TRUE" or "FALSE."
It is especially important for computer science because it is easily evaluated in binary, where each bit has a value of either '1' or '0.' For both Boolean and binary, a value of '1' is 'TRUE', and a value of '0' is 'FALSE.'
IntelliSurvey's survey programming language (SPL) expressions are formed either by evaluating questions with checked functions or by using operators. Earlier in the question and table tutorials, the Discussion Details sections covered variable creation, variable naming, and data storage conventions. We covered various question types, and how data is stored differently for each type. Understanding these fundamental concepts will help you create logic in our SPL.
Some standard rules apply to writing IntelliSurvey logic:
- When referencing questions, use a '$Q' before the question ID.
- The '$' symbol is used to indicate a question reference in logical statements.
- The system automatically prepends a leading 'Q' to variable names by default.
- The questions must be referenced in all caps, regardless of how they are defined. For this reason, we recommend using all caps for variable naming.
- Methods are mainly used to create logic for closed-ended questions (radio, checkbox ,etc.).
- Operators are mainly used to create logic for open-ended questions (text, numbers).
Although leading Q's are added to all questions by the system, it is possible to globally turn off leading Q's via the set defaults
widget.
Survey logic is used in many places, for many reasons. Use it to funnel options, add branching and skips, write custom validations, create selection priorities, create termination logic, and other criteria.
Related reading and resources
The following articles can be used for reference with this training module:
Question Skips and Validation video
The following video provides a brief overview of how we reference variables (questions and tables) within our SPL to create logical statements, focusing on conditions and the anyChecked
function.
Overview of logical expressions
Expressions |
Conjunction Operators |
Open-ended Logic For open-ended questions, IntelliSurvey uses standard math operators to evaluate questions. Text operators: eq, lt, ge, ne, etc... If the expression is for text open ends, use text comparison operators ('eq', 'lt', 'ge', 'ne'). At times you will need to use single or double quotes to compare strings. Note: If your close-ended questions have option IDs with letters, or other non-numeric characters, you may need single or double quotes within the checked function syntax. For example, you would use Numeric operators: ==, <, >=, !=, etc... If the expression is for numeric open ends, use numeric comparison operators ('==', '<', '<=', '!='). Single choice close-ended questions can use these same numeric comparison operators. Review comparison Operators for more information. |
The AND/OR conjunction operators are used to evaluate multiple logical expressions. Assuming you are comparing two expressions, then this is how the operators work: Assuming you are comparing three expressions, then this is how the operators work: When using mixed operators, you'll need to consider order of operations. Just like any form of algebra, IntelliSurvey uses parenthesis to denote order of execution. If (exp1 OR exp2) AND exp3 – Returns a value of '1' if either, or both, of the first two expressions are TRUE, AND the last expression must also be TRUE. If either side of the AND operator returns FALSE, the whole statement is FALSE. When using the AND operator, both sides of the expression must be TRUE. If exp1 OR (exp2 AND exp3) – Returns a value of '1' if the first expression is TRUE, OR both the second AND third expression are TRUE. If either side of the OR operator returns TRUE, the whole statement is TRUE. When using the OR operator, some expressions can be FALSE, as long as one is TRUE. All this talk about TRUE/FALSE, what does it all mean? If the overall value of a logical expression returns TRUE, the action will trigger. If the value returns FALSE, it will not trigger. |
Close-ended Logic For close-ended question expressions, IntelliSurvey has checked functions to assist in writing logical statements. With checked functions you can reference a closed-ended question and perform specific checks on the options selected. In many places in IntelliSurvey logic you will come across This type of check, employing Review the Checked functions pages to see all of them. |
|
Tables present a challenge because we are evaluating responses to several statements. Typically, there are multiple lists used to create a table, which can include close-ended or open-ended question types, and even mixed question types. IntelliSurvey's SPL includes several functions and tags to help simplify table logic. The list functions and different iterators like |
Comments
0 comments
Please sign in to leave a comment.