updated api

This commit is contained in:
2026-05-22 13:26:29 +02:00
parent c86372af2e
commit 52d4ef42dc
17 changed files with 867 additions and 41 deletions

View File

@ -254,7 +254,8 @@ Fields:
- `clients[].completedQuestionnaires`: array of questionnaires already completed by this client. Empty array if none.
- `clients[].completedQuestionnaires[].questionnaireID`: the questionnaire ID, matching the IDs from the questionnaire list endpoint.
- `clients[].completedQuestionnaires[].sumPoints`: total points from the last upload for this questionnaire.
- `clients[].completedQuestionnaires[].completedAt`: Unix timestamp (seconds) of when the questionnaire was completed, or `null` if not recorded.
- `clients[].completedQuestionnaires[].completedAt`: when the questionnaire was completed on the device (milliseconds), or `null`.
- `clients[].completedQuestionnaires[].uploadedAt`: when the latest version was received on the server (milliseconds), or `null`.
Common failures:
@ -368,14 +369,16 @@ Answer fields:
- `numericValue`: for numeric/range answers.
- `answeredAt`: timestamp for this answer.
Current upload behavior:
Upload behavior:
- Unknown or empty `questionID` values are skipped.
- Unknown `answerOptionKey` values are stored as no selected option for that question.
- Re-uploading the same `clientCode` and `questionID` overwrites the previous answer.
- Re-uploading the same `clientCode` and `questionnaireID` overwrites the completed questionnaire status and point sum.
- Each successful POST **appends** an immutable `questionnaire_submission` record (version increments per client + questionnaire).
- The latest answers are also written to the `client_answer` cache used by web results/CSV (always shows newest only).
- `uploadedAt` is set by the server at POST time (milliseconds); do not send it from the client.
- `completedAt` in the request is the device completion time; it is stored separately from `uploadedAt`.
- `sumPoints` is calculated from recognized `answerOptionKey` values.
- The current database stores one selected answer option per question. If the Android UI allows multiple selections for a layout, coordinate a server change before uploading multiple option keys for one question.
- Coaches may re-open, edit, and POST again; each upload creates a new submission version.
Success:
@ -384,11 +387,20 @@ Success:
"ok": true,
"data": {
"submitted": true,
"sumPoints": 0
"sumPoints": 0,
"submissionID": "sub_…",
"uploadedAt": 1714471800123,
"submissionVersion": 2
}
}
```
## Fetch Latest Answers (re-edit)
`GET /api/app_questionnaires?clientCode={code}&questionnaireID={id}&answers=1`
Returns the **latest** cached answers for a client/questionnaire in the same shape as POST `answers[]`. Use before reopening a completed questionnaire on the tablet.
Common failures:
- `400 INVALID_BODY`: request body is not valid JSON.