Assess Assignments
API integration guide for teachers to accept or refuse student assignment submissions
Assess Assignments
Teachers review student assignment submissions and record on-chain decisions to accept or refuse each one. Multiple student assessments can be batched into a single transaction.
Summary
| Property | Value |
|---|---|
| System | Course |
| Role | Teacher |
| Type Key | assessment_assess |
| Build Endpoint | POST /api/v2/tx/course/teacher/assignments/assess |
| DB Sync | Yes |
| Service Fee | 0 ADA |
| Est. Wallet Cost | ~0.21 ADA |
The estimated wallet cost is transaction fee ~0.28 ADA minus a minUTxO refund of ~0.07 ADA. The refund occurs because the on-chain datum shrinks when assessment decisions are recorded.
Build Transaction
Endpoint
POST /api/v2/tx/course/teacher/assignments/assess
Request Body
{
"alias": "teacher1",
"courseId": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
"assignmentDecisions": [
{ "alias": "student1", "outcome": "accept" },
{ "alias": "student2", "outcome": "refuse" },
{ "alias": "student3", "outcome": "accept" }
],
"walletData": {
"usedAddresses": ["addr1qx2fxv..."],
"changeAddress": "addr1qx2fxv..."
}
}| Field | Type | Required | Description |
|---|---|---|---|
alias | string (Alias) | Yes | The teacher's access token alias. Must be in the course's teacher list. |
courseId | string (GYMintingPolicyId) | Yes | The 56-character hex course policy ID. |
assignmentDecisions | AssignmentOutcome[] | Yes | Array of decisions, one per student being assessed. |
assignmentDecisions[].alias | string (Alias) | Yes | The student's access token alias. |
assignmentDecisions[].outcome | string | Yes | Either "accept" or "refuse". |
walletData | WalletData | No | Object containing usedAddresses (string[]) and changeAddress (string). |
Response
{
"unsignedTxCBOR": "84a800..."
}The response contains the unsigned transaction CBOR, ready for the user's wallet to sign.
Register Transaction
After the user signs and submits the transaction, register it with the state machine:
POST /api/v2/tx/register
{
"tx_hash": "64-char hex hash from wallet.submitTx()",
"tx_type": "assessment_assess"
}No metadata is required. On confirmation, the state machine updates each student's assignment commitment status to ACCEPTED or REFUSED in the database, matching the on-chain decisions.
Related API Endpoints
| Endpoint | Description |
|---|---|
GET /api/v2/courses/{course_id}/commitments | View pending and assessed student submissions for the course |
Example: Full Lifecycle
const API_URL = "https://api.andamio.io";
// 1. Build — assess three students in one batch
const buildRes = await fetch(`${API_URL}/api/v2/tx/course/teacher/assignments/assess`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
alias: "teacher1",
courseId: "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
assignmentDecisions: [
{ alias: "student1", outcome: "accept" },
{ alias: "student2", outcome: "refuse" },
{ alias: "student3", outcome: "accept" },
],
walletData: {
usedAddresses: [walletAddress],
changeAddress: walletAddress,
},
}),
});
const { unsignedTxCBOR } = await buildRes.json();
// 2. Sign
const signedTx = await wallet.signTx(unsignedTxCBOR);
// 3. Submit
const txHash = await wallet.submitTx(signedTx);
// 4. Register
await fetch(`${API_URL}/api/v2/tx/register`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
tx_hash: txHash,
tx_type: "assessment_assess",
}),
});
// 5. Monitor (SSE)
const events = new EventSource(
`${API_URL}/api/v2/tx/stream/${txHash}`
);
events.addEventListener("state_change", (e) => {
const data = JSON.parse(e.data);
console.log(`State: ${data.old_state} → ${data.new_state}`);
});
events.addEventListener("complete", (e) => {
const data = JSON.parse(e.data);
console.log(`Final: ${data.final_state}`);
events.close();
});See Also
- Transaction State Machine -- Lifecycle overview
- Student: Update Assignment -- Students revise and resubmit work
- Student: Claim Course Credential -- Students claim credential after all assignments are accepted