Backend: Assessment detail
GitHub Issue: #217
Last modified with commit 7a580a0 on
by Aljaž.
Backend task for the assessment detail (GET /assessments/{assessmentId}) – check the API spec and DB structure, access rules per role, the caller's activity statuses, implement, and verify against the spec.
Docs: Assessment detail
Spec: GET /assessments/{assessmentId} (getAssessmentDetail), AssessmentDetail, AssessmentActivityStatus in api-docs/openapi.yaml
DB: all assessment tables in api/database/create_schema.sql (statuses are calculated from AssessmentGrades / AssessmentNotes)
1. Double check API spec and DB structure
- Header fields in the docs (name, status, brand, date, komisija list) are in
AssessmentDetail. - Zajedničke aktivnosti → top-level
myActivities; Aktivnosti po kandidatu →candidates[].myActivities. Check that the activity lists match the docs, including when argumentation is disabled and when the caller is not a Trainer (no interview-notes). - The candidate row shows “email · partner”. The partner is on the assessment, not on the candidate. Confirm.
- Does the frontend need
canEdit/canOpenFormsflags, or can it work them out fromstatus+ permissions +myActivities? - Roles and permissions: access =
assessments.access-all, or an active board member.interview-notesonly withassessments.notes-access. Decide:- a Trainer not in the komisija: read-only (
myActivitiesisnull, no “Otvori”), as the docs recommend? - an evaluator who isn’t a member of this assessment: 403 or 404? Write both decisions into the spec.
- a Trainer not in the komisija: read-only (
- DB:
boardMemberslists only active members (DeletedAt IS NULL). Statuses are not stored. They are calculated from the caller’s rows in AssessmentGrades / AssessmentNotes.
2. Implementation
- Roles and permissions: use the shared “active board member” check and the
assessments.*permissions. - DB: load the assessment, active board members, and candidates (incl.
writtenTestGradefrom AssessmentWrittenTestGrades, left join) together with the caller’s grades and notes in as few queries as possible. - If the caller is an active board member, calculate their Zaključeno status per activity with each form’s status rule (see the Backend: Form – … tasks).
-
argumentationonly whenhasArgumentation.interview-notesonly withassessments.notes-access. - Unknown id → 404
AssessmentNotFound.
3. Verify implementation against spec
- The response matches
AssessmentDetail(nullability of bothmyActivities). - Checked with: a Trainer in the komisija, a Trainer outside it, an evaluator in it, an evaluator not in it, and a removed member.
Done when
The detail page can be fully rendered for every role, from this response only.