Backend: Delete assessment
GitHub Issue: #216
Last modified with commit 374306c on
by Aljaž.
Backend task for deleting an assessment (DELETE /assessments/{assessmentId}) – soft delete, check permissions and status rules, implement, and verify against the spec.
Docs: Assessment list (Actions menu → Ukloni assessment, Delete confirmation modal)
Spec: DELETE /assessments/{assessmentId} (deleteAssessment), AssessmentConflict in api-docs/openapi.yaml
DB: Assessments (DeletedAt) in api/database/create_schema.sql
1. Double check API spec and DB structure
- Soft delete (decided): the spec soft-deletes (sets
DeletedAt) and keeps candidates, board members, grades and notes. Data is kept for 2 years (see Data retention). BTC školovanje and BTC certificiranje use the same approach. - Rule: only
upcomingassessments can be deleted → 409assessment_not_upcoming. Check the docs agree. - After deleting, every assessment endpoint (detail, edit, forms, notes overviews, results) → 404, and the list excludes it.
- Roles and permissions: Trainer only (
assessments.edit). Check against the docs permission table.
2. Implementation
- Roles and permissions: require
assessments.edit→ 403. - DB: set
DeletedAt(andUpdatedAt). Make sure the shared “load assessment” helper used by the other endpoints filtersDeletedAt IS NULL. - Function + repository. Status check → 409. Unknown or already deleted id → 404. Success → 204.
3. Verify implementation against spec
- Status codes and the
errorvalue matchdeleteAssessment. - Active / past assessment → 409. Evaluator → 403. Deleting twice → 404 the second time.
- After deleting: list excludes it; detail, forms and results → 404; the rows are still in the database.
Done when
A trainer can delete an upcoming assessment, and it disappears everywhere in the app while its data stays in the database.