Validations are only available if the Enable Calculations checkbox in the Assessment Settings is selected.
To create a validation, you add a calculation, and then, in the Calculation Type field, choose one of the Validation Types.
Validations allow you to:
- compare the result of a calculation to a constant. For example, see if the total of several numeric fields entered = 100
- see if allowable combinations of answers have been selected, for example maybe "Always" can only be selected once per subsection.
- Display a message if, say, a certain score has or hasn't been attained in the assessment so far, and potentially end the assessment.
- Validations can result in
- an error - the text for which will appear as a dialogue box and there will only be a Return button (that will take you back to the current section)
- a warning - the text for which will appear as a dialogue box and there will be a Return and a Next (that will take you to the Next section) button
- information - the text for which will appear as a dialogue box and there will only be a Next button
For example, the output from the warning validation shown below may appear like this:
Validations can occur anywhere in an assessment but are hidden in the response.
Validations use the power of Microsoft's Transact-SQL, meaning that as well as regular operators like +-*/ with or without brackets, advanced users can access the Mathematical and String functions that Transact-SQL offers for a single field. Validations always have Case statements in them resulting in "True" (there is an error) or "False" (there is no error). Often the messages use the Cast function to combine numeric results into a text message. Database statements are not allowed for security reasons.
Validations are always calculated when the responses to the section they are in is saved, either by hitting Next or Save Progress.
- Validations are denoted in the assessment builder with a tick before the Validation name.
- Calculation Name is used for identification purposes only.
- Calculation Number is used for reference and is interchangeable with a question number. For example, you can refer to a question number in a merge string in the feedback report to display the result of a calculation.
- Calculation Type specifies whether this is a calculation or a validation. Validation Types are
- Validation error - the text for which will appear as a dialogue box and there will only be a Return button (that will take you back to the current section)
- Validation warning - the text for which will appear as a dialogue box and there will be a Return and a Next (that will take you to the Next section) button
- Validation information - the text for which will appear as a dialogue box and there will only be a Next button
- The format of the validation is: case when [condition] then 'true' else 'false' end. The true and false may be transposed if that makes the condition simpler.
- Literals can be entered into a formula as a number for numerics, or with single quotes for character strings.
- If you have numerics that are user input, the Answer Type should be Numeric or Decimal rather than Text.
- If you have selected answers (e.g single choice) that are input to a calculation, the Answer Short Name will be used. It should be entered as a number with no formatting (e.g. 300000 not $300,000.)
- When scores are used in a calculation they are returned as a percentage. e.g. .6 = 60%. if you want the Likert equivalent you need to multiply it by 5 (assuming your Potential Points = 5).
- Comments can be added between /* and */ to document the validation
- Support will help build more complex validations for you.
- Calculate after Scoring - Indicates whether the scoring for the assessment, including the current page should be calculated before the Validation. This is used when you need the "current score" as part of the calculation.
- Result is Numeric - Not relevant for Validations.
- Validation Message - Merge Fields - use the merge field drop-down lists to specify answers and scores that you wish to include in the score calculation. Click the Add button to insert the merge string where the cursor currently is.
- Validation Message - Enter the message that should be displayed in the dialogue box. In the example shown, we want to show the total calculated in the text. The Cast Transact-SQL statement is used to convert the numeric value to a text string. Its format is CAST([expression] as varchar(max)). + signs are used to concatenate strings.
- Documentation - unlimited documentation of validations can be entered. They do not affect the validation or appear anywhere but here.
- Segmentations - Not used for Validations
- Conditions - a validation can be conditional like a question. The system will treat it as unanswered and no validations will be done.
- Report Text. -Not used for Validations.
As a system administrator, you can view the workings of Validations from within a response, for diagnostic purposes. The Section menu (to the left of the Section name on the response header) provides access to the Calculations form which shows validations as well:
- Validation Name
- Section / Subsection / Question Number of the validation
- If the validation message was shown, this field will be 'true'.
- The calculated score is not used by validations.
- The validations are shown how they are passed to SQL for calculation.
- The system preresolves all of the merge strings - so you can see the current values.
- The calculation of the message is shown even if it wasn't displayed.
- SQL has a quirk that if it is only passed whole numbers it will always return a whole number. For that reason, we multiply numbers by 1.00 to give the numbers decimal places.
- If there is an error in either of the formulas an error message will be shown. That error is from SQL and is usually quite cryptic. Most errors are caused by unmatched brackets or missing operators. Support can help you with these if you can not find them.