Andamio Logo
Protocol/Protocol V2/Transaction State Machine/Course

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

PropertyValue
SystemCourse
RoleTeacher
Type Keyassessment_assess
Build EndpointPOST /api/v2/tx/course/teacher/assignments/assess
DB SyncYes
Service Fee0 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..."
  }
}
FieldTypeRequiredDescription
aliasstring (Alias)YesThe teacher's access token alias. Must be in the course's teacher list.
courseIdstring (GYMintingPolicyId)YesThe 56-character hex course policy ID.
assignmentDecisionsAssignmentOutcome[]YesArray of decisions, one per student being assessed.
assignmentDecisions[].aliasstring (Alias)YesThe student's access token alias.
assignmentDecisions[].outcomestringYesEither "accept" or "refuse".
walletDataWalletDataNoObject 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.

EndpointDescription
GET /api/v2/courses/{course_id}/commitmentsView 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