Retaking an Assessment

If a profile risk entity exists against an assessment, and profile questionnaire entity has progress = 1, then it is a completed assessment. Users may want to re-attempt completed assessments at a later time, after making changes to their lifestyle.

All the answers from the initial attempt are stored for the user. Hence, the GET available-questions endpoint will return an equal number of available_question_ids and answered_question_ids. The existing answers can be fetched using the GET profile-questionnaire endpoint, and when re-attempting, you can even pre-select the options the user chose when first attempting the questionnaire. Just like attempting a questionnaire for the first time, users are to be displayed questions in the same order as displayed in available_question_ids. The question details can be fetched from the same endpoint that's used for the first attempt, i.e. question listing endpoint.

If a user does not change their answer to a question and reselects the same option or enters the exact same response text, the POST /answer/ call should not be made, and neither the subsequent GET available-questions call should be made, because if the answer stays the same, there is no need to update it, and there won't be any difference in the available questions. Simply, the next question in available_question_ids that were fetched upon starting the questionnaire can be displayed.

If user selects a different option or gives a different text answer, then a POST call should be made to answer endpoint, and subsequently, GET /available-questions/ should be called and the next question should be displayed based on the latest fetched available_question_ids

Example

Let's say a user is re-attempting a completed assessment and the available-questions endpoint returns the following response:

{  
    "available_question_ids": [  
        "a28f4e05-2f46-438d-a8d0-feb898bf3319",  
        "8619f86b-b1f2-4aff-ab98-54b27d06b8dc",  
        "022d574b-ac7e-4335-8f25-246f731b89e7"  
    ],  
    "answered_question_ids": [  
        "022d574b-ac7e-4335-8f25-246f731b89e7",  
        "8619f86b-b1f2-4aff-ab98-54b27d06b8dc",  
        "a28f4e05-2f46-438d-a8d0-feb898bf3319"  
    ]  
}

Case 1: Choosing same answers

  1. Display the first available question to the user, with id a28f4e05-2f46-438d-a8d0-feb898bf3319
  2. User chooses the same answer option as selected in an earlier attempt
  3. Simply display the next question from the array with id 8619f86b-b1f2-4aff-ab98-54b27d06b8dc without making any API call
  4. User chooses the same answer option as selected in an earlier attempt
  5. Display question with id 022d574b-ac7e-4335-8f25-246f731b89e7
  6. User chooses the same answer option as selected in an earlier attempt
  7. Re-attempt successful, no changes made to user's profile risk score in backend.

Case 2: User chooses a different answer for any question

  1. Display the first available question to the user, with id a28f4e05-2f46-438d-a8d0-feb898bf3319
  2. User chooses a different answer option as selected in an earlier attempt
  3. Make a POST call to /answer/ endpoint with the newly selected option.
  4. Make a GET call to /available-questions/ endpoint which returns:
    1. {
          "available_question_ids": [
              "a28f4e05-2f46-438d-a8d0-feb898bf3319",
              "3890dc66-dffe-4ad5-9625-da328287792c",
              "8619f86b-b1f2-4aff-ab98-54b27d06b8dc",
              "022d574b-ac7e-4335-8f25-246f731b89e7"
          ],
          "answered_question_ids": [
              "022d574b-ac7e-4335-8f25-246f731b89e7",
              "8619f86b-b1f2-4aff-ab98-54b27d06b8dc",
              "a28f4e05-2f46-438d-a8d0-feb898bf3319"
          ]
      }
      
  5. Notice that the available_question_ids list is updated. Display the next question from the updated array with id 3890dc66-dffe-4ad5-9625-da328287792c
    1. Note: It may not always get updated. It will only get updated if there are certain questions which are dependent on the new answer that the user chose. Otherwise, it'll just return the same list as before.
  6. Since this is a new question and is not present in answered_question_ids, any answer the user selects has to be followed by a POST call to /answer/ endpoint.
  7. Call the GET /available-questions/ endpoint which returns
    1. {
          "available_question_ids": [
              "a28f4e05-2f46-438d-a8d0-feb898bf3319",
              "3890dc66-dffe-4ad5-9625-da328287792c",
              "8619f86b-b1f2-4aff-ab98-54b27d06b8dc",
              "022d574b-ac7e-4335-8f25-246f731b89e7"
          ],
          "answered_question_ids": [
              "022d574b-ac7e-4335-8f25-246f731b89e7",
              "3890dc66-dffe-4ad5-9625-da328287792c",
              "8619f86b-b1f2-4aff-ab98-54b27d06b8dc",
              "a28f4e05-2f46-438d-a8d0-feb898bf3319"
          ]
      }
      
  8. Display the next available question from the updated list, i.e. 8619f86b-b1f2-4aff-ab98-54b27d06b8dc
  9. User chooses the same answer option as selected in an earlier attempt
  10. Display question with id 022d574b-ac7e-4335-8f25-246f731b89e7
  11. User chooses the same answer option as selected in an earlier attempt
  12. Re-attempt successful, user's risk score updated.
    1. Note: The latest score was calculated at step 6 when the call was made to POST /answer/ and the latest profile_risk entity was returned in response. It did not get updated any further as no more answers were posted. That profile_risk can be used to display the latest details about the user's risk, or a subsequent GET call can always be made to /profile-risk/ endpoint.

Re-attempting partially completed assessments

The same logic can be applied if a questionnaire is left half-way completed and the user re-attempts the questionnaire at a later point, or if a questionnaire is partially completed because the user answered some questions of that questionnaire while attempting another assessment. All that information can be obtained from the GET profile-questionnaire endpoint, which returns the progress and answers that a profile has stored against the concerned questionnaire.

In that case, the first unanswered question can be displayed to the user, followed by the same logic of calling POST /answer/ for each unanswered question, followed by calling GET /available-questions/. If you want to display answered questions first when user is re-attempting an incomplete assessment, that too can be done, by following the exact same logic as is followed for showing them questions of completed assessments, i.e. display answered questions in the order given in available_question_ids, if the answer isn't altered, don't make any API call, and simply display the next available question, and so on.