Update Assignment
API integration guide for students to update their assignment submission or commit to a new module
Update Assignment
A student updates their existing assignment submission with new evidence, or optionally commits to a new module in the same transaction. This is used when a student wants to revise their work before teacher assessment or after a refusal.
Summary
| Property | Value |
|---|---|
| System | Course |
| Role | Student |
| Type Key | assignment_submit |
| Build Endpoint | POST /api/v2/tx/course/student/assignment/update |
| DB Sync | Yes |
| Service Fee | 0 ADA |
| Est. Wallet Cost | ~0.33 ADA |
The estimated wallet cost breaks down as: transaction fee ~0.28 ADA + minUTxO delta ~0.05 ADA. The minUTxO increases slightly when the on-chain datum grows with updated assignment data.
Build Transaction
Endpoint
POST /api/v2/tx/course/student/assignment/update
Request Body
{
"alias": "student1",
"courseId": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
"assignmentInfo": "d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5",
"maybeNewSltHash": null,
"walletData": {
"usedAddresses": ["addr1qx2fxv..."],
"changeAddress": "addr1qx2fxv..."
}
}| Field | Type | Required | Description |
|---|---|---|---|
alias | string (Alias) | Yes | The student's access token alias. |
courseId | string (GYMintingPolicyId) | Yes | The 56-character hex course policy ID. |
assignmentInfo | string | Yes | Updated evidence hash — a hash of the student's revised work or a new reference. |
maybeNewSltHash | string (SltHash) or null | No | If provided, the student commits to a new module in addition to updating. 64-character hex hash of the target module. Pass null or omit if only updating existing evidence. |
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": "assignment_submit"
}No metadata is required. On confirmation, the state machine creates or updates the assignment commitment in the database, setting the status to ON_CHAIN. If the student committed on-chain without first saving a draft via the API, the database record is created automatically (upsert behavior).
Related API Endpoints
| Endpoint | Description |
|---|---|
GET /api/v2/courses/{course_id}/commitments | View all assignment commitments for the course, including status |
Example: Full Lifecycle
const API_URL = "https://api.andamio.io";
// 1. Build — update evidence for an existing assignment
const buildRes = await fetch(`${API_URL}/api/v2/tx/course/student/assignment/update`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
alias: "student1",
courseId: "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
assignmentInfo: "d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5",
maybeNewSltHash: null,
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: "assignment_submit",
}),
});
// 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: Commit to Assignment -- Initial assignment commitment
- Teacher: Assess Assignments -- Teacher reviews the submission