Quizzes
Quiz
A QuizActivity
has associated a Quiz
object that contains the set of the quiz questions and the learners responses to the quiz.
Questions
The quiz questions can be either of type MultipleChoice
, where learners can select one or more option, or OpenEnded
, where learners can write an open ended answer.
API Example
Since there are different question types, quiz questions make use of GraphQL Interfaces. Common fields, such as id
and content
can be represented through QuizQuestion
interface, specific fields can be fetched via an inline fragment.
query {
activity(id: "db79e3a7-07e7-4b2f-b799-e00ed94c1c8a") {
__typename
... on QuizActivity {
quiz {
questions {
__typename
content
order
isOptional
questionType
... on QuizQuestionMultipleChoice {
selectionMode
randomizeAnswers
options {
order
content
}
}
}
}
}
}
}
{
"data": {
"activity": {
"__typename": "QuizActivity",
"quiz": {
"questions": [
{
"__typename": "QuizQuestionMultipleChoice",
"content": "<p>Question 1</p>",
"order": 0,
"isOptional": false,
"questionType": "MultipleChoice",
"selectionMode": "Single",
"randomizeAnswers": false,
"options": [
{
"order": 0,
"content": "<p>Option 1</p>"
},
{
"order": 1,
"content": "<p>Option 2</p>"
},
{
"order": 2,
"content": "<p>Option 3</p>"
}
]
},
{
"__typename": "QuizQuestionMultipleChoice",
"content": "<p>Question 2</p>",
"order": 1,
"isOptional": false,
"questionType": "MultipleChoice",
"selectionMode": "Multiple",
"randomizeAnswers": false,
"options": [
{
"order": 0,
"content": "<p>Option 1</p>"
},
{
"order": 1,
"content": "<p>Option 2</p>"
},
{
"order": 2,
"content": "<p>Option 3</p>"
}
]
},
{
"__typename": "QuizQuestionMultipleChoice",
"content": "<p>Question 3</p>",
"order": 2,
"isOptional": true,
"questionType": "MultipleChoice",
"selectionMode": "Multiple",
"randomizeAnswers": true,
"options": [
{
"order": 0,
"content": "<p>Option 1</p>"
},
{
"order": 1,
"content": "<p>Option 2</p>"
},
{
"order": 2,
"content": "<p>Option 3</p>"
}
]
},
{
"__typename": "QuizQuestionOpenEnded",
"content": "<p>Question 4</p>",
"order": 3,
"isOptional": false,
"questionType": "OpenEnded"
}
]
}
}
}
}
Responses
The quiz responses contains the learners answers to the quiz. Each answer can be either MultipleChoice
or OpenEnded
, depending on the question type.
API Example
Responses are available via a pageable GraphQL Connection.
Paginating queriesquery {
activity(id: "db79e3a7-07e7-4b2f-b799-e00ed94c1c8a") {
__typename
... on QuizActivity {
quiz {
responses(first: 2) {
edges {
node {
retryNumber
submitter {
name
}
group {
members {
name
}
}
answers {
__typename
question {
content
questionType
}
... on QuizAnswerMultipleChoice {
selectedOptions {
content
order
}
isCorrect
}
... on QuizAnswerOpenEnded {
content
}
}
}
}
}
}
}
}
}
{
"data": {
"activity": {
"__typename": "QuizActivity",
"quiz": {
"responses": {
"edges": [
{
"node": {
"retryNumber": null,
"submitter": {
"name": "Daisy Duck"
},
"group": {
"members": [
{
"name": "Daisy Duck"
}
]
},
"answers": [
{
"__typename": "QuizAnswerMultipleChoice",
"question": {
"content": "<p>Question 1</p>",
"questionType": "MultipleChoice"
},
"selectedOptions": [
{
"content": "<p>Option 1</p>",
"order": 0
}
],
"isCorrect": true
},
{
"__typename": "QuizAnswerMultipleChoice",
"question": {
"content": "<p>Question 2</p>",
"questionType": "MultipleChoice"
},
"selectedOptions": [
{
"content": "<p>Option 2</p>",
"order": 1
}
],
"isCorrect": false
},
{
"__typename": "QuizAnswerMultipleChoice",
"question": {
"content": "<p>Question 3</p>",
"questionType": "MultipleChoice"
},
"selectedOptions": [
{
"content": "<p>Option 2</p>",
"order": 1
},
{
"content": "<p>Option 3</p>",
"order": 2
}
],
"isCorrect": false
},
{
"__typename": "QuizAnswerOpenEnded",
"question": {
"content": "<p>Question 4</p>",
"questionType": "OpenEnded"
},
"content": "<p>Open answer</p>"
}
]
}
},
{
"node": {
"retryNumber": null,
"submitter": {
"name": "Uncle Scrooge"
},
"group": {
"members": [
{
"name": "Uncle Scrooge"
}
]
},
"answers": [
{
"__typename": "QuizAnswerMultipleChoice",
"question": {
"content": "<p>Question 1</p>",
"questionType": "MultipleChoice"
},
"selectedOptions": [
{
"content": "<p>Option 2</p>",
"order": 1
}
],
"isCorrect": false
},
{
"__typename": "QuizAnswerMultipleChoice",
"question": {
"content": "<p>Question 2</p>",
"questionType": "MultipleChoice"
},
"selectedOptions": [
{
"content": "<p>Option 2</p>",
"order": 1
},
{
"content": "<p>Option 3</p>",
"order": 2
}
],
"isCorrect": false
},
{
"__typename": "QuizAnswerMultipleChoice",
"question": {
"content": "<p>Question 3</p>",
"questionType": "MultipleChoice"
},
"selectedOptions": [
{
"content": "<p>Option 1</p>",
"order": 0
},
{
"content": "<p>Option 3</p>",
"order": 2
}
],
"isCorrect": false
},
{
"__typename": "QuizAnswerOpenEnded",
"question": {
"content": "<p>Question 4</p>",
"questionType": "OpenEnded"
},
"content": "<p>Open answer</p>"
}
]
}
}
]
}
}
}
}
}
Last updated