On Friday evening, May 3rd, a new version of the Minddistrict platform will go into production. In this release note, you'll find all updates. Enjoy the new version of Minddistrict! |
Do you have questions about the Minddistrict platform or app? Visit our online support site! |
CMS
Using entered answers in open questions in computations
This update is relevant for editors
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 question
- Write a short code in the computation like this:
reference: function (data) { return data.name_of_open_question; } |
- To get the text back later on in the module use ${computation:reference} in the module.
- Done. The answer of the open question should be displayed in the module now as text.
If you want to reference an answer from another chapter, it might be that the therapist has turned it off. Then there will be no answer to display. For these cases you can use the following code:
food_reference: function(data) { var food = data.food; if (typeof food === 'string') { return food; } else return "The question has not been answered."; } |
This code checks if the value from the open question is a string (text). If yes, the open question was answered and the answer can be displayed. If not, the function gives back something else, here: “The question has not been answered.”
The same applies to referencing answers from a multiple choice / single choice question:
// Single choice fruit_answer: function(data) { if (typeof data.fruit === 'number') { if (data.fruit === 90) { return "Apple"; } else if (data.fruit === 91) { return "Banana"; } else return "This question was not answered"; } // Multiple choice animals: function(data) { if (typeof data.animal === 'object') { var animal = []; if (data.animal.includes(1)) { animal.push("Cat"); } if (data.animal.includes(2)) { animal.push("Dog"); } return animal.join(", "); } else return "this question was not answered"; |
Do you want to stay informed about developments? Sign up and receive the Release note every month. |