What is a computation?

What is a computation?

A computation is a calculation based on answers of a client.

 

What can you do with a computation?

  • Calculate the 'total score' on a questionnaire
  • Give an advice that depends on the score a client gets on a questionnaire
  • Give back the score on several domains to the client and therapist
  • Make a piece of content within a session dependent on a calculated score
  • Trigger a piece of content based on the outcome of a calculation or questionnaire


For example, you can calculate BMI (Body Mass Index), and give back an advice to the client based on whether they scored underweight, normal weight, or overweight.

 

What does a calculation look like?

A computation is a piece of code (javascript) in which you write a calculation based on the question(s) in your session.



If you want, you can learn more about code. This will help you to get more creative with your computations. It is based on javascript, so most rules of javascript will apply. More on that later.


Understanding the parts of a computation

A computation consists of a couple of core parts. They are the following:



The computations 'object'

 The total range of calculations, from the beginning bracket { to the end bracket } and the finishing semicolon, is called the 'object'. This is the code that the computer will run through. We will put all the computations in here.

 The function declaration

A function is like a little machine in which we build the calculation we want the computer to run through. We give it a name, let the computer know that the function starts at the "name: function" and that we want it to use "(data)". 

 Data

The command 'data'  is used to refer to the answers saved in the document. This way, the data the client enters is used in the computation and the score of that particular client is given back.

 The function body

The function body is the content of the machine, the actual calculation.

    • Related Articles

    • How to test a computation for a mobile module

      To test your computation, it is important to first check whether your computation is actually defined. After opening 'computation' in the left menu, you will see your created compution there. Or you see the default text if you didn't create one yet. ...
    • Computations in mobile modules

      What to do before adding a computation in a mobile module Determine the score for each answer. Determine the calculation of the scores in Computations JavaScript screen. Determine how the score will be displayed. You can show the score to the client ...
    • How to create computations

      When you create a computation it is especially important to practice a lot. Writing codes is very unforgiving. One small mistake is enough to stop the computation from working. If you get an error, remember: the code is always right! Stay calm and ...
    • Using entered answers in open questions in computations

      It’s possible to display answers from open questions later on in the module as text, e.g., asking for a goal XY and after some pages ask clients how their goal XY is going. To do this: turn on the “use in computation” toggle give a name to the ...
    • Useful code for creating computations

      It is best if you have had training in writing code in Javascript. If that's the case, you can easily write your code yourself. If you are not yet proficient in Javascript, this might be a handy page for you. Below are some snippets of code, matching ...