Get Measure Using Scale Score with Prior Student Information
Overview
- There is prior information about a student. For example, a
previously-computed
priorAbilitywithpriorUncertaintyand number of days since that assessmentelapsedDays. - The student has taken a linked test with a known link ID.
- The student’s scale score and standard error (or conditional standard error) are being provided.
URL
POST /api/score/scale/bayes
Request
The following parameters are required in the request. An example is provided in the Code Example section.
| Parameter | Type | Description |
|---|---|---|
linkId |
String | ID associated with the linking table for the external test. MetaMetrics will provide these IDs. |
scaleScore |
String |
The scale score received on the external test. |
scaleSem |
Integer |
The standard error of measurement (or conditional sem) received on the external test. |
priorAbility |
Integer |
The student’s prior ability estimate. |
priorUncertainty |
Integer |
Uncertainty associated with the student’s prior ability estimate. |
elapsedDays |
Integer |
Number of days since the student’s measure was last updated. |
Response
This returns an object that contains the computed ability and uncertainty. See Scoring Service Response Codes for an explanation of error codes that might be returned.
| Parameter | Type | Description |
|---|---|---|
ability |
Integer |
The student’s new ability estimate. |
uncertainty |
Integer |
Uncertainty associated with the student’s new ability estimate. |
framework |
String | Either Lexile or Quantile; framework used to produce the measure. |
apiVersion |
String | The current version number for the API. |
Code Examples
The following show examples of the request followed by the response. The Python example is written for use with Python 3 and above.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.json.JSONObject;
public class BayesScaleScore {
public static void main( String[] args )
{
try
{
// Call 9
String baseURL = "https://scoring.lexile.com";
String clientId = "your_client_id";
String clientSecret = "your_client_secret";
HttpClient client = HttpClientBuilder.create().build();
HttpPost authPost = new HttpPost(baseURL + "/authToken");
JSONObject jsonInput = new JSONObject();
jsonInput.put("clientId", clientId);
jsonInput.put("clientSecret", clientSecret);
StringEntity input = new StringEntity(jsonInput.toString());
authPost.setEntity(input);
authPost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
HttpResponse response = client.execute(authPost);
StringBuilder stringBuilder = new StringBuilder();
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line;
while ((line = rd.readLine()) != null)
{
stringBuilder.append(line);
}
JSONObject json = new JSONObject(stringBuilder.toString());
String token = (String) json.get("accessToken");
Integer expires = (Integer) json.get("expiresIn");
// 1) Basic Example
HttpPost postScaleScore = new HttpPost(baseURL + "/api/score/scale/bayes");
JSONObject postData = new JSONObject();
postData.put("linkId", "mNxV");
postData.put("scaleScore", "1");
postData.put("scaleSem", 20);
postData.put("priorAbility", 200);
postData.put("priorUncertainty", 50);
postData.put("elapsedDays", 20);
StringEntity formInput = new StringEntity(postData.toString());
postScaleScore.setEntity(formInput);
postScaleScore.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + token);
postScaleScore.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
response = client.execute(postScaleScore);
stringBuilder = new StringBuilder();
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
while ((line = rd.readLine()) != null)
{
stringBuilder.append(line);
}
JSONObject output = new JSONObject(stringBuilder.toString());
Integer ability = (Integer) output.get("ability");
Integer uncertainty = (Integer) output.get("uncertainty");
String framework = (String) output.get("framework");
String apiVersion = (String) output.get("apiVersion");
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
//System.out.println(stringBuilder.toString());
# Call 9
# /authToken
import requests
import json
base_url = "https://scoring.lexile.com"
client_id = "your_client_id" # replace with your provided client ID
client_secret = "your_client_secret" # replace with your provided client secret
response = requests.post(
f"{base_url}/authToken",
data={"clientId": client_id, "clientSecret": client_secret},
)
access_token = response.json()["accessToken"] # use in Authorization header
# use these headers to make requests
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
}
# /api/score/scale/bayes
# 1) Basic Example
data = {
"priorAbility": 500,
"priorUncertainty": 100,
"elapsedDays": 15,
"linkId": "mNxV",
"scaleScore": "5",
"scaleSem": 10,
}
response = requests.post(
f"{base_url}/api/score/scale/bayes", headers=headers, json=data
)
response.json()
# returns
# {
# "ability": <int>,
# "uncertainty": <int>
# "framework": ["lexile" or "quantile"]
# "apiVersion": <string>
# }
