Docs Guides
Quizzes and questions
Question banks, eight question types, pools, attempts and manual grading.
The model#
- A question bank is a folder. Every question lives in exactly one.
- A question is a list of immutable versions. Editing adds a version; nothing is changed in place.
- A quiz (assessment) belongs to a course draft and holds ordered items: a pinned question version, or a pool that draws N random questions from a bank.
- An attempt freezes the exact paper a learner sees, so results never change when the bank does.
Question types#
Option, item and pair ids are 1 to 32 characters of A-Z a-z 0-9 _ -, unique within the question.
| Type | body |
Graded |
|---|---|---|
SINGLE_CHOICE |
{"options":[{"id","text"}], "correctOptionId"} (2 to 10 options) |
auto |
MULTIPLE_CHOICE |
{"options":[…], "correctOptionIds":[…], "scoring":"ALL_OR_NOTHING"|"PARTIAL"} |
auto |
TRUE_FALSE |
{"correct": true} |
auto |
SHORT_TEXT |
{"acceptedAnswers":["…"], "caseSensitive": false} |
auto |
NUMERIC |
{"correct": 9.81, "tolerance": 0.05} |
auto |
ORDERING |
{"items":[{"id","text"}], "correctOrder":[ids]} |
auto |
MATCHING |
{"pairs":[{"id","left","right"}]} |
auto, partial credit per pair |
LONG_TEXT |
{"rubric":"…", "maxLength": 2000} |
by a person, always |
Create a question#
BANK_ID=7e41743a-ffa6-461a-95cb-e0760d83c476
curl -X POST "$LMS_URL/api/v1/question-banks/$BANK_ID/questions" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "SINGLE_CHOICE",
"prompt": "Where do you go when the fire alarm sounds?",
"points": 1,
"body": {
"options": [
{
"id": "a",
"text": "The nearest safe exit"
},
{
"id": "b",
"text": "Back to my desk"
}
],
"correctOptionId": "a"
}
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const bankId = "7e41743a-ffa6-461a-95cb-e0760d83c476"
const res = await fetch(`${LMS_URL}/api/v1/question-banks/${bankId}/questions`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"type": "SINGLE_CHOICE",
"prompt": "Where do you go when the fire alarm sounds?",
"points": 1,
"body": {
"options": [
{
"id": "a",
"text": "The nearest safe exit"
},
{
"id": "b",
"text": "Back to my desk"
}
],
"correctOptionId": "a"
}
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const bankId = "7e41743a-ffa6-461a-95cb-e0760d83c476"
const res = await fetch(`${LMS_URL}/api/v1/question-banks/${bankId}/questions`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"type": "SINGLE_CHOICE",
"prompt": "Where do you go when the fire alarm sounds?",
"points": 1,
"body": {
"options": [
{
"id": "a",
"text": "The nearest safe exit"
},
{
"id": "b",
"text": "Back to my desk"
}
],
"correctOptionId": "a"
}
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
bank_id = "7e41743a-ffa6-461a-95cb-e0760d83c476"
res = requests.post(f"{LMS_URL}/api/v1/question-banks/{bank_id}/questions", headers=HEADERS, json={
"type": "SINGLE_CHOICE",
"prompt": "Where do you go when the fire alarm sounds?",
"points": 1,
"body": {
"options": [
{
"id": "a",
"text": "The nearest safe exit",
},
{
"id": "b",
"text": "Back to my desk",
},
],
"correctOptionId": "a",
},
}, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
String bankId = "7e41743a-ffa6-461a-95cb-e0760d83c476";
String body = """
{
"type": "SINGLE_CHOICE",
"prompt": "Where do you go when the fire alarm sounds?",
"points": 1,
"body": {
"options": [
{
"id": "a",
"text": "The nearest safe exit"
},
{
"id": "b",
"text": "Back to my desk"
}
],
"correctOptionId": "a"
}
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/question-banks/" + bankId + "/questions"))
.header("X-API-Key", lmsKey)
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
bank_id = "7e41743a-ffa6-461a-95cb-e0760d83c476"
uri = URI("#{lms_url}/api/v1/question-banks/#{bank_id}/questions")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"type" => "SINGLE_CHOICE",
"prompt" => "Where do you go when the fire alarm sounds?",
"points" => 1,
"body" => {
"options" => [
{
"id" => "a",
"text" => "The nearest safe exit",
},
{
"id" => "b",
"text" => "Back to my desk",
},
],
"correctOptionId" => "a",
},
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$bankId = "7e41743a-ffa6-461a-95cb-e0760d83c476";
$ch = curl_init("$lmsUrl/api/v1/question-banks/{$bankId}/questions");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"type" => "SINGLE_CHOICE",
"prompt" => "Where do you go when the fire alarm sounds?",
"points" => 1,
"body" => [
"options" => [
[
"id" => "a",
"text" => "The nearest safe exit",
],
[
"id" => "b",
"text" => "Back to my desk",
],
],
"correctOptionId" => "a",
],
]),
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
bankId := "7e41743a-ffa6-461a-95cb-e0760d83c476"
body := strings.NewReader(`{
"type": "SINGLE_CHOICE",
"prompt": "Where do you go when the fire alarm sounds?",
"points": 1,
"body": {
"options": [
{
"id": "a",
"text": "The nearest safe exit"
},
{
"id": "b",
"text": "Back to my desk"
}
],
"correctOptionId": "a"
}
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/question-banks/" + bankId + "/questions", body)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Build a quiz#
Create the quiz:
COURSE_ID=ecec91e5-4eb9-4c55-98de-72dbe85cae33
curl -X POST "$LMS_URL/api/v1/courses/$COURSE_ID/draft/assessments" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Knowledge check",
"passPercent": 70,
"maxAttempts": 3,
"feedbackMode": "AFTER_ATTEMPT"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const courseId = "ecec91e5-4eb9-4c55-98de-72dbe85cae33"
const res = await fetch(`${LMS_URL}/api/v1/courses/${courseId}/draft/assessments`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"title": "Knowledge check",
"passPercent": 70,
"maxAttempts": 3,
"feedbackMode": "AFTER_ATTEMPT"
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const courseId = "ecec91e5-4eb9-4c55-98de-72dbe85cae33"
const res = await fetch(`${LMS_URL}/api/v1/courses/${courseId}/draft/assessments`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"title": "Knowledge check",
"passPercent": 70,
"maxAttempts": 3,
"feedbackMode": "AFTER_ATTEMPT"
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
course_id = "ecec91e5-4eb9-4c55-98de-72dbe85cae33"
res = requests.post(f"{LMS_URL}/api/v1/courses/{course_id}/draft/assessments", headers=HEADERS, json={
"title": "Knowledge check",
"passPercent": 70,
"maxAttempts": 3,
"feedbackMode": "AFTER_ATTEMPT",
}, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
String courseId = "ecec91e5-4eb9-4c55-98de-72dbe85cae33";
String body = """
{
"title": "Knowledge check",
"passPercent": 70,
"maxAttempts": 3,
"feedbackMode": "AFTER_ATTEMPT"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/courses/" + courseId + "/draft/assessments"))
.header("X-API-Key", lmsKey)
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
course_id = "ecec91e5-4eb9-4c55-98de-72dbe85cae33"
uri = URI("#{lms_url}/api/v1/courses/#{course_id}/draft/assessments")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"title" => "Knowledge check",
"passPercent" => 70,
"maxAttempts" => 3,
"feedbackMode" => "AFTER_ATTEMPT",
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$courseId = "ecec91e5-4eb9-4c55-98de-72dbe85cae33";
$ch = curl_init("$lmsUrl/api/v1/courses/{$courseId}/draft/assessments");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"title" => "Knowledge check",
"passPercent" => 70,
"maxAttempts" => 3,
"feedbackMode" => "AFTER_ATTEMPT",
]),
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
courseId := "ecec91e5-4eb9-4c55-98de-72dbe85cae33"
body := strings.NewReader(`{
"title": "Knowledge check",
"passPercent": 70,
"maxAttempts": 3,
"feedbackMode": "AFTER_ATTEMPT"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/courses/" + courseId + "/draft/assessments", body)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Add a question (this pins its latest version):
QUIZ_ID=a5ed7659-513d-4489-950f-3bda0fe05b1f
curl -X POST "$LMS_URL/api/v1/assessments/$QUIZ_ID/items" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"questionId": "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64"
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
const res = await fetch(`${LMS_URL}/api/v1/assessments/${quizId}/items`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"questionId": "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64"
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
const res = await fetch(`${LMS_URL}/api/v1/assessments/${quizId}/items`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"questionId": "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64"
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
quiz_id = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
res = requests.post(f"{LMS_URL}/api/v1/assessments/{quiz_id}/items", headers=HEADERS, json={
"questionId": "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64",
}, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
String quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f";
String body = """
{
"questionId": "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64"
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/assessments/" + quizId + "/items"))
.header("X-API-Key", lmsKey)
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
quiz_id = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
uri = URI("#{lms_url}/api/v1/assessments/#{quiz_id}/items")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"questionId" => "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64",
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f";
$ch = curl_init("$lmsUrl/api/v1/assessments/{$quizId}/items");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"questionId" => "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64",
]),
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
quizId := "a5ed7659-513d-4489-950f-3bda0fe05b1f"
body := strings.NewReader(`{
"questionId": "9d3b6e21-4a85-4f17-b0c2-7e5a1d8f3b64"
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/assessments/" + quizId + "/items", body)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Or draw 5 random questions from a bank, 2 points each:
QUIZ_ID=a5ed7659-513d-4489-950f-3bda0fe05b1f
curl -X POST "$LMS_URL/api/v1/assessments/$QUIZ_ID/items" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"poolBankId": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount": 5,
"pointsOverride": 2
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
const res = await fetch(`${LMS_URL}/api/v1/assessments/${quizId}/items`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"poolBankId": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount": 5,
"pointsOverride": 2
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
const res = await fetch(`${LMS_URL}/api/v1/assessments/${quizId}/items`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"poolBankId": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount": 5,
"pointsOverride": 2
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
quiz_id = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
res = requests.post(f"{LMS_URL}/api/v1/assessments/{quiz_id}/items", headers=HEADERS, json={
"poolBankId": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount": 5,
"pointsOverride": 2,
}, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
String quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f";
String body = """
{
"poolBankId": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount": 5,
"pointsOverride": 2
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/assessments/" + quizId + "/items"))
.header("X-API-Key", lmsKey)
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
quiz_id = "a5ed7659-513d-4489-950f-3bda0fe05b1f"
uri = URI("#{lms_url}/api/v1/assessments/#{quiz_id}/items")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"poolBankId" => "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount" => 5,
"pointsOverride" => 2,
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$quizId = "a5ed7659-513d-4489-950f-3bda0fe05b1f";
$ch = curl_init("$lmsUrl/api/v1/assessments/{$quizId}/items");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"poolBankId" => "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount" => 5,
"pointsOverride" => 2,
]),
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
quizId := "a5ed7659-513d-4489-950f-3bda0fe05b1f"
body := strings.NewReader(`{
"poolBankId": "7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
"poolDrawCount": 5,
"pointsOverride": 2
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/assessments/" + quizId + "/items", body)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Send exactly one of questionId, questionVersionId or poolBankId.
Editing questions safely#
Posting a new version never changes a quiz that already uses the question. Choose to adopt it with POST /assessment-items/{id}/upgrade, usually in a new draft.
Taking a quiz#
POST /me/enrollments/{e}/assessments/{a}/attemptsstarts (or resumes) an attempt. Questions arrive without the answer key.PUT …/attempts/{id}/answersautosaves.POST …/attempts/{id}/submitgrades.
Answer shapes:
| Type | Response |
|---|---|
SINGLE_CHOICE |
{"optionId": "b"} |
MULTIPLE_CHOICE |
{"optionIds": ["a","c"]} |
TRUE_FALSE |
{"value": true} |
SHORT_TEXT |
{"text": "torque"} |
NUMERIC |
{"value": 9.81} |
ORDERING |
{"order": ["2","3","1"]} |
MATCHING |
{"matches": [{"pairId":"p1","rightId":"p1"}]} |
LONG_TEXT |
{"text": "…"} |
Rules#
passedis score percent ≥passPercent. Passing completes any lesson that requires it.maxAttemptscounts from start. Once passed, no further attempts.- Time limits: answers can’t be saved after the deadline (30 seconds of grace); the attempt is graded on what was saved.
feedbackMode:NEVER,AFTER_ATTEMPT, orAFTER_PASScontrols when learners see results and the key.
Manual grading#
An attempt with essay questions becomes NEEDS_GRADING and shows the learner no score yet. Staff work the queue:
See what is waiting:
curl -X GET "$LMS_URL/api/v1/grading/queue" \
-H "X-API-Key: $LMS_KEY"const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const res = await fetch(`${LMS_URL}/api/v1/grading/queue`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const res = await fetch(`${LMS_URL}/api/v1/grading/queue`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
res = requests.get(f"{LMS_URL}/api/v1/grading/queue", headers=HEADERS, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/grading/queue"))
.header("X-API-Key", lmsKey)
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
uri = URI("#{lms_url}/api/v1/grading/queue")
request = Net::HTTP::Get.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"))
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$ch = curl_init("$lmsUrl/api/v1/grading/queue");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY')],
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", os.Getenv("LMS_URL") + "/api/v1/grading/queue", nil)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Open one attempt (answers, the key and the rubric):
ATTEMPT_ID=ca174553-d8b0-4963-97c9-54203cea1ed5
curl -X GET "$LMS_URL/api/v1/attempts/$ATTEMPT_ID" \
-H "X-API-Key: $LMS_KEY"const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5"
const res = await fetch(`${LMS_URL}/api/v1/attempts/${attemptId}`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5"
const res = await fetch(`${LMS_URL}/api/v1/attempts/${attemptId}`, {
method: 'GET',
headers: { "X-API-Key": LMS_KEY },
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
attempt_id = "ca174553-d8b0-4963-97c9-54203cea1ed5"
res = requests.get(f"{LMS_URL}/api/v1/attempts/{attempt_id}", headers=HEADERS, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
String attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/attempts/" + attemptId))
.header("X-API-Key", lmsKey)
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
attempt_id = "ca174553-d8b0-4963-97c9-54203cea1ed5"
uri = URI("#{lms_url}/api/v1/attempts/#{attempt_id}")
request = Net::HTTP::Get.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"))
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5";
$ch = curl_init("$lmsUrl/api/v1/attempts/{$attemptId}");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY')],
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
attemptId := "ca174553-d8b0-4963-97c9-54203cea1ed5"
req, _ := http.NewRequest("GET", os.Getenv("LMS_URL") + "/api/v1/attempts/" + attemptId, nil)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Mark it:
ATTEMPT_ID=ca174553-d8b0-4963-97c9-54203cea1ed5
curl -X POST "$LMS_URL/api/v1/attempts/$ATTEMPT_ID/grade" \
-H "X-API-Key: $LMS_KEY" \
-H "Content-Type: application/json" \
-d '{
"grades": [
{
"attemptQuestionId": "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded": 4,
"feedback": "Good."
}
]
}'const LMS_URL = process.env.LMS_URL
const LMS_KEY = process.env.LMS_KEY
const attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5"
const res = await fetch(`${LMS_URL}/api/v1/attempts/${attemptId}/grade`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"grades": [
{
"attemptQuestionId": "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded": 4,
"feedback": "Good."
}
]
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data = await res.json()const LMS_URL = process.env.LMS_URL!
const LMS_KEY = process.env.LMS_KEY!
const attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5"
const res = await fetch(`${LMS_URL}/api/v1/attempts/${attemptId}/grade`, {
method: 'POST',
headers: { "X-API-Key": LMS_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"grades": [
{
"attemptQuestionId": "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded": 4,
"feedback": "Good."
}
]
}),
})
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`)
const data: unknown = await res.json()import os
import requests
LMS_URL = os.environ["LMS_URL"]
HEADERS = {"X-API-Key": os.environ["LMS_KEY"]}
attempt_id = "ca174553-d8b0-4963-97c9-54203cea1ed5"
res = requests.post(f"{LMS_URL}/api/v1/attempts/{attempt_id}/grade", headers=HEADERS, json={
"grades": [
{
"attemptQuestionId": "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded": 4,
"feedback": "Good.",
},
],
}, timeout=10)
res.raise_for_status()
data = res.json()import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
String lmsUrl = System.getenv("LMS_URL");
String lmsKey = System.getenv("LMS_KEY");
String attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5";
String body = """
{
"grades": [
{
"attemptQuestionId": "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded": 4,
"feedback": "Good."
}
]
}
""";
var request = HttpRequest.newBuilder(URI.create(lmsUrl + "/api/v1/attempts/" + attemptId + "/grade"))
.header("X-API-Key", lmsKey)
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) throw new IllegalStateException(response.statusCode() + " " + response.body());
System.out.println(response.body());
}
}require "net/http"
require "json"
lms_url = ENV.fetch("LMS_URL")
attempt_id = "ca174553-d8b0-4963-97c9-54203cea1ed5"
uri = URI("#{lms_url}/api/v1/attempts/#{attempt_id}/grade")
request = Net::HTTP::Post.new(uri, "X-API-Key" => ENV.fetch("LMS_KEY"), "Content-Type" => "application/json")
request.body = {
"grades" => [
{
"attemptQuestionId" => "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded" => 4,
"feedback" => "Good.",
},
],
}.to_json
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
raise "#{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)<?php
$lmsUrl = getenv('LMS_URL');
$attemptId = "ca174553-d8b0-4963-97c9-54203cea1ed5";
$ch = curl_init("$lmsUrl/api/v1/attempts/{$attemptId}/grade");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('LMS_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
"grades" => [
[
"attemptQuestionId" => "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded" => 4,
"feedback" => "Good.",
],
],
]),
]);
$response = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 300) {
throw new RuntimeException($response);
}
$data = json_decode($response, true);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
attemptId := "ca174553-d8b0-4963-97c9-54203cea1ed5"
body := strings.NewReader(`{
"grades": [
{
"attemptQuestionId": "c4a1f2e8-6b3d-4e97-a5c0-1d8e7f2b9a63",
"pointsAwarded": 4,
"feedback": "Good."
}
]
}`)
req, _ := http.NewRequest("POST", os.Getenv("LMS_URL") + "/api/v1/attempts/" + attemptId + "/grade", body)
req.Header.Set("X-API-Key", os.Getenv("LMS_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 300 {
panic(fmt.Sprintf("%d %s", res.StatusCode, data))
}
fmt.Println(string(data))
}