UX improvements in data views
This commit is contained in:
@ -38,13 +38,7 @@ $qStmt = $pdo->prepare("SELECT questionID, defaultText, type, orderIndex, config
|
||||
$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);
|
||||
$resultColumns = qdb_results_export_columns($questions, $qnID);
|
||||
|
||||
$optionTextMap = [];
|
||||
foreach ($questionIDs as $qid) {
|
||||
@ -99,10 +93,10 @@ foreach ($clients as $c) {
|
||||
$answerMap = [];
|
||||
foreach ($answers as $a) $answerMap[$a['questionID']] = $a;
|
||||
|
||||
foreach ($questions as $q) {
|
||||
$qid = $q['questionID'];
|
||||
foreach ($resultColumns as $col) {
|
||||
$qid = $col['questionID'];
|
||||
$a = $answerMap[$qid] ?? null;
|
||||
$row[$q['defaultText']] = qdb_format_client_answer_display($q, $a, $optionTextMap);
|
||||
$row[$col['header']] = qdb_results_column_cell_value($col, $a, $optionTextMap);
|
||||
}
|
||||
$rows[] = $row;
|
||||
}
|
||||
@ -126,8 +120,8 @@ if (!empty($rows)) {
|
||||
}
|
||||
} else {
|
||||
$header = ['clientCode', 'coachID', 'status', 'sumPoints', 'startedAt', 'completedAt'];
|
||||
foreach ($questions as $q) {
|
||||
$header[] = $questionColumnLabels[$q['questionID']] ?? $q['defaultText'];
|
||||
foreach ($resultColumns as $col) {
|
||||
$header[] = $col['header'];
|
||||
}
|
||||
fputcsv($out, $header);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user