Skip to content

Commit 5a1bc6a

Browse files
committed
feat: introduce Grid as a new question type
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent 2c8f1dd commit 5a1bc6a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/Controller/ApiController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,6 @@ private function storeAnswersForQuestion(Form $form, $submissionId, array $quest
17041704

17051705
$answerText = '';
17061706
$uploadedFile = null;
1707-
// fixme: properly handle grid values (consider create new column)
17081707
// Are we using answer ids as values
17091708
if (in_array($question['type'], Constants::ANSWER_TYPES_PREDEFINED) && $question['type'] !== Constants::ANSWER_TYPE_LINEARSCALE) {
17101709
// Search corresponding option, skip processing if not found
@@ -1733,6 +1732,8 @@ private function storeAnswersForQuestion(Form $form, $submissionId, array $quest
17331732
$file->move($folder->getPath() . '/' . $name);
17341733

17351734
$answerText = $name;
1735+
} elseif ($question['type'] === Constants::ANSWER_TYPE_GRID) {
1736+
$answerText = json_encode($answer);
17361737
} else {
17371738
$answerText = $answer; // Not a multiple-question, answerText is given answer
17381739
}

lib/Service/SubmissionService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ public function validateSubmission(array $questions, array $answers, string $for
432432
throw new \InvalidArgumentException(sprintf('Question "%s" can only have two answers.', $question['text']));
433433
} elseif ($answersCount > 1
434434
&& $question['type'] !== Constants::ANSWER_TYPE_FILE
435-
// todo: improve this for grid, add mandatory?
436435
&& $question['type'] !== Constants::ANSWER_TYPE_GRID
437436
&& !($question['type'] === Constants::ANSWER_TYPE_DATE && isset($question['extraSettings']['dateRange'])
438437
|| $question['type'] === Constants::ANSWER_TYPE_TIME && isset($question['extraSettings']['timeRange']))) {

0 commit comments

Comments
 (0)