Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/DataStructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Optional extra settings for some [Question Types](#question-types)
| `rows` | `grid` | Array | - | Array of row identifiers / labels for grid questions |
| `questionType` | `grid` | String | `checkbox`, `number`, `radio` | Type of cell for grid questions (checkbox, numeric input, or radio) |
| `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

Expand Down
2 changes: 2 additions & 0 deletions lib/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,14 @@ class Constants {

public const QUESTION_TYPES_WITH_NEXT = [
self::ANSWER_TYPE_COLOR,
self::ANSWER_TYPE_DATE,
self::ANSWER_TYPE_FILE,
self::ANSWER_TYPE_GRID,
self::ANSWER_TYPE_LONG,
self::ANSWER_TYPE_MULTIPLE,
self::ANSWER_TYPE_RANKING,
self::ANSWER_TYPE_SHORT,
self::ANSWER_TYPE_TIME,
];

public const EXTRA_SETTINGS_GRID_QUESTION_TYPE = [
Expand Down
2 changes: 2 additions & 0 deletions src/utils/Jumps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,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" */
Expand Down
12 changes: 11 additions & 1 deletion tests/Unit/Service/FormsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
19 changes: 19 additions & 0 deletions tests/fixtures/jump-paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,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": [
Expand Down
Loading