Pearson
Always Learning

API Group: 

This API is where you'll send, update, or retrieve the user's answers during an active attempt.

Each question type requires a different payload format for submitting an answer to this API, each of which are detailed below. You should review the various API contracts for each question type as well to ensure you're familiar with the different ways to get answer options and premises, where relevant.

In order to submit or update answers, there must be an active attempt. Once the attempt is marked as complete, or expires, answers cannot added or changed. (You will be able to retrieve the student's answers in the attempt after the attempt is complete, however.)

Note: When working with this API you may see references to answer IDs. An Answer ID is always the same value as the Question ID. Updating an answer will change the answer value but not change the Answer ID.



Supported Roles and Authentication Protocols

Type Supported Values
Authentication Protocols OAuth 1.0a, OAuth 2.0
Valid for Roles (OAuth 2): Professor, Teaching Assistant, Student, Administrator

Note: Only the user for whom the exam instance was provisioned add or update answers in an attempt. So while technically teachers and teaching assistants can take an exam, in practical terms this API is primarily used by Student roles with OAuth 2 Access Tokens.

API Request

API Endpoints

HTTP Verbs and URIs

GET /users/{userId}/courses/{courseId}/exams/{examId}/attempts/{attemptId}/answers
  • Retrieves an array of of the user's saved answers.
GET /users/{userId}/courses/{courseId}/exams/{examId}/attempts/{attemptId}/answers/{questionId}
  • Retrieves an array of of the user's answers to a specific question.
POST /users/{userId}/courses/{courseId}/exams/{examId}/attempts/{attemptId}/answers
  • Saves a user's answer (see question type-specific payload formats, below).
PUT /users/{userId}/courses/{courseId}/exams/{examId}/attempts/{attemptId}/answers/{questionId}
  • Updates a user's answer (see question type-specific payload formats, below).
DELETE /users/{userId}/courses/{courseId}/exams/{examId}/attempts/{attemptId}/answers/{questionId}
  • Deletes a user's answer.

Parameters

Parameter Description Valid Values
{userId} LearningStudio User ID or relevant user overload.
  • Numeric ID issued by LearningStudio
  • loginid={clientString}|{username}
  • or replace /users/{userId} with /me
    (OAuth 2 only)
{courseId} LearningStudio Course ID or relevant course overload.
  • Numeric ID issued by LearningStudio
  • ccn={callNumber}
{examId} LearningStudio Exam ID. Numeric ID issued by LearningStudio
{attemptId} LearningStudio Exam Attempt ID. Numeric ID issued by LearningStudio
{questionId} LearningStudio Question ID. Note that answer IDs are the same value as question IDs. Numeric ID issued by LearningStudio
{.format} Desired format of response data. See Response Formats. .json , .xml , or Blank

Request HTTP Headers

In addition to the standard Authentication headers, you will need headers that regulate Exam Security. See Exam Security.

Format

Pearson-Exam-Password: {examPassword}
Pearson-Exam-Token: {examToken}

Parameter Descriptions

Name Description Valid Values Required
{examPassword} A password provided by the teacher. This is not retrievable by API. Exam Security Plain text string Only if set by teacher, for all verbs
{examToken} The Pearson Exam Token provided by a POST or GET to this API Plain text string Always for PUT

Query String Parameters

No Query String Parameters are supported.

Request Body

Each question type requires a unique payload format for saving (POST) and updating (PUT) answers. There is no request body for GET and DELETE. Below, each payload format is printed first, and the property table at the end of this section covers all question types.

True/False Questions

{
  "answer": {
    "id": {questionId},
    "type": "trueFalse",
    "trueFalseAnswer": {
      "id": {choiceId}
    }
  }
}

More Information:

Multiple Choice Questions

{
  "answer": {
    "id": {questionId},
    "type": "multipleChoice",
    "multipleChoiceAnswer": {
      "id": {choiceId}
    }
  }
}

More Information:

Many Multiple Choice Questions

{
  "answer":{
    "id": {questionId},
    "type": "manyMultipleChoice",
    "manyMultipleChoiceAnswers":[{
      "id":{choiceId}
    },{
      "id":{choiceId}
    }]
  }
}

More Information:

Matching Questions

{
  "answer":{
    "id":{questionId},
    "type":"matching",
    "matchingAnswers":[{
      "premise": { "id": {premiseId} },
      "choice": { "id": {choiceId} }
    },{
      "premise": {"id": {premiseId} },
      "choice": {"id": {choiceId} }
    },{
      "premise": {"id": {premiseId} },
      "choice": {"id": {choiceId} }
    }]
    }
  }
}

More Information:

Short Answer Questions

{
  "answer":{
    "id": {questionId},
    "type": "short",
    "shortAnswer":{
      "text":"{answerText}"
    }
  }
}

More Information:

Essay Questions

{
  "answer":{
    "id": {questionId},
    "type": "essay",
    "essayAnswer":{
      "text":"{answerText}"
    }
  }
}

More Information:

Fill-in-the-Blank Question

{
  "answer":{
    "id": {questionId},
    "type": "fillInTheBlank",
    "fillInTheBlankAnswer":{
      "text": "{answerText}"
    }
  }
}

More Information:

Property Descriptions for All Question Types

Name Description Valid Values
{questionId} The ID of the question you're answering. The Answer ID is always the same value as the Question ID. Numeric ID issued by LearningStudio
{choiceId} Choice ID being saved as answer. The IDs to choose from are specified by the relevant Answer Options API for the question type. See the "More Information" links by each payload format above. Numeric ID issued by LearningStudio.
{premiseId} Premise ID for Matching questions - this the text to which the choice is being matched. The Premise IDs are specified by the Premises API for Matching questions. See the "More Information" links Matching questions above Numeric ID issued by LearningStudio.
{answerText} Freeform text entered by the user as their answer. Any string of characters entered by the user.

API Response

Response Header

This API returns the standard HTTP Status Codes used by the LearningStudio APIs. There are no special headers returned by the API.

Response Body

When saving a new answer for a user (POST), the response body will be an echo of the saved answer, along with link href's to additional detail. Because each question type has a different format, they are detailed here. See the examples below for some specific payloads.

When updating or deleting an answer (PUT), there will not be a response body.

Sample Format For GET

Here is a sample format for GET .../answers (returning all saved answers):

{
  "answers": [{
	"trueFalseAnswer": {
		"id": {choiceId}
		"links": [{
			"href": "{choiceHref}",
			"rel": "https://api.learningstudio.com/rels/user/course/exam/section/trueFalseQuestion/choice"
		}]},
	"id": {questionId},
	"type": "TrueFalse",
	"links": [{
		"href": "{answerHref}",
		"rel": "https://api.learningstudio.com/rels/user/course/exam/attempt/answer"
	    }]
	},{
	"multipleChoiceAnswer":{
        "id":{choiceId},
        "links":[{
        	"href":"{choiceHref}",
        	"rel":"http://api.learningstudio.com/rels/user/course/exam/section/multipleChoiceQuestion/choice"
    	}]},
    "id":{questionId},
    "type":"multipleChoice",
    "links":[{
      "href":"{answerHref}",
      "rel":"http://api.learningstudio.com/rels/user/course/exam/attempt/answer"
      }]
  }]
}

Example: Save True/False Answer

Request

Endpoint

POST /users/88888/courses/123456/exams/999999/attempts/808080/answers

HTTP Headers

Pearson-Exam-Token: XVNQEQIXDRYATw4JBFZJAkFYUVEOBBdeW14ICVxBClwBXVBACQYOXAYJRFAH==

Body

{
  "answer": {
    "id": 111111,
    "type": "trueFalse",
    "trueFalseAnswer": {
      "id": 1
    }
  }
}

Response

Body

{
  "answer": {
	"trueFalseAnswer": {
		"id": 1,
		"links": [{
			"href": "https://api.learningstudio.com/users/88888/courses/123456/exams/999999/sections/123123/trueFalseQuestions/111111/choices/1",
			"rel": "https://api.learningstudio.com/rels/user/course/exam/section/trueFalseQuestion/choice"
		}]
	},
	"id": 1277871470,
	"type": "trueFalse",
	"links": [{
		"href": "https://api.learningstudio.com/users/88888/courses/123456/exams/999999/attempts/808080/answers/111111",
		"rel": "https://api.learningstudio.com/rels/user/course/exam/attempt/answer"
	}]
  }
}

Example: Change True/False Answer

Request

Endpoint

PUT /users/88888/courses/123456/exams/999999/attempts/808080/answers/111111

HTTP Headers

Pearson-Exam-Token: XVNQEQIXDRYATw4JBFZJAkFYUVEOBBdeW14ICVxBClwBXVBACQYOXAYJRFAH==

Body

{
  "answer": {
    "id": 111111,
    "type": "trueFalse",
    "trueFalseAnswer": {
      "id": 0
    }
  }
}

Response

HTTP Status Code

204 - No Content

Example: Get All Saved Answers

Request

Endpoint

GET /users/88888/courses/123456/exams/999999/attempts/808080/answers

HTTP Headers

Pearson-Exam-Token: XVNQEQIXDRYATw4JBFZJAkFYUVEOBBdeW14ICVxBClwBXVBACQYOXAYJRFAH==

Response

Body

{
  "answers":[{
    "trueFalseAnswer":{
      "id":1,
      "links":[{
        "href":"https://api.learningstudio.com/users/88888/courses/123456/exams/999999/sections/67890/trueFalseQuestions/11111/choices/1",
        "rel":"https://api.learningstudio.com/rels/user/course/exam/section/trueFalseQuestion/choice"}]},
    "id":11111,
    "type":"trueFalse",
    "links":[{
      "href":"https://api.learningstudio.com/users/88888/courses/123456/exams/999999/attempts/808080/answers/11111",
      "rel":"https://api.learningstudio.com/rels/user/course/exam/attempt/answer"}]
  },{
    "multipleChoiceAnswer":{
      "id":4,
      "links":[{
        "href":"https://api.learningstudio.com/users/88888/courses/123456/exams/999999/sections/67890/multipleChoiceQuestions/11112/choices/4",
        "rel":"https://api.learningstudio.com/rels/user/course/exam/section/multipleChoiceQuestion/choice"
      }]
    },
    "id":11112,
    "type":"multipleChoice",
    "links":[{
      "href":"https://api.learningstudio.com/users/88888/courses/123456/exams/999999/attempts/808080/answers/11112",
      "rel":"https://api.learningstudio.com/rels/user/course/exam/attempt/answer"
    }]
  },{
    "shortAnswer":{
        "text":"My Short Answer"
      },
      "id":11113,
      "type":"short",
      "links":[{
        "href":"https://api.learningstudio.com/users/88888/courses/123456/exams/999999/attempts/808080/answers/11113",
        "rel":"https://api.learningstudio.com/rels/user/course/exam/attempt/answer"
      }]
  },{
    "fillInTheBlankAnswer":{
      "text": "My Answer"},
    "id": 11114,
    "type": "fillInTheBlank",
    "links":[{
      "href":"https://api.learningstudio.com/users/88888/courses/123456/exams/999999/attempts/808080/answers/11114",
      "rel":"https://api.learningstudio.com/rels/user/course/exam/attempt/answer"
    }]
  }]
}
2831 reads
Always Learning
Pearson