Backend: Rezultati feedback forme
GitHub Issue: #246
Last modified with commit 7a580a0 on
by Aljaž.
Backend task for the Rezultati feedback forme values (POST /btc-trainings/{trainingId}/modules/{moduleNumber}/feedback) – check the Trener and Ocjena formats against the API spec and DB structure, implement, and verify against the spec.
Docs: Rezultati feedback forme
Spec: POST /btc-trainings/{trainingId}/modules/{moduleNumber}/feedback (setBtcTrainingFeedback), GET /btc-trainings/{trainingId} (getBtcTrainingDetail), BtcTrainingFeedbackRequest, BtcFeedbackGrade, BtcTrainingModule in api-docs/openapi.yaml
DB: BtcTrainingModules (Trainers, FeedbackGrade) in api/database/create_schema.sql
The page reads its data (školovanje name, 4 modules with trainers / feedbackGrade) from the
detail endpoint. This task adds only the save endpoint.
1. Double check API spec and DB structure
- Each table column maps to a field: Modul →
moduleNumber, Trener →trainers, Ocjena →feedbackGrade.nullrenders as “—”. - Ocjena range: the docs comment says it isn’t specified; Figma shows two decimals
(4,23). The spec and DB use 1–5 with two decimals (
multipleOf: 0.01,DECIMAL(3,2),CHECK BETWEEN 1 AND 5). Confirm the scale of the feedback form. - Trener: free text, several trainers in one field, max 500 characters
(
NVARCHAR(500)). Confirm the length. - Save semantics: both values are replaced;
nullclears one. The frontend must always send both. Check against the docs (one row edited at a time, “SPREMI”). - Status rule: the spec allows saving in any status (feedback is often entered after the training). Confirm.
- Roles and permissions:
btc-trainings.edit, Trainer only.
2. Implementation
- Roles and permissions: require
btc-trainings.edit→ 403. - DB: update
Trainers,FeedbackGradeandUpdatedAtof the module row found byTrainingId+ModuleNumber. - Validation → 400:
moduleNumber1–4;feedbackGradenull or 1–5 with at most two decimals;trainers≤ 500 characters (trim, empty string → null). - Unknown / deleted školovanje → 404. Response 200 with the
BtcTrainingModule.
3. Verify implementation against spec
- Route, request and response match
setBtcTrainingFeedback. - Save Modul 3 → only Modul 3 changes in
getBtcTrainingDetail. -
feedbackGrade4.235, 0.5 or 6 → 400. Bothnull→ “—” again. - Evaluator → 403. Deleted školovanje → 404.
Done when
A trainer can enter and change Trener and Ocjena for each module, and the page shows them.