Skip to content

User Attempts Stats API

Saravanakumar Nagaraj edited this page Jun 11, 2021 · 7 revisions

Get the stats of all attempts topic-wise

GET /api/stats/topic_attempts_stats/:topic_id

PARAMS

  • Header : Bearer Token
  • Params : topic id

RESPONSE

Success

  • If the user hasn't attempted any quiz before on that respective topic (Status Code: 200)
{
    "error": false,
    "started_attempts": false,
    "topic_attempt_stats": null
}
  • If the user has attempted any quiz before on that respective topic (Status Code: 200)
{
    "error": false,
    "started_attempts": true,
    "topic_attempt_stats": [
        {
            "attempt_id": "60b489ac83436699ea3655cd",
            "correct": 0,
            "skipped": 5,
            "incorrect": 0,
            "total_questions": 5,
            "date": "31/05/2021, 12:30:41"              // "N/A" for previous submission, as the data wasn't collected
        },
        {
            "attempt_id": "60b489ac83436699ea3655ce",
            "correct": 3,
            "skipped": 2,
            "incorrect": 0,
            "total_questions": 5,
            "date": "31/05/2021, 11:20:21"              // "N/A" for previous submission, as the data wasn't collected        
        }
    ]
}

RESPONSE Failure

  • If there is no topic id in the params (Status code: 400)
{
    "error" : true,
    "message" : "Send topic id"
}
  • If the topic id is not valid mongo id (Status code: 400)
{
    "error": true,
    "message": "Invalid topic id"
}
  • If topic id doesn't match with any topic (Status code: 400)
{
    "error": true,
    "message": "No such topic id"
}
  • Others (Status code: 500)
{
    "error": true,
    "message": "Something went wrong",
    "reason": err
}