showing quesiton-keys instead of ids
This commit is contained in:
@ -34,10 +34,17 @@ if (!$questionnaire) {
|
||||
json_error('NOT_FOUND', 'Questionnaire not found', 404);
|
||||
}
|
||||
|
||||
$qStmt = $pdo->prepare("SELECT questionID, defaultText, type, orderIndex FROM question WHERE questionnaireID = :id ORDER BY orderIndex");
|
||||
$qStmt = $pdo->prepare("SELECT questionID, defaultText, type, orderIndex, configJson FROM question WHERE questionnaireID = :id ORDER BY orderIndex");
|
||||
$qStmt->execute([':id' => $qnID]);
|
||||
$questions = $qStmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
$questionIDs = array_column($questions, 'questionID');
|
||||
$questionColumnLabels = [];
|
||||
foreach ($questions as &$q) {
|
||||
$cfg = json_decode($q['configJson'] ?? '{}', true) ?: [];
|
||||
$label = qdb_question_column_label($cfg, $q['defaultText'], $q['questionID'], $qnID);
|
||||
$questionColumnLabels[$q['questionID']] = $label;
|
||||
}
|
||||
unset($q);
|
||||
|
||||
$optionTextMap = [];
|
||||
foreach ($questionIDs as $qid) {
|
||||
@ -119,7 +126,9 @@ if (!empty($rows)) {
|
||||
}
|
||||
} else {
|
||||
$header = ['clientCode', 'coachID', 'status', 'sumPoints', 'startedAt', 'completedAt'];
|
||||
foreach ($questions as $q) $header[] = $q['defaultText'];
|
||||
foreach ($questions as $q) {
|
||||
$header[] = $questionColumnLabels[$q['questionID']] ?? $q['defaultText'];
|
||||
}
|
||||
fputcsv($out, $header);
|
||||
}
|
||||
fclose($out);
|
||||
|
||||
Reference in New Issue
Block a user