Skip to content

Commit 21839d4

Browse files
fix: apply review suggestions
- merge ranking into grid condition in ApiController - swap icon to IconSwapVertical - fix copyright year to 2026 - use v-else for ranked list header - simplify sort comparison in validation Signed-off-by: paul bochtler <65470117+datapumpernickel@users.noreply.github.com>
1 parent 08800d3 commit 21839d4

3 files changed

Lines changed: 5 additions & 24 deletions

File tree

lib/Controller/ApiController.php

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,23 +1720,7 @@ public function uploadFiles(int $formId, int $questionId, string $shareHash = ''
17201720
* @param string[]|array<array{uploadedFileId: string, uploadedFileName: string}> $answerArray
17211721
*/
17221722
private function storeAnswersForQuestion(Form $form, $submissionId, array $question, array $answerArray): void {
1723-
if ($question['type'] === Constants::ANSWER_TYPE_GRID) {
1724-
if (!$answerArray) {
1725-
return;
1726-
}
1727-
1728-
$answerEntity = new Answer();
1729-
$answerEntity->setSubmissionId($submissionId);
1730-
$answerEntity->setQuestionId($question['id']);
1731-
1732-
$answerText = json_encode($answerArray);
1733-
$answerEntity->setText($answerText);
1734-
$this->answerMapper->insert($answerEntity);
1735-
1736-
return;
1737-
}
1738-
1739-
if ($question['type'] === Constants::ANSWER_TYPE_RANKING) {
1723+
if ($question['type'] === Constants::ANSWER_TYPE_GRID || $question['type'] === Constants::ANSWER_TYPE_RANKING) {
17401724
if (!$answerArray) {
17411725
return;
17421726
}

lib/Service/SubmissionService.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,8 @@ public function validateSubmission(array $questions, array $answers, string $for
585585
if ($question['type'] === Constants::ANSWER_TYPE_RANKING) {
586586
$optionIds = array_map('intval', array_column($question['options'] ?? [], 'id'));
587587
$rankedIds = array_map('intval', $answers[$questionId]);
588-
$sortedRanked = $rankedIds;
589-
$sortedOptions = $optionIds;
590-
sort($sortedRanked);
591-
sort($sortedOptions);
592-
if ($sortedRanked !== $sortedOptions) {
588+
589+
if (sort($rankedIds) !== sort($optionIds)) {
593590
throw new \InvalidArgumentException(sprintf('Ranking for question "%s" must include all options exactly once.', $question['text']));
594591
}
595592
}

src/models/AnswerTypes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import IconFile from 'vue-material-design-icons/FileOutline.vue'
1212
import IconGrid from 'vue-material-design-icons/Grid.vue'
1313
import IconNumeric from 'vue-material-design-icons/Numeric.vue'
1414
import IconRadioboxMarked from 'vue-material-design-icons/RadioboxMarked.vue'
15-
import IconReorderHorizontal from 'vue-material-design-icons/ReorderHorizontal.vue'
15+
import IconSwapVertical from 'vue-material-design-icons/SwapVertical.vue'
1616
import IconTextLong from 'vue-material-design-icons/TextLong.vue'
1717
import IconTextShort from 'vue-material-design-icons/TextShort.vue'
1818
import IconLinearScale from '../components/Icons/IconLinearScale.vue'
@@ -269,7 +269,7 @@ export default {
269269

270270
ranking: {
271271
component: markRaw(QuestionRanking),
272-
icon: markRaw(IconReorderHorizontal),
272+
icon: markRaw(IconSwapVertical),
273273
label: t('forms', 'Ranking'),
274274
predefined: true,
275275
validate: (question) => question.options.length > 0,

0 commit comments

Comments
 (0)