Template "Test with a set of points"

If the user writes "Test" or "Take the test", the bot will offer testing:

For each correct answer, we will award points. We will store them in the variable "points" for the test. We reset this variable before starting the test:

Now you can ask the first question.

There are 4 answer buttons for the question. One of them leads to a message about the correct answer and points. All the rest - to the message that the user answered incorrectly. After that, for any outcome, the bot writes the correct answer, waits 10 seconds and moves on to the next question.

Pay attention to the block with crediting points:

In double curly braces, you can write any arithmetic expressions with variables, as well as use our special SmartQuery language, in which you can do a variety of things - from arithmetic to processing API return data:

The 2nd question of the test is: “How far (in millions of kilometers) is the Earth from the Sun? Write the approximate number of million km.

The user must enter the answer himself. We save the answer in the %Answer to the second question% variable and proceed to the condition: the variable must be in the range from 140 to 160. Then we will assume that the user knows the answer approximately.

After that, we follow the familiar pattern: if the answer is correct, we go to the script branch with crediting points. If incorrect, then we say that the user made a mistake and continue:

The 3rd question is: “Which planet from the Sun is the Earth?” Thanks to the “Wait for a response from the user” checkbox, we expect a response in the same block. This allows you not to take extra steps like "Process message" or "Save to variable". After that, we make a condition on the message itself from the user. This condition always works on the last message, which must be equal to "3" for the correct option.

Last updated