Skip to content

Commit 532bee6

Browse files
committed
fix: export of subquestions
1 parent 6fe3275 commit 532bee6

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

lib/Db/QuestionMapper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,21 @@ public function __construct(
2828
* @throws DoesNotExistException if not found
2929
* @return Question[]
3030
*/
31-
public function findByForm(int $formId, bool $loadDeleted = false): array {
31+
public function findByForm(int $formId, bool $loadDeleted = false, bool $loadSubquestions = false): array {
3232
$qb = $this->db->getQueryBuilder();
3333

3434
$qb->select('*')
3535
->from($this->getTableName())
3636
->where(
3737
$qb->expr()->eq('form_id', $qb->createNamedParameter($formId, IQueryBuilder::PARAM_INT))
38-
)
38+
);
39+
40+
if (!$loadSubquestions) {
3941
// Only load top-level questions (not subquestions of conditional questions)
40-
->andWhere(
42+
$qb->andWhere(
4143
$qb->expr()->isNull('parent_question_id')
4244
);
45+
}
4346

4447
if (!$loadDeleted) {
4548
// Don't load questions, that are marked as deleted (marked by order==0).

lib/Service/SubmissionService.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function getSubmissionsData(Form $form, string $fileFormat, ?File $file =
227227
// Oldest first
228228
$submissionEntities = array_reverse($submissionEntities);
229229

230-
$questions = $this->questionMapper->findByForm($form->getId());
230+
$questions = $this->questionMapper->findByForm($form->getId(), false, true);
231231
$defaultTimeZone = $this->config->getSystemValueString('default_timezone', 'UTC');
232232

233233
if (!$this->currentUser) {
@@ -831,7 +831,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
831831
}
832832
}
833833
return false;
834-
835834
case Constants::ANSWER_TYPE_MULTIPLE:
836835
// Multi-select: all condition option IDs must be selected
837836
foreach ($conditions as $condition) {
@@ -847,7 +846,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
847846
return true;
848847
}
849848
return false;
850-
851849
case Constants::ANSWER_TYPE_SHORT:
852850
case Constants::ANSWER_TYPE_LONG:
853851
// Text-based: evaluate regex/string conditions
@@ -875,7 +873,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
875873
}
876874
}
877875
return false;
878-
879876
case Constants::ANSWER_TYPE_LINEARSCALE:
880877
$numValue = (float)($triggerAnswer[0] ?? 0);
881878
foreach ($conditions as $condition) {
@@ -893,7 +890,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
893890
}
894891
}
895892
return false;
896-
897893
case Constants::ANSWER_TYPE_COLOR:
898894
$colorValue = $triggerAnswer[0] ?? '';
899895
foreach ($conditions as $condition) {
@@ -902,7 +898,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
902898
}
903899
}
904900
return false;
905-
906901
case Constants::ANSWER_TYPE_FILE:
907902
$hasFile = !empty($triggerAnswer);
908903
foreach ($conditions as $condition) {
@@ -911,7 +906,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
911906
}
912907
}
913908
return false;
914-
915909
case Constants::ANSWER_TYPE_DATE:
916910
case Constants::ANSWER_TYPE_DATETIME:
917911
case Constants::ANSWER_TYPE_TIME:
@@ -942,7 +936,6 @@ private function evaluateBranchConditions(string $triggerType, array $triggerAns
942936
}
943937
}
944938
return false;
945-
946939
default:
947940
return false;
948941
}

0 commit comments

Comments
 (0)