migration to mysql
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-07-10 09:57:44 +02:00
parent 351af170a0
commit 810ed24792
24 changed files with 986 additions and 208 deletions

View File

@ -180,15 +180,19 @@ if ($method === 'POST') {
$glassByParent = [];
$submittedQuestionIds = [];
$answerInsert = $pdo->prepare("
$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
");
VALUES (:cc, :qid, :aoid, :ftv, :nv, :at) '
. qdb_upsert_update(
['clientCode', 'questionID'],
[
'answerOptionID' => 'excluded.answerOptionID',
'freeTextValue' => 'excluded.freeTextValue',
'numericValue' => 'excluded.numericValue',
'answeredAt' => 'excluded.answeredAt',
]
)
);
$answerDelete = $pdo->prepare(
'DELETE FROM client_answer WHERE clientCode = :cc AND questionID = :qid'
);
@ -298,16 +302,20 @@ if ($method === 'POST') {
? qdb_compute_questionnaire_score_from_manifest($pdo, $clientCode, $submitManifest)
: qdb_compute_questionnaire_score($pdo, $clientCode, $qnID);
$pdo->prepare("
$pdo->prepare('
INSERT INTO completed_questionnaire (clientCode, questionnaireID, assignedByCoach, status, startedAt, completedAt, sumPoints)
VALUES (:cc, :qn, :abc, 'completed', :sa, :ca, :sp)
ON CONFLICT(clientCode, questionnaireID) DO UPDATE SET
assignedByCoach = excluded.assignedByCoach,
status = 'completed',
startedAt = COALESCE(excluded.startedAt, startedAt),
completedAt = excluded.completedAt,
sumPoints = excluded.sumPoints
")->execute([
VALUES (:cc, :qn, :abc, \'completed\', :sa, :ca, :sp) '
. qdb_upsert_update(
['clientCode', 'questionnaireID'],
[
'assignedByCoach' => 'excluded.assignedByCoach',
'status' => "'completed'",
'startedAt' => 'COALESCE(excluded.startedAt, startedAt)',
'completedAt' => 'excluded.completedAt',
'sumPoints' => 'excluded.sumPoints',
]
)
)->execute([
':cc' => $clientCode,
':qn' => $qnID,
':abc' => $assignedByCoach !== '' ? $assignedByCoach : null,