Get All Quiz Submissions API not working

Jump to solution
amit_kumar
Community Novice

We are using quiz submissions API to get the submissions history of the learners. We want to check details of all the attempts for a learner and so, using this API( link: Quiz Submissions - Canvas LMS REST API Documentation ). But, the problem is that we are getting details of learner's most recent submission for a particular quiz even though he has submitted it more than 3 times. What are we missing here?

0 Likes
1 Solution
James
Community Champion

 @amit_kumar  

What I do when I need all of the attempts is to start with that API call and then look at the attempt. When it is greater than 1, I make the call to get a single quiz submission using the id of the quiz submission. I iterate through the values from 1 to attempt-1.

For example,

GET /api/v1/courses/2687822/quizzes/6068656/submissions

returns this JSON fragment.

{
"quiz_submissions":[
{
"id":38733666,
"quiz_id":6068656,
"attempt":2
}
]
}

I make this call to get the first attempt.

GET /api/v1/courses/2687822/quizzes/6068656/submissions/38733666?attempt=1

If the first call said it was attempt 5, then I would make the specific call four times with attempt 1, 2, 3 and 4 to get the other attempts.

Depending on what you need, you may be able to get the information from the submission API with include[]=submission_history.

It returns the answers given by the students for each of the quiz attempts as well as much of the same information that the quiz submission gives. Some of the fields included with the quiz_submission that are not included with the regular submission are attempts_left, end_at, extra_attempts, extra_time, finished_at, fudge_points, has_seen_results, and kept_score.

Here are the fields with the submissions: anonymous_id, assignment_id, attempt, body, cached_due_date, entered_grade, entered_score, excused, extra_attempts, grade, grade_matches_current_submission, graded_at, grader_id, grading_period_id, id, late, late_policy_status, missing, points_deducted, posted_at, preview_url, score, seconds_late, submission_type, submitted_at, url, user_id, workflow_state

Here are the fields with the quiz_submissions: attempt, attempts_left, end_at, excused?, extra_attempts, extra_time, finished_at, fudge_points, has_seen_results, html_url, id, kept_score, manually_unlocked, overdue_and_needs_submission, quiz_id, quiz_points_possible, quiz_version, result_url, score, score_before_regrade, started_at, submission_id, time_spent, user_id, validation_token, workflow_state

The main benefits are that the submissions with include[]=submission_history will give you the student responses and that you can get the information about each submission with one call. However, if you need some of the quiz-specific information then you'll need to get one quiz at a time using the quiz_submission id and attempt.

View solution in original post