Metrics Page Tech Doc - AashnaNarang/SurveyLab GitHub Wiki
APIs
-
Survey Responses API Updates
GET /api/v1/surveys/:surveyId or GET /api/v1/surveys/survey_responses/:surveyId
-
First try to make it a different route than the existing show route, if the code is the same then combine the two.
-
If the two are combined, check for errors that may pop up in the Survey.js file
-
If its a text response, a JSON of all the responses
-
If its an MC response, then a summary of how many responses per option + the option name
-
This is the response:
survey: { "question 1": { "question_type": text, "order": 1, "responses": { "response 1"", "response 2", "response 3" } }, "question 2": { "question_type": "mc", "order": 2, "responses": { "Option 1": 20, "Option 2": 5, "Option 3": 10, "Option 4": 1 } } }
-
Then the frontend can display the question, then a list of responses for text ones, for mc question, display the question then display the answers in the form of a pie chart
-
Frontend
- Use API: /surveyResponses/:surveyId page
- The “View metrics” button on the survey on the dashboard routes to this page
- Call the GET /api/v1/surveys/:surveyId or GET /api/v1/surveys/survey_responses/:surveyId API to get the information you need
- Display each text question and below it have a scrollable list (static size box though) of the text responses
- Display each mc question and below it have a pie chart of the mc_options
- Questions should be displayed in the same order they are displayed in the survey