From 74b8c6ab812a97a68b62a7d1f087b5c8e0f92f0e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 10 Nov 2026 10:56:19 +0100 Subject: [PATCH] feat(conditional): go to a question after date and time questions Date and time questions get the select "After question N", stored in extraSettings.next. Date and time questions of old forms (datetime) get no jumps. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- docs/DataStructure.md | 2 +- lib/Constants.php | 2 ++ src/utils/Jumps.ts | 2 ++ tests/Unit/Service/FormsServiceTest.php | 12 +++++++++++- tests/fixtures/jump-paths.json | 19 +++++++++++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/DataStructure.md b/docs/DataStructure.md index f35940868..0cffd7e75 100644 --- a/docs/DataStructure.md +++ b/docs/DataStructure.md @@ -273,7 +273,7 @@ Optional extra settings for some [Question Types](#question-types) | `questionType` | `linearscale` | String | `rating`, `promoter` | Sub type, fixed at creation; `rating` is a 1 to N scale drawn as icons, `promoter` is a 0 to 10 scale whose results show the promoter score; absent for a plain scale | | `ratingIcon` | `linearscale` with `questionType` `rating` | string | `'star', 'heart', 'thumb'` | Set the icon of the rating, default: `'star'` | | `goTo` | `dropdown, multiple_unique` | Array | see [Jumps](#jumps) | Where to go next for an answer | -| `next` | `color, file, grid, long, multiple, ranking, short` | Integer / string | question id, `'submit'` | Where to go after the question, see [Jumps](#jumps) | +| `next` | `color, date, file, grid, long, multiple, ranking, short, time` | Integer / string | question id, `'submit'` | Where to go after the question, see [Jumps](#jumps) | ### Jumps diff --git a/lib/Constants.php b/lib/Constants.php index d663d2ec9..9ee9d9137 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -235,12 +235,14 @@ class Constants { 'dateMax' => ['string', 'integer', 'NULL'], 'dateMin' => ['string', 'integer', 'NULL'], 'dateRange' => ['boolean', 'NULL'], + 'next' => ['integer', 'string'], ]; public const EXTRA_SETTINGS_TIME = [ 'timeMax' => ['string', 'NULL'], 'timeMin' => ['string', 'NULL'], 'timeRange' => ['boolean', 'NULL'], + 'next' => ['integer', 'string'], ]; // should be in sync with FileTypes.js diff --git a/src/utils/Jumps.ts b/src/utils/Jumps.ts index a9e382ef2..e72a7e6a1 100644 --- a/src/utils/Jumps.ts +++ b/src/utils/Jumps.ts @@ -18,12 +18,14 @@ export const QUESTION_TYPES_WITH_GOTO = ['dropdown', 'multiple_unique'] export const QUESTION_TYPES_WITH_NEXT = [ 'color', + 'date', 'file', 'grid', 'long', 'multiple', 'ranking', 'short', + 'time', ] /** The answer a jump belongs to: an option or the answer "Other" */ diff --git a/tests/Unit/Service/FormsServiceTest.php b/tests/Unit/Service/FormsServiceTest.php index c877c4afc..1c63589cc 100644 --- a/tests/Unit/Service/FormsServiceTest.php +++ b/tests/Unit/Service/FormsServiceTest.php @@ -1687,9 +1687,19 @@ public static function dataAreExtraSettingsValid() { 'questionType' => Constants::ANSWER_TYPE_SHORT, 'expected' => false, ], - 'jump: next not offered on date questions' => [ + 'jump: next on date questions' => [ 'extraSettings' => ['next' => 5], 'questionType' => Constants::ANSWER_TYPE_DATE, + 'expected' => true, + ], + 'jump: next on time questions' => [ + 'extraSettings' => ['next' => 'submit'], + 'questionType' => Constants::ANSWER_TYPE_TIME, + 'expected' => true, + ], + 'jump: next not offered on datetime questions' => [ + 'extraSettings' => ['next' => 5], + 'questionType' => Constants::ANSWER_TYPE_DATETIME, 'expected' => false, ], 'jump: goTo per option and Other' => [ diff --git a/tests/fixtures/jump-paths.json b/tests/fixtures/jump-paths.json index 9c47ed4d3..49de38322 100644 --- a/tests/fixtures/jump-paths.json +++ b/tests/fixtures/jump-paths.json @@ -309,6 +309,25 @@ "answers": { "1": ["11", "12"] }, "visible": [1, 3] }, + { + "name": "a time question goes to its target", + "questions": [ + { "id": 1, "type": "time", "extraSettings": { "next": 3 } }, + { "id": 2, "type": "short", "extraSettings": {} }, + { "id": 3, "type": "short", "extraSettings": {} } + ], + "answers": { "1": ["10:30"] }, + "visible": [1, 3] + }, + { + "name": "a date question goes to its target", + "questions": [ + { "id": 1, "type": "date", "extraSettings": { "next": "submit" } }, + { "id": 2, "type": "short", "extraSettings": {} } + ], + "answers": { "1": ["2026-11-10"] }, + "visible": [1] + }, { "name": "the jumps of skipped questions do not count", "questions": [