diff --git a/common.php b/common.php index 3c77624..3e98605 100644 --- a/common.php +++ b/common.php @@ -1069,6 +1069,14 @@ function qdb_glass_symptom_answer_value(?string $json, string $symptomKey): stri return trim((string)($decoded[$symptomKey] ?? '')); } +/** + * Question types that exist only for app/editor flow (no answer payload to persist). + */ +function qdb_is_non_stored_answer_question_type(string $type): bool +{ + return $type === 'last_page'; +} + /** * Flat columns for results / CSV: one column per glass-scale symptom. * @@ -1080,6 +1088,9 @@ function qdb_results_export_columns(array $questions, string $qnID): array foreach ($questions as $q) { $cfg = json_decode($q['configJson'] ?? '{}', true) ?: []; $type = $q['type'] ?? ''; + if (qdb_is_non_stored_answer_question_type($type)) { + continue; + } if ($type === 'glass_scale_question') { $symptoms = $cfg['symptoms'] ?? []; if (is_array($symptoms) && $symptoms !== []) { @@ -1368,6 +1379,9 @@ function qdb_display_questionnaire_context(PDO $pdo, string $questionnaireID): a foreach ($questions as $q) { $cfg = json_decode($q['configJson'] ?? '{}', true) ?: []; $type = $q['type'] ?? ''; + if (qdb_is_non_stored_answer_question_type($type)) { + continue; + } if ($type === 'glass_scale_question') { $symptoms = $cfg['symptoms'] ?? []; if (is_array($symptoms) && $symptoms !== []) { diff --git a/handlers/app_questionnaires.php b/handlers/app_questionnaires.php index dd7a998..aac0061 100644 --- a/handlers/app_questionnaires.php +++ b/handlers/app_questionnaires.php @@ -228,6 +228,12 @@ if ($method === 'POST') { continue; } + $qType = $shortIdToType[$shortId] ?? ''; + if (qdb_is_non_stored_answer_question_type($qType)) { + $answerDelete->execute([':cc' => $clientCode, ':qid' => $fullQID]); + continue; + } + $answerOptionID = null; $freeTextValue = isset($a['freeTextValue']) ? (string)$a['freeTextValue'] : null; $numericValue = isset($a['numericValue']) ? (float)$a['numericValue'] : null; diff --git a/lib/app_submit_validate.php b/lib/app_submit_validate.php index 84d46d5..9267a36 100644 --- a/lib/app_submit_validate.php +++ b/lib/app_submit_validate.php @@ -69,6 +69,11 @@ function qdb_validate_app_submit_payload( continue; } + $type = $shortIdToType[$shortId] ?? ''; + if (qdb_is_non_stored_answer_question_type($type)) { + continue; + } + $fullQID = $shortIdMap[$shortId]; $type = $shortIdToType[$shortId] ?? ''; $optKey = $a['answerOptionKey'] ?? null; diff --git a/lib/submissions.php b/lib/submissions.php index 4737833..edba451 100644 --- a/lib/submissions.php +++ b/lib/submissions.php @@ -47,6 +47,9 @@ function qdb_display_context_from_manifest(PDO $pdo, array $manifest): array { $cfg = json_decode($qRow['configJson'] ?? '{}', true) ?: []; $type = $qRow['type'] ?? ''; + if (qdb_is_non_stored_answer_question_type($type)) { + continue; + } if ($type === 'glass_scale_question') { $symptoms = $cfg['symptoms'] ?? $qEntry['symptoms'] ?? []; if (is_array($symptoms) && $symptoms !== []) { diff --git a/website/js/test-data.js b/website/js/test-data.js index d7a7111..d16f3bb 100644 --- a/website/js/test-data.js +++ b/website/js/test-data.js @@ -62,6 +62,7 @@ export function glassSymptomAnswerValue(raw, symptomKey) { export function buildResultColumns(questions) { const cols = []; for (const q of questions || []) { + if (q.type === 'last_page') continue; const cfg = parseQuestionConfig(q); const symptoms = cfg.symptoms; if (q.type === 'glass_scale_question' && Array.isArray(symptoms) && symptoms.length > 0) {