Backend: Form – Igranje uloga – argumentacija
Last modified with commit 54c7b1e on
by TjasaSimovic.
Backend task for the optional Igranje uloga – argumentacija form (activity argumentation) – check the criterion keys, the enabled/disabled behaviour and status rule against the API spec and DB structure, implement, and verify.
Docs: Form – Igranje uloga – argumentacija
Spec: activity argumentation on /assessments/{assessmentId}/forms/{activity}, Assessment.hasArgumentation, error activity_disabled in api-docs/openapi.yaml
DB: AssessmentGrades (argumentation), Assessments.HasArgumentation in api/database/create_schema.sql
An optional shared grading form, only available when hasArgumentation is true.
1. Double check API spec and DB structure
Criterion keys for the 7 categories / 16 sub-criteria in the docs:
- Zadatak – 1
- Orijentacija prema kupcu – 4
- Društvenost / Empatija – 2
- Vještina govora i izražavanja – 2
- Posvećenost / samo-motiviranost – 1
- Tehnika i sposobnost – 3
- Pripreme i razgovor za ocjenjivanje – 3
Category keys that also appear in prvi kontakt (e.g. Zadatak) can share a key name, because keys are scoped per activity. Agree on this with the frontend.
Disabled → GET / POST return 409
activity_disabled; detail and results leave it out (or copy prvi kontakt on the results page). The docs also say “always Nije zaključeno” when disabled. Check this doesn’t conflict with leaving it out of the detail page.Turning it off during an assessment deletes its grades (see Backend: Editing existing assessment).
Roles and permissions: Trainer and Assessment evaluator, if they are active board members.
DB:
HasArgumentation BIT NOT NULL DEFAULT 0matcheshasArgumentation(required in the request).DB structure – argumentation rows can’t exist while disabled: check the schema has
UQ_Assessments_Argumentation UNIQUE (Id, HasArgumentation)on AssessmentsAssessmentGrades.ArgumentationFlag BIT NULLwithCK_AssessmentGrades_ArgumentationFlag(1 whenActivity = 'argumentation', otherwise NULL)FK_AssessmentGrades_Argumentation (AssessmentId, ArgumentationFlag) → Assessments(Id, HasArgumentation)IX_AssessmentGrades_AssessmentId (AssessmentId, ArgumentationFlag), so the FK check on aHasArgumentationupdate doesn’t scan the table
Effect: saving an argumentation grade while it’s disabled fails with 547, and setting
HasArgumentation = 0fails with 547 while argumentation rows exist. This closes the race between a board member saving the form and a trainer turning it off, without a lock.
2. Implementation
- Roles and permissions: handled by the shared form endpoint. No extra checks.
- DB / catalog: add the argumentation criteria to the catalog. Check
HasArgumentationin the forms endpoint → 409. Insert argumentation rows withArgumentationFlag = 1. A 547 on save (disabled in the meantime) → 409activity_disabled. - Status helper for this form (always
falsewhen disabled).
3. Verify implementation against spec
- Disabled assessment → 409 on GET and POST.
- Directly in the DB: inserting an argumentation row for a disabled assessment fails;
UPDATE Assessments SET HasArgumentation = 0fails while argumentation rows exist. - Enabled → status true / false cases, as for Grupna diskusija.
Done when
Argumentacija works when enabled and is blocked when disabled.