You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ce8a60a
Browse filesBrowse the repository at this point in the historyBrowse files
feat(section): limit jumps to the start of a section
In a form with sections, a jump goes to a later question of its own
section, to a later section or to the end of the form, as in Microsoft
Forms, so a page never starts in the middle of a section. The server
removes other jumps wherever it removes backward jumps, and inserting
a section removes the jumps that would go into its middle. The editor
offers only these targets and asks before a move turns jumps into
jumps into another section.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Copy file name to clipboardExpand all lines: docs/API_v3.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ Some requests succeed with their usual status, and their payload keeps its shape
37
37
38
38
| Key | Value | Set by | Meaning |
39
39
|-----|-------|--------|---------|
40
-
|`removed-jumps`| Inner list of question ids, e.g. `(3 7)`| Updating, reordering and copying questions; deleting options; changing the bounds of a linear scale | Jumps to the question itself or to an earlier question, jumps of the deleted option or of options that are not options of the question, or jumps for values outside the scale, were removed from the `extraSettings` of these questions, see [Jumps](DataStructure.md#jumps)|
40
+
|`removed-jumps`| Inner list of question ids, e.g. `(3 7)`| Updating, reordering and copying questions; inserting a section; deleting options; changing the bounds of a linear scale | Jumps to the question itself, to an earlier question or into the middle of another section, jumps of the deleted option or of options that are not options of the question, or jumps for values outside the scale, were removed from the `extraSettings` of these questions, see [Jumps](DataStructure.md#jumps)|
41
41
42
42
```
43
43
X-Forms-Adjusted: removed-jumps=(3 7)
@@ -64,7 +64,7 @@ When more than 100 questions lost jumps, which only a reorder can cause, `remove
64
64
65
65
### Other API changes
66
66
67
-
- Questions can jump to a later question or to the end of the form with the extra settings `goTo` (per answer, on dropdown, radio and linear scale questions) or `next` (after the question, on the other types with jumps), never both (see [Jumps](DataStructure.md#jumps)). Jumps to questions of other forms are rejected, jumps for options that are not options of the question are removed, deleting an option removes its jumps, and narrowing a linear scale removes the jumps of the values that are gone. Submissions and submission updates ignore answers to the questions the jumps skip and do not require them, the path ends at an unanswered question with a jump per answer past the following question, and an answer "Other" needs a text. Updating, reordering and copying questions removes jumps to the question itself or to an earlier question; the response header `X-Forms-Adjusted` then lists the questions concerned under `removed-jumps` (see [Adjustments by the server](#adjustments-by-the-server)). Copying or importing a form drops such jumps as well, without the header, as these create a new form.
67
+
- Questions can jump to a later question or to the end of the form with the extra settings `goTo` (per answer, on dropdown, radio and linear scale questions) or `next` (after the question, on the other types with jumps), never both (see [Jumps](DataStructure.md#jumps)). Jumps to questions of other forms are rejected, jumps for options that are not options of the question are removed, deleting an option removes its jumps, and narrowing a linear scale removes the jumps of the values that are gone. Submissions and submission updates ignore answers to the questions the jumps skip and do not require them, the path ends at an unanswered question with a jump per answer past the following question, and an answer "Other" needs a text. Updating, reordering and copying questions removes jumps to the question itself, to an earlier question or into the middle of another section; the response header `X-Forms-Adjusted` then lists the questions concerned under `removed-jumps` (see [Adjustments by the server](#adjustments-by-the-server)). Copying or importing a form drops such jumps as well, without the header, as these create a new form.
68
68
- In API version 3.0 the following endpoints were introduced/changed:
69
69
-`GET /api/v3/forms/{formId}/questions` to get all questions of a form
70
70
-`GET /api/v3/forms/{formId}/questions/{questionId}` to get a single question
@@ -276,7 +276,7 @@ Creates a clone of a form (without submissions).
276
276
| Parameter | Type | Description |
277
277
|-----------|---------|-------------|
278
278
|_formId_| Integer | ID of the form to clone |
279
-
- Response: Returns the full object of the new form. See [Request full data of a Form](#request-full-data-of-a-form). The jumps of the copied questions point at the copied questions and options; jumps whose target or option was not copied, jumps that would go to the question itself or to an earlier question, and `goTo` or `next` on a question type without it, are dropped, without the header `X-Forms-Adjusted` (see [Jumps](DataStructure.md#jumps)).
279
+
- Response: Returns the full object of the new form. See [Request full data of a Form](#request-full-data-of-a-form). The jumps of the copied questions point at the copied questions and options; jumps whose target or option was not copied, jumps that would go to the question itself, to an earlier question or into the middle of another section, and `goTo` or `next` on a question type without it, are dropped, without the header `X-Forms-Adjusted` (see [Jumps](DataStructure.md#jumps)).
280
280
281
281
```
282
282
See section 'Request full data of a form'.
@@ -396,7 +396,7 @@ Returns the questions and options of the given form (without submissions).
396
396
|_text_| String | yes |_Optional_ The text of the new question. |
397
397
|_position_| Integer | yes |_(optional)_ 1-based position to insert the new question. When omitted the question is appended at the end. |
398
398
- Restrictions: A `grid` question needs its cell type as _subtype_. A _subtype_ for a question type without sub types is rejected with **400 Bad Request**.
399
-
- Response: The new question object.
399
+
- Response: The new question object. A `section` inserted or cloned at a _position_ removes the jumps of other questions that would go into its middle (see [Jumps](DataStructure.md#jumps)), and the response header `X-Forms-Adjusted` then lists them under `removed-jumps` (see [Adjustments by the server](#adjustments-by-the-server)).
400
400
401
401
```
402
402
"data": {
@@ -473,7 +473,7 @@ Update a single or multiple properties of a question-object.
473
473
- Restrictions:
474
474
- It is **not allowed** to update one of the following key-value pairs: _id, formId, order, type_.
475
475
- The sub type `extraSettings.questionType` is fixed when the question is created. An `extraSettings` value that adds, removes or changes `questionType` is rejected with **403 Forbidden**, so send the stored `questionType` with every `extraSettings` update.
476
-
- Response: **Status-Code OK**, as well as the id of the updated question. Jumps in `extraSettings` that go to the question itself or to an earlier question, and jumps of a linear scale for values outside its bounds, are removed before saving (see [Jumps](DataStructure.md#jumps)), and the response header `X-Forms-Adjusted` then holds `removed-jumps=(<question id>)` (see [Adjustments by the server](#adjustments-by-the-server)). Jumps with an invalid structure, `goTo` or `next` on a question type without it, and ids of questions of other forms are rejected with **Status-Code Bad Request** "Invalid extraSettings, will not update." Jumps for options that are not options of the question are removed before saving, with the same header.
476
+
- Response: **Status-Code OK**, as well as the id of the updated question. Jumps in `extraSettings` that go to the question itself, to an earlier question or into the middle of another section, and jumps of a linear scale for values outside its bounds, are removed before saving (see [Jumps](DataStructure.md#jumps)), and the response header `X-Forms-Adjusted` then holds `removed-jumps=(<question id>)` (see [Adjustments by the server](#adjustments-by-the-server)). Jumps with an invalid structure, `goTo` or `next` on a question type without it, and ids of questions of other forms are rejected with **Status-Code Bad Request** "Invalid extraSettings, will not update." Jumps for options that are not options of the question are removed before saving, with the same header.
477
477
478
478
```
479
479
"data": 1
@@ -494,7 +494,7 @@ Reorders all Questions of a single form
494
494
|-----------|---------|-------------|
495
495
|_newOrder_| Array | Array of **all** Question-IDs, ordered in the desired order |
496
496
- Restrictions: The Array **must** contain all Question-IDs corresponding to the specified form and **must not** contain any duplicates.
497
-
- Response: Array of questionIDs and their corresponding order. Jumps that would go to the question itself or to an earlier question are removed (see [Jumps](DataStructure.md#jumps)): the questions concerned also carry their new `extraSettings`, and the response header `X-Forms-Adjusted` then lists their ids, e.g. `X-Forms-Adjusted: removed-jumps=(3 7)`, or holds `removed-jumps` alone for more than 100 questions (see [Adjustments by the server](#adjustments-by-the-server)).
497
+
- Response: Array of questionIDs and their corresponding order. Jumps that would go to the question itself, to an earlier question or into the middle of another section are removed (see [Jumps](DataStructure.md#jumps)): the questions concerned also carry their new `extraSettings`, and the response header `X-Forms-Adjusted` then lists their ids, e.g. `X-Forms-Adjusted: removed-jumps=(3 7)`, or holds `removed-jumps` alone for more than 100 questions (see [Adjustments by the server](#adjustments-by-the-server)).
498
498
499
499
```
500
500
"data": {
@@ -540,7 +540,7 @@ Creates a clone of a question with all its options.
540
540
| Parameter | Type | Optional | Description |
541
541
|-----------|---------|----------|-------------|
542
542
|_position_| Integer | yes |_(optional)_ 1-based position to insert the cloned question. When omitted the clone is appended at the end. |
543
-
- Response: Returns cloned question object with the new ID set. Jumps that would go to the clone itself or to an earlier question, for example when it is appended at the end, are removed from its `extraSettings` (see [Jumps](DataStructure.md#jumps)), and the response header `X-Forms-Adjusted` then holds `removed-jumps=(<clone id>)` (see [Adjustments by the server](#adjustments-by-the-server)).
543
+
- Response: Returns cloned question object with the new ID set. Jumps that would go to the clone itself, to an earlier question or into the middle of another section, for example when it is appended at the end, are removed from its `extraSettings` (see [Jumps](DataStructure.md#jumps)), and the response header `X-Forms-Adjusted` then holds `removed-jumps=(<clone id>)` (see [Adjustments by the server](#adjustments-by-the-server)).
Copy file name to clipboardExpand all lines: docs/DataStructure.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -283,6 +283,7 @@ An answer can lead to a later question or to the end of the form, as in Microsof
283
283
- A question has either jumps per answer or one jump after the question, depending on its type: `goTo` only on `dropdown`, `linearscale` and `multiple_unique`, `next` only on the other types listed above. Sending `next` on a question type with `goTo`, or `goTo` on a question type with `next`, is rejected with 400 "Invalid extraSettings". An answer without a `goTo` entry leads to the following question.
284
284
- A target is the id of a later question of the same form or `"submit"` for the end of the form, and `optionId` is the id of an option of the question. Ids of questions of other forms are rejected as invalid `extraSettings`, while ids of deleted questions of the form are accepted. Updating a question removes its jumps for option ids that are not options of the question; the response header `X-Forms-Adjusted` then holds `removed-jumps` with the id of the question.
285
285
- Jumps never go back: the server removes jumps to the question itself or to an earlier question when a question is updated, reordered or copied, and when a form is copied or imported; copying or importing a form also drops `goTo` or `next` on question types without it. Updating, reordering and copying a question still succeed with their usual status, and the payload keeps its shape: a reorder adds the new `extraSettings` of the questions concerned, and a copied question is returned with its reduced `extraSettings`. The response header `X-Forms-Adjusted` lists the questions that lost jumps, e.g. `removed-jumps=(3 7)`, see [Adjustments by the server](API_v3.md#adjustments-by-the-server).
286
+
- In a form with sections, a jump also never goes into the middle of another section: it goes to a later question of its own section, to a later section or to the end of the form. The server removes other jumps in the same cases as backward jumps, and inserting or cloning a section at a position removes the jumps of other questions that would go into its middle, with the header `X-Forms-Adjusted` listing them.
286
287
- Deleting an option removes the jumps of the question for that option; the response header `X-Forms-Adjusted` then holds `removed-jumps` with the id of the question.
287
288
- Saving a question rejects jumps with an invalid structure with 400, as any invalid `extraSettings`. Copying or importing a form keeps the jumps whose target and option it can map, and drops the others and jumps per answer with an invalid structure. The path walks ignore malformed entries.
288
289
- Only the deprecated `datetime` accepts neither `goTo` nor `next` (400).
Copy file name to clipboardExpand all lines: lib/Controller/ApiController.php
+17-6Lines changed: 17 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -539,7 +539,8 @@ public function getQuestion(int $formId, int $questionId): DataResponse {
539
539
/**
540
540
* Add a new question
541
541
*
542
-
* A clone loses its jumps to itself or to an earlier question, and the header `X-Forms-Adjusted` then holds `removed-jumps` with its id
542
+
* A clone loses its jumps to itself, to an earlier question or into the middle of another section, and the header `X-Forms-Adjusted` then holds `removed-jumps` with its id.
543
+
* A section inserted or cloned at a position removes the jumps of other questions that would go into its middle, and the header then holds `removed-jumps` with their ids.
543
544
*
544
545
* @param int $formId the form id
545
546
* @param FormsQuestionType $type the new question type
@@ -690,7 +691,7 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
$headers = self::getRemovedJumpsHeaders(array_map(staticfn (Question$changedQuestion): int => $changedQuestion->getId(), $changedQuestions));
711
+
}
712
+
}
713
+
703
714
$this->formMapper->update($form);
704
715
705
716
if (empty($response['extraSettings'])) {
@@ -713,7 +724,7 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
713
724
* Writes the given key-value pairs into Database
714
725
* Key `order` should only be changed by reorderQuestions() and is not allowed here
715
726
*
716
-
* Jumps to the question itself or to an earlier question, and jumps of a linear scale for values outside its bounds, are removed before saving, and the header `X-Forms-Adjusted` then holds `removed-jumps` with the id of the question.
727
+
* Jumps to the question itself, to an earlier question or into the middle of another section, and jumps of a linear scale for values outside its bounds, are removed before saving, and the header `X-Forms-Adjusted` then holds `removed-jumps` with the id of the question.
717
728
* Jumps for options that are not options of the question are removed as well, with the same header. Jumps to questions of other forms are rejected as invalid `extraSettings`.
718
729
*
719
730
* @param int $formId the form id
@@ -811,7 +822,7 @@ public function updateQuestion(int $formId, int $questionId, array $keyValuePair
811
822
if (FormsService::removeJumpsOutsideScale($updatedQuestion)) {
812
823
$removedJumps = true;
813
824
}
814
-
if (in_array($updatedQuestion, FormsService::removeBackwardJumps($formQuestions), true)) {
825
+
if (in_array($updatedQuestion, FormsService::removeDisallowedJumps($formQuestions), true)) {
@@ -916,7 +927,7 @@ public function deleteQuestion(int $formId, int $questionId): DataResponse {
916
927
/**
917
928
* Updates the Order of all Questions of a Form
918
929
*
919
-
* Jumps that would go to the question itself or to an earlier question are removed: the new extra settings of these questions are returned, and the header `X-Forms-Adjusted` holds `removed-jumps` with their ids, or alone for more than 100 questions
930
+
* Jumps that would go to the question itself, to an earlier question or into the middle of another section are removed: the new extra settings of these questions are returned, and the header `X-Forms-Adjusted` holds `removed-jumps` with their ids, or alone for more than 100 questions
920
931
*
921
932
* @param int $formId Id of the form to reorder
922
933
* @param list<int> $newOrder Array of Question-Ids in new order.
@@ -1001,7 +1012,7 @@ public function reorderQuestions(int $formId, array $newOrder): DataResponse {
0 commit comments