cancel
Showing results for 
Search instead for 
Did you mean: 
OliverKharas
Community Participant

Create a Quiz Question

Jump to solution

Hi all this is my POST request using Postman to create a quiz question.

https://canvas.instructure.com/api/v1/courses/2775624/quizzes/8044367/questions?"question_type"= "essay_question",&"question_name"= "QuestionOliverTest",

It works, but only creates a "text_only_question" not an essay question? Capture.PNG

0 Kudos
1 Solution

Accepted Solutions
James
Community Champion

@OliverKharas 

I don't use Postman, but that looks like a messed up request. There are extra quotes and commas that shouldn't be there. But since it's a POST and those parameters are not typically in the query string, I don't know if it's just the way you entered it here or the way it was entered in Postman.

What I'm seeing though is that basically none of your question came through and only the defaults are used.

To create a single quiz question, you need to wrap everything inside a question object.

It's question[question_type]=essay_question, not just question_type=essay_question.

One alternative is to wrap it in a JSON object and then be sure to include the content-type:application/json header. Depending on the language/library you're using, you may need to JSON.stringify that -- with the right settings, Postman can probably do that for you.

{
  "question" : {
    "question_type" : "essay_question",
    "question_name" : "OliverTest"
  }
}

I like the JSON style when programming because it's easier to work with objects than strings. I like it for illustration purposes because it's easier for people to see the structure.

View solution in original post

6 Replies
James
Community Champion

@OliverKharas 

I don't use Postman, but that looks like a messed up request. There are extra quotes and commas that shouldn't be there. But since it's a POST and those parameters are not typically in the query string, I don't know if it's just the way you entered it here or the way it was entered in Postman.

What I'm seeing though is that basically none of your question came through and only the defaults are used.

To create a single quiz question, you need to wrap everything inside a question object.

It's question[question_type]=essay_question, not just question_type=essay_question.

One alternative is to wrap it in a JSON object and then be sure to include the content-type:application/json header. Depending on the language/library you're using, you may need to JSON.stringify that -- with the right settings, Postman can probably do that for you.

{
  "question" : {
    "question_type" : "essay_question",
    "question_name" : "OliverTest"
  }
}

I like the JSON style when programming because it's easier to work with objects than strings. I like it for illustration purposes because it's easier for people to see the structure.

View solution in original post

OliverKharas
Community Participant

Thanks @James I did have to tidy up my parameters as well. Working well now. Out of interest have you managed to use a CSV or similar to upload more than one question at a time?

James
Community Champion

@OliverKharas 

I have used an Excel to generate the questions and then used Respondus to import them into Canvas. I think that behind the scenes, they are creating a QTI file and then importing it with the content migrations API rather than the quiz API. I'm not positive as Respondus hides all that from you.

I have used programming to generate variation of questions and used the API to create them in Canvas.

I have not used programming to read an Excel file and use the API to create them in Canvas, but it is a natural extension of the work I have done. You could iterate through the file and generate the questions but you would still need to send them one at a time to Canvas.

OliverKharas
Community Participant

Thanks @James are you aware of any tutorials or guides around the process of using Excel/Respondus? 

 

On a side note I've seen your comments on a lot of threads and I think if you developed a YouTube channel to post your work the canvas API community would really benefit!! 😁  

James
Community Champion

@OliverKharas 

I don't know of any tutorials. I used the online help for Respondus that explains the format that the file has to be in. I imagine most people use the Word version to import into Respondus, but I am creating math questions and can use the formula capability of Excel to create the questions.

Thanks for the chuckle. After 2.5 semesters of teaching online because of COVID, I'm okay if I never make another YouTube video. That would take away time from writing code that can help people. Out of curiosity, what would I even put on a YouTube channel? The notion is something I've never given any thought to and don't know what would benefit people.

OliverKharas
Community Participant

Thank you @James  I will check it out, found some stuff already and will likely have to ask my ORG to pay for it.

 

No worries!! Yes where I work its been a massive year of moving all content online. I was watching a heap of those old Instructure conference videos, and they are all around 10 years old and the quality is lacking. I think if someone with your knowledge and use cases started making videos they would do really well. I would say a lot of CANVAS users wouldn't be aware of the API capability.