Revert "refactored export functionality"

This reverts commit 2616238dc8.
This commit is contained in:
2026-05-22 14:23:39 +02:00
parent 2616238dc8
commit e0be2c501f
6 changed files with 157 additions and 206 deletions

View File

@ -88,14 +88,6 @@ if ($method === 'POST') {
$pdo->beginTransaction();
// Latest cache = full replace for this questionnaire (drop answers on unreachable branches)
$pdo->prepare("
DELETE FROM client_answer
WHERE clientCode = :cc AND questionID IN (
SELECT questionID FROM question WHERE questionnaireID = :qn
)
")->execute([':cc' => $clientCode, ':qn' => $qnID]);
$sumPoints = 0;
$parsedAnswers = [];
@ -160,6 +152,11 @@ if ($method === 'POST') {
$answerInsert = $pdo->prepare("
INSERT INTO client_answer (clientCode, questionID, answerOptionID, freeTextValue, numericValue, answeredAt)
VALUES (:cc, :qid, :aoid, :ftv, :nv, :at)
ON CONFLICT(clientCode, questionID) DO UPDATE SET
answerOptionID = excluded.answerOptionID,
freeTextValue = excluded.freeTextValue,
numericValue = excluded.numericValue,
answeredAt = excluded.answeredAt
");
foreach ($parsedAnswers as $pa) {
@ -357,7 +354,7 @@ if ($fetchClients) {
'clientCode' => $code,
'completedQuestionnaires' => $completions[$code] ?? [],
];
}, array_values(array_filter($clientCodes, fn($code) => strcasecmp($code, 'DEVELOPER-SETTINGS') !== 0)));
}, $clientCodes);
qdb_discard($tmpDb, $lockFp);
json_success(['coachID' => $coachID, 'clients' => $clients]);