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 e0eb191
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 the first section of a form; 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 the first section of a form; 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 where the question has a jump for "Other". 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 where the question has a jump for "Other". 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**. In a form with sections every question is in a section (see [Sections](DataStructure.md#sections)): a question or section that would add to the questions before the first section, for example a section appended below the questions of a form without sections, is rejected with **400 Bad Request** "Every question must be in a section".
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": {
@@ -474,7 +474,7 @@ Update a single or multiple properties of a question-object.
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
476
- A promoter score question (`questionType``promoter`) keeps `optionsLowest` at `0` and `optionsHighest` at `10`; send both with every `extraSettings` update, or it is rejected with **400 Bad Request**.
477
-
- 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.
477
+
- 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.
478
478
479
479
```
480
480
"data": 1
@@ -495,7 +495,7 @@ Reorders all Questions of a single form
495
495
|-----------|---------|-------------|
496
496
|_newOrder_| Array | Array of **all** Question-IDs, ordered in the desired order |
497
497
- Restrictions: The Array **must** contain all Question-IDs corresponding to the specified form and **must not** contain any duplicates. An order that puts more questions before the first section than before is rejected with **400 Bad Request** "Every question must be in a section" (see [Sections](DataStructure.md#sections)).
498
-
- 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)).
498
+
- 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)).
499
499
An id of a deleted question gets a **Not Found** response.
500
500
501
501
```
@@ -542,7 +542,7 @@ Creates a clone of a question with all its options.
542
542
| Parameter | Type | Optional | Description |
543
543
|-----------|---------|----------|-------------|
544
544
|_position_| Integer | yes |_(optional)_ 1-based position to insert the cloned question. When omitted the clone is appended at the end. |
545
-
- 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)).
545
+
- 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
@@ -293,6 +293,7 @@ An answer can lead to a later question or to the end of the form, as in Microsof
293
293
- 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.
294
294
- 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.
295
295
- 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).
296
+
- 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.
296
297
- 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.
297
298
- 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.
298
299
- Only the deprecated `datetime` accepts neither `goTo` nor `next` (400).
Copy file name to clipboardExpand all lines: lib/Controller/ApiController.php
+18-7Lines changed: 18 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -540,7 +540,8 @@ public function getQuestion(int $formId, int $questionId): DataResponse {
540
540
/**
541
541
* Add a new question
542
542
*
543
-
* 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
543
+
* 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.
544
+
* 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.
544
545
*
545
546
* @param int $formId the form id
546
547
* @param FormsQuestionType $type the new question type
@@ -694,7 +695,7 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
$headers = self::getRemovedJumpsHeaders(array_map(staticfn (Question$changedQuestion): int => $changedQuestion->getId(), $changedQuestions));
715
+
}
716
+
}
717
+
707
718
$this->formMapper->update($form);
708
719
709
720
if (empty($response['extraSettings'])) {
@@ -717,7 +728,7 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
717
728
* Writes the given key-value pairs into Database
718
729
* Key `order` should only be changed by reorderQuestions() and is not allowed here
719
730
*
720
-
* 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.
731
+
* 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.
721
732
* 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`.
722
733
*
723
734
* @param int $formId the form id
@@ -811,7 +822,7 @@ public function updateQuestion(int $formId, int $questionId, array $keyValuePair
811
822
if (JumpHelper::removeJumpsOutsideScale($updatedQuestion)) {
812
823
$removedJumps = true;
813
824
}
814
-
if (in_array($updatedQuestion, JumpHelper::removeBackwardJumps($formQuestions), true)) {
825
+
if (in_array($updatedQuestion, JumpHelper::removeDisallowedJumps($formQuestions), true)) {
@@ -917,7 +928,7 @@ public function deleteQuestion(int $formId, int $questionId): DataResponse {
917
928
/**
918
929
* Updates the Order of all Questions of a Form
919
930
*
920
-
* 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
931
+
* 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
921
932
*
922
933
* @param int $formId Id of the form to reorder
923
934
* @param list<int> $newOrder Array of Question-Ids in new order.
@@ -997,7 +1008,7 @@ public function reorderQuestions(int $formId, array $newOrder): DataResponse {
0 commit comments