API to assign quiz to a given student?

302 views
Skip to first unread message

Boris Kheyfets

unread,
May 31, 2018, 9:18:35 AM5/31/18
to Canvas LMS Users
Hi all,

I'm searching for a way to assign a quiz to a given student using API.

It looks like all_dates quiz property is the way to do it, however it is unclear how to achieve it.

The quiz docs are here:

Boris Kheyfets

unread,
May 31, 2018, 9:23:45 AM5/31/18
to Canvas LMS Users

Boris Kheyfets

unread,
May 31, 2018, 9:38:09 AM5/31/18
to Canvas LMS Users
Using assignment overrides it is possible to assign quiz to a given student.

Boris Kheyfets

unread,
May 31, 2018, 9:46:40 AM5/31/18
to Canvas LMS Users
Oh, I solved it:

curl -s "https://$CANVAS_URL/api/v1/courses/$COURSE_ID/quizzes" \
  -X POST \
  -F "quiz[title]=Test4" \
  -F "quiz[only_visible_to_overrides]=true" \
  -F "quiz[published]=true" \
  -H "Authorization: Bearer $CANVAS_TOKEN" | jq -r '.'

Get assignment_id from this output, and use it in the next call:

curl -s "https://$CANVAS_URL/api/v1/courses/$COURSE_ID/assignments/$ASSIGNMENT_ID/overrides" \
  -X POST \
  -F "assignment_override[student_ids][]=$STUDENT_ID" \
  -H "Authorization: Bearer $CANVAS_TOKEN" | jq -r '.'

Boris Kheyfets

unread,
May 31, 2018, 11:05:29 AM5/31/18
to Canvas LMS Users
Here's how to create question (with answers) in the quiz:

curl -s "https://$CANVAS_URL/api/v1/courses/$COURSE_ID/quizzes/$QUIZ_ID/questions" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{ "question": { "question_type": "multiple_choice_question", "question_text": "<p>Is everything clear?</p>", "points_possible": 1, "answers": [ { "text": "I read and understood", "html": "", "weight": 100 }, { "text": "I have questions", "comments_html": "<p>Please post your questions to a discussion (in course navigation).</p>", "weight": 0 } ] } }' \

DV-RU

unread,
Jun 4, 2018, 10:08:43 AM6/4/18
to Canvas LMS Users
Боря, у тебя отличный монолог получается по решению проблем в канвасе)))
Кирилл.

Joseph Grn

unread,
Aug 14, 2020, 1:49:16 AM8/14/20
to Canvas LMS Users
This seems to work for assignments, but not quizzes for me.  Are you sure it works for quizzes?  I always get a `null` returned when I try to use quiz_ids when trying to post or put an override as you mention....

Boris Kheyfets

unread,
Sep 18, 2025, 8:36:59 AM (9 days ago) Sep 18
to Canvas LMS Users
Dear Joseph,

probably you set quiz type to either "practice_quiz" or "survey".

In order to set assignment override in this case - set the quiz type to either "assignment" or "graded_survey", after this set the assignment override, and finally change the quiz type to the one you wanted to use.
Reply all
Reply to author
Forward
0 new messages