Quiz statistic API ungraded quiz

Jump to solution
Nva2023
Community Explorer

Hi @James 

I am trying to get students responses from ungraded survey classic Quizzes via API, using this as url

instructure.com/api/v1/courses/" + courseID + "/quizzes/" + quiz_id + "/statistics?include[]=submission_history

or this

instructure.com/api/v1/courses/" + courseID + "/quizzes/" + quiz_id + "/statistics

I can see manually in Canvas the responses are listed under url: /courses/8141/quizzes/162015/history?quiz_submission_id=980024 

But with API there are no responses listed, looks like this: 

{
"quiz_statistics": [
{
"id": "2588",
"url": "https://X.instructure.com/api/v1/courses/8141/quizzes/162015/statistics",
"html_url": "https://x.instructure.com/courses/8141/quizzes/162015/statistics",
"multiple_attempts_exist": true,
"generated_at": "2024-03-12T17:22:21Z",
"includes_all_versions": false,
"includes_sis_ids": true,
"points_possible": null,
"anonymous_survey": true,
"speed_grader_url": null,
"quiz_submissions_zip_url": "https://x.instructure.com/courses/8141/quizzes/162015/submissions?zip=1",
"question_statistics": [
{
"id": "2377759",
"question_type": "essay_question",
"question_text": "<span>Is there a specific topic you'd like the instructor to explain better to help you understand the material more effectively?</span>",
"position": 1,
"responses": 4,
"graded": 0,
"full_credit": 0,
"point_distribution": [
{
"score": 0,
"count": 5
}
],
"answers": [
{
"user_ids": [
null,
null,
null,
null,
null
],
"responses": 5,
"id": "ungraded",
"score": 0,
"full_credit": false
}
]
}
],
"submission_statistics": {
"scores": {
"0": 5
},
"score_average": 0,
"score_high": 0,
"score_low": 0,
"score_stdev": 0,
"correct_count_average": 0,
"incorrect_count_average": 0,
"duration_average": 55657,
"unique_count": 5
},
"links": {
"quiz": "https://x.instructure.com/api/v1/courses/8141/quizzes/162015"
}
}
]
}

 

0 Likes
1 Solution
James
Community Champion

Was your first request a POST or a GET? It has to be a POST.

The string[] on the documentation says that it is a string array and there's a note that says it's JSON-API only.

POST commands are rarely made with a command line and it's definitely not JSON when you do.

That said, if I make a POST and leave off the include=file, the report generation begins and I get what I need to finish.

Here is an abbreviated version of the output.

{
  "id": 1640643,
  "report_type": "student_analysis",
  "readable_type": "Student Analysis",
  "url": "... /quizzes/11385725/reports/1640643",
  "progress_url": "... /api/v1/progress/51792053",
  "quiz_id": 11385725
}

Now, if I use a GET on the URL that it gives me, which is an API request, it gives me the file information. I don't need to use include=file. I don't think it does this until the report is ready, There is a progress url in there where you can check to make sure it's done, but this was a small class and I'm a slow typist.

The file URL it gives is not an API call -- do not include the credentials.

View solution in original post

0 Likes