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

@ -1,7 +1,5 @@
<?php
require_once __DIR__ . '/../lib/questionnaire_reachability.php';
$tokenRec = require_valid_token();
if ($method !== 'GET') {
@ -81,19 +79,21 @@ foreach ($clients as $c) {
$answerMap = [];
foreach ($answers as $a) $answerMap[$a['questionID']] = $a;
$reachable = qrb_reachable_question_ids($pdo, $qnID, $answerMap, $optionTextMap);
foreach ($questions as $q) {
$qid = $q['questionID'];
$header = $q['defaultText'];
if (!isset($reachable[$qid])) {
$row[$header] = '';
continue;
}
if (isset($answerMap[$qid])) {
$row[$header] = qrb_format_cell($answerMap[$qid], $optionTextMap);
$a = $answerMap[$qid];
if ($a['answerOptionID'] && isset($optionTextMap[$a['answerOptionID']])) {
$row[$q['defaultText']] = $optionTextMap[$a['answerOptionID']];
} elseif ($a['freeTextValue'] !== null && $a['freeTextValue'] !== '') {
$row[$q['defaultText']] = $a['freeTextValue'];
} elseif ($a['numericValue'] !== null) {
$row[$q['defaultText']] = $a['numericValue'];
} else {
$row[$q['defaultText']] = '';
}
} else {
$row[$header] = '';
$row[$q['defaultText']] = '';
}
}
$rows[] = $row;