# Storing workflow progress for later sessions

**URL:** <https://community.triggre.com/t/storing-workflow-progress-for-later-sessions/757>\
**Category:** Flow parts\
**Tags:** designer, flow-parts\
**Created:** [December 31, 2019, 11:00pm UTC](https://community.triggre.com/t/storing-workflow-progress-for-later-sessions/757 "2019-12-31T23:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mar](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.triggre.com/mar/32/395_2.png) [@Mar](https://community.triggre.com/u/Mar)\
**Post date:** [December 31, 2019, 11:00pm UTC](https://community.triggre.com/t/storing-workflow-progress-for-later-sessions/757/1 "2019-12-31T23:00:00Z")

</div>

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:

1. _Questionnaire_: the questionnaires that are used in the organisation.

2. _Question_: the questions that belong to them.

3. _My Questionnaire_: the questionnaires that are assigned to _Users_.

4. M_y 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

1. In the **Data item** _User_, add the reference _Current questionnaire_ to _User_ and reference it to _Questionnaire_.
2. A _User_ can have only one _Current questionnaire_. A _Questionnaire_ can have more than one _User_ who is currently working on it.  
 ![User data item](https://canada1.discourse-cdn.com/flex035/uploads/triggre/original/1X/16ddd51aa0d5b96a14fd817d9155f573ab133c6b.png)  
 ![Questionnaire data item](https://canada1.discourse-cdn.com/flex035/uploads/triggre/original/1X/955117b636c82f49ac6eb91cf694371d7da0fb86.png)

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_

 ![My current question flow part](https://canada1.discourse-cdn.com/flex035/uploads/triggre/original/1X/3c3d0fd0997f77bc2c9969839c8005ed35a15607.png)

1. Start with the **Input** _User / Current user_.

2. 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_

3. Generate a single _My question_, sorted on number, smallest to largest.

4. The result will be: _The next question to answer_ **OR** _No questio_n (if all questions are answered), in which case the flow edits the _My questionnaire_ as _Completed_.

5. The **Output** will be the question that has to be answered or no question at all.

### Design the User flow _My current question_

 ![My current question user flow](https://canada1.discourse-cdn.com/flex035/uploads/triggre/original/1X/13ded48799f22f305e85d24aa04ec4e8b36f5cfd.png)

In words:

1. 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_.

2. 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.

3. If no question is returned: this means that the _User_ has answered all questions. Congratulate the _User_ and exit to _My questionnaires_.
