# How it should work?

## How does it should work?

1. Every participants should have an account
2. Each participants is labeled with  role
   1. &#x20;for the example of Malagasy National Assembly, role can be `deputy` and `sessionLeader`
   2. deputies are the voters&#x20;
   3. the one that lead and manage the session. He does not vote.
3. &#x20;In a session come one or more Yes/No questions.
4. Each question has to be voted by voters.
5. &#x20;Right after a vote, every body can get the statistic automatically.
6. Right after a session, every body can get a resume about the session.<br>

In order to be transparent as possible these are some rules to follow:

#### Rules for session

1. A session has 3 states: created, open, close
2. Numbers of voters in a session can be updated only if the state of the session is \`created\`, you cannot change an open or a closed session.
3. &#x20;Questions can be added if and only if session exists and not closed.

#### Rules for question

1. &#x20;Yes,No, NoIdea question-arrays should be empty by creation.
2. Voted attribute should be \`false\` by creation.
3. &#x20;State attribute should be \`created\` by creation
4. Session should not be empty and should match a created or an open session in the database. It tells us, in which session belongs the question.
5. &#x20;Sentence attribute can be updated only if the attribute voted is \`false\`.
6. Every question has a state : created, open, close&#x20;
   1. &#x20;created: No one can vote&#x20;
   2. open: Every body can vote&#x20;
   3. close : No one can vote

#### Rules of vote

1. Only Session Leader can open the vote.
2. &#x20;The vote is Open for a certain time period, decided by the Session Leader. And only during this time, user can vote.
3. After the periode of time, the vote is automatically closed.
4. &#x20;Every registered User can vote&#x20;
5. Client sends request to the endpoint vote&#x20;
6. The client's ID will be pushed to the set (every item is unique) of their decision (Yes, No, NoIdea)&#x20;
7. A voter has only one vote, which means, that if he already voted for \`Yes\`, he canot vote for \`No\` or \`NoIdea\` any more .
8. The vote cannot be updated. Once the request arrives at server side, you are done.
