If a user would be working on a Questionnaire, it would be nice if the user could continue where he left off in the Questionnaire when he signs in the next day. A way to achieve this is to store certain data in the User profile (the Data item User).
To do this, we first use the Data item User to store the current Questionnaire. Then, we use the Flow part My current question to find the question in that Questionnaire that he needs to answer.
1. Data structure
We have the following Data items in the application:
-
Questionnaire: the questionnaires that are used in the organisation.
-
Question: the questions that belong to them.
-
My Questionnaire: the questionnaires that are assigned to Users.
-
My question: copies of the questions that are assigned to Users.
When a teacher assigns a Questionnaire to a student, a Flow part copies the related questions to My questions. The reason for this is that the Questionnaire might change during or after the time that the student works on it. You don’t want the student to be affected by those changes.
2. User profile
- In the Data item User, add the reference Current questionnaire to User and reference it to Questionnaire.
- A User can have only one Current questionnaire. A Questionnaire can have more than one User who is currently working on it.
This way, the user can select the Questionnaire he is working on and the teacher can see who is working on a Questionnaire.
3. Only show questions that need to be answered
The User flow My current question shows the question that needs to be answered. We need some Properties and a Flow part to achieve this.
The following Properties of My question are used to keep track of answered questions:
- Questionnaire
- Question number
- This question was answered (true/false or date/time)
Design the Flow part My current question
-
Start with the Input User / Current user.
-
Find the next question to answer with a Look up from My question.
Questionnaire = Input / User / Current questionnaire AND
Answered on = Empty AND
User = Input / User -
Generate a single My question, sorted on number, smallest to largest.
-
The result will be: The next question to answer OR No question (if all questions are answered), in which case the flow edits the My questionnaire as Completed.
-
The Output will be the question that has to be answered or no question at all.
Design the User flow My current question
In words:
-
If there is a Current Questionnaire: get the Current question. If not: tell the User that he must select one. Then exit to My questionnaires.
-
If the Flow part My current question returns a question: show the Page Answer current question. After the user presses Done, store the answer and look for the next question to be answered.
-
If no question is returned: this means that the User has answered all questions. Congratulate the User and exit to My questionnaires.