Skip to content

The Syntax of Consequences and Options of a Questionnaire

Syntax of Consequences

A consequence is a message to be displayed or an action to be performed at the end of the test, under certain conditions. A consequence can be expressed in the general form: if condition then action.

A condition can be a simple test or a logical combination of elementary conditions, so we can write:

  • if condition1 and condition2 then action
  • if condition1 or condition2 then action
  • if (condition1 and condition2) or condition3 then action

Conditions

Conditions relate to tests concerning scores expressed in percentages % (overall score, score by domain or by tag).

  • Test on the overall score: global_score
  • Test on the score in the 'geo' domain: domain_score_geo
  • Test on the score for the 'best practices' tag: tag_score_best_practices

The comparison operators are: >, >=, <, <=, == (equality)

The logical operators are: and, or

Messages and Actions

The actions are:

message("..."), questionnaire("..."), module("..."), in_group("..."), out_group("...") The messages must be defined in the dedicated section Messages The actions must be defined in the dedicated section Actions Here are the variables that can be included within [] in the messages:

[firstname] [lastname] [global_score] [domain_score_geo] [tag_score_best_practices] …

WARNING: An action that starts on a new line must be preceded by 4 spaces. You can define multiple actions to be performed for the same condition, each action being on a line preceded by 4 spaces.

Examples of messages:

if  domain_score_geo <= 40  then message("Advice to [firstname] [lastname]! Revise geography, your score is [domain_score_geo] %")

if  domain_score_geo >= 60  then message("Congratulations you can obtain your [badge](https://www.xxx.com)")

if  domain_score_geo >= 60  then message("Congratulations you can visit the site http://www.xxx.com or https://www.xxx.com ")

Examples of actions: if global_score >= 60 and domain_score_geo <= 40 then out_group("Experts")

if  (domain_score_geo == 0  and  domain_score_timeline >= 80) then   questionnaire("explorers_expert")

if  tag_score_history == 100  then module("antarctica_level2")

Note: It is possible to define a message or an action without conditions.

Example of a permanent message:

message("Congratulations [firstname] [lastname]!")

Example of a permanent action:

email("administrator", "End of test", "end of test for [firstname] [lastname]")

Code Verification

You can verify your code by assigning values to the variables with the = operator. To do this, click on the 'CHECK CODE' button. Each assignment is written on a single line:

global_score = 75
domain_score_geo = 30
tag_score_history = 100

By clicking on the 'CODE VALIDATION' button, you will get a display of the messages and a check of the invitations to questionnaires or modules:

Message: Advice to Camille Chêne! Revise geography, your score is 30 %.

Options of a Questionnaire

The video below presents the other options of a questionnaire.

Mini Tutorial

Article Navigation

Previous Previous Article: Questionnaires

Next Next Article: Questionnaires