Action conditions

A feedback action has a condition. The feedback is only given when the condition is satisfied. An empty condition is always true, so when you leave the condition empty the feedback is always given. For each condition there also is a switch  Stop on match. If you switch this on, no further actions are performed after this one if the condition is met. This can for example be used to have default feedback when all other conditions fail.

The condition is an expression in JavaScript that results in a Boolean (true or false). In it you can use a number of variables. The most important one is answer, that contains the answer by the student. For multiple choice this is the label of the answer. When there are multiple answers the labels are stored in an array answers. In this case answer is the first one. The labels themselves can also be used as variables and are true if that answer was selected.

Boolean expressions

Boolean expressions in JavaScript are built up as follows:

  • Use == for equal. Also you can use comparisons like <, <=, > and >=.
  • Use && for and, || for or, and ! for not. 
  • You can also use parentheses.

For example, when you have a multiple choice question with four answers, labeled a, b, c, and d, and the correct answer is b and d, the following condition

!a && b && !c && d

could give feedback 'That is correct.' You can set Stop on match. Next you could add

(!a && !b && !c && d) || (!a && b && !c && !d)

could give the feedback 'You gave one correct answer but there is another correct answer as well.'. Note that these conditions can be much simpler; see below.

Variable overview

The most important variables that exist are:

answer The answer given by the student. When multiple answers, this is the first answer. For multiple choice the answer is the label. Note that for a numeric open question the answer is a number and for a text open question it is a string (between quotes).
correct Whether the answer is correct, that is, exactly equal to (one of) the provided solution(s).
answerCount The number of given answers. (for multiple choice)
correctAnswerCount The number of correct answers. (for multiple choice)
wrongAnswerCount The number of wrong answers. (for multiple choice)
label1, label2, ... You can use the labels of the answers as variables. They are true when selected and false otherwise. (for multiple choice)
attemptCount The number of the attempt to check the answer. The first time the student checks the answer this is 1, then 2,and so on. You can use this to make the feedback dependent on the attempt.
user.firstName First name of the student.


Last name of the student.

So, for example the two conditions used in the example above could also be written as



correctAnswerCount == 1 && wrongAnswerCount == 0

Note that when you use code actions you can add extra variables that you can then use in the conditions. For a full overview of the variables, see the Quarterfall object.


A condition is a JavaScript expression. So, in it you can use any JavaScript functions and properties you want. For example you can use:

str.length The length of a string or of an array.
str.trim() Trims all leading and trailing spaces and tabs.
str.toUpperCase() Turns the string in all uppercase letters.
str.toLowerCase() Turns the string in all lowercase letters.
str.includes(searchStr) Returns whether the string includes the search string.
So, for example, you could write feedback by checking whether an open answer contains certain keywords:

and give as feedback: 'You should write something about Quarterfall.'

If you want to use all power of JavaScript in your conditions, you can actually use a function with a closure. However, in such cases you better use a  code action instead.

Still need help? Contact Us Contact Us