From b808b361efc5388fb76a32e1f1bf9711c7182874 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sat, 21 Nov 2026 16:24:37 +0100
Subject: [PATCH 01/17] feat(linearscale): add a promoter score sub type
A 0-10 scale is not always a "how likely are you to recommend"
question, and switching a scale that already has answers to 0-10
would score those answers on the wrong scale. The promoter score is
therefore a sub type of the linear scale, fixed when the question is
created and stored in extraSettings.questionType next to "Numbers"
and "Rating" in the add-question menu.
Creating a promoter score question stores the range 0 to 10, the
server rejects any other range for it, and the editor shows no range
pickers for it. Its lowest and highest values are labelled "Not at all
likely" and "Extremely likely" unless the author changes them, as
"Strongly disagree" and "Strongly agree" do not fit a likelihood.
Existing scales have no sub type and keep working as before.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
docs/API_v3.md | 3 +-
docs/DataStructure.md | 10 +--
lib/Constants.php | 10 +++
lib/Controller/ApiController.php | 3 +
lib/ResponseDefinitions.php | 2 +-
lib/Service/FormsService.php | 6 ++
openapi.json | 3 +-
playwright/support/sections/QuestionType.ts | 1 +
.../Questions/QuestionLinearScale.vue | 15 +++--
src/components/Results/ResultsSummary.vue | 14 ++++-
src/models/AnswerTypes.ts | 8 +++
src/models/Constants.ts | 24 +++++++
tests/Unit/Controller/ApiControllerTest.php | 15 ++++-
tests/Unit/Service/FormsServiceTest.php | 62 +++++++++++++++++++
14 files changed, 158 insertions(+), 18 deletions(-)
diff --git a/docs/API_v3.md b/docs/API_v3.md
index 7a1272103..604af503d 100644
--- a/docs/API_v3.md
+++ b/docs/API_v3.md
@@ -376,7 +376,7 @@ Returns the questions and options of the given form (without submissions).
| Parameter | Type | Optional | Description |
|-----------|---------|----------|-------------|
| _type_ | [QuestionType](DataStructure.md#question-types) | | The question-type of the new question |
- | _subtype_ | String | yes | _Optional_ The sub type, stored as `extraSettings.questionType`: the cell type for `grid` (`checkbox`, `number` or `radio`), `rating` for `linearscale` (a 1 to N scale drawn as icons). Any other value is rejected. |
+ | _subtype_ | String | yes | _Optional_ The sub type, stored as `extraSettings.questionType`: the cell type for `grid` (`checkbox`, `number` or `radio`), `rating` (a 1 to N scale drawn as icons) or `promoter` (a fixed 0 to 10 scale) for `linearscale`. Any other value is rejected. |
| _text_ | String | yes | _Optional_ The text of the new question. |
| _position_ | Integer | yes | _(optional)_ 1-based position to insert the new question. When omitted the question is appended at the end. |
- 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**.
@@ -457,6 +457,7 @@ Update a single or multiple properties of a question-object.
- Restrictions:
- It is **not allowed** to update one of the following key-value pairs: _id, formId, order, type_.
- 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.
+ - 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**.
- Response: **Status-Code OK**, as well as the id of the updated question.
```
diff --git a/docs/DataStructure.md b/docs/DataStructure.md
index e84c665ee..2aabc65ef 100644
--- a/docs/DataStructure.md
+++ b/docs/DataStructure.md
@@ -263,14 +263,14 @@ Optional extra settings for some [Question Types](#question-types)
| `timeMax` | `time` | string | - | Maximum allowed time to be chosen (as `HH:mm` string) |
| `timeMin` | `time` | string | - | Minimum allowed time to be chosen (as `HH:mm` string) |
| `timeRange` | `time` | Boolean | `true/false` | The time picker should query a time range |
-| `optionsLowest` | `linearscale` | Integer | `0, 1` | Set the lowest value of the scale, default: `1`; always `1` for the `rating` sub type |
-| `optionsHighest` | `linearscale` | Integer | `2, 3, 4, 5, 6, 7, 8, 9, 10` | Set the highest value of the scale, default: `5` |
-| `optionsLabelLowest` | `linearscale` | string | - | Set the label of the lowest value, default: `'Strongly disagree'`; not allowed for the `rating` sub type |
-| `optionsLabelHighest` | `linearscale` | string | - | Set the label of the highest value, default: `'Strongly agree'`; not allowed for the `rating` sub type |
+| `optionsLowest` | `linearscale` | Integer | `0, 1` | Set the lowest value of the scale, default: `1`; always `1` for the `rating` sub type, always `0` for the `promoter` sub type |
+| `optionsHighest` | `linearscale` | Integer | `2, 3, 4, 5, 6, 7, 8, 9, 10` | Set the highest value of the scale, default: `5`; always `10` for the `promoter` sub type |
+| `optionsLabelLowest` | `linearscale` | string | - | Set the label of the lowest value, default: `'Strongly disagree'`, `'Not at all likely'` for the `promoter` sub type; not allowed for the `rating` sub type |
+| `optionsLabelHighest` | `linearscale` | string | - | Set the label of the highest value, default: `'Strongly agree'`, `'Extremely likely'` for the `promoter` sub type; not allowed for the `rating` sub type |
| `columns` | `grid` | Array | - | Array of column identifiers / labels for grid questions |
| `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) |
-| `questionType` | `linearscale` | String | `rating` | Sub type, fixed at creation; `rating` is a 1 to N scale drawn as icons; absent for a plain scale |
+| `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'` |
### Option Types
diff --git a/lib/Constants.php b/lib/Constants.php
index f74d2f3be..f56977d8e 100644
--- a/lib/Constants.php
+++ b/lib/Constants.php
@@ -119,6 +119,7 @@ class Constants {
public const ANSWER_GRID_TYPE_RADIO = 'radio';
public const ANSWER_LINEARSCALE_TYPE_RATING = 'rating';
+ public const ANSWER_LINEARSCALE_TYPE_PROMOTER = 'promoter';
// Option types
public const OPTION_TYPE_CHOICE = 'choice';
@@ -267,6 +268,15 @@ class Constants {
public const EXTRA_SETTINGS_LINEARSCALE_QUESTION_TYPE = [
self::ANSWER_LINEARSCALE_TYPE_RATING,
+ self::ANSWER_LINEARSCALE_TYPE_PROMOTER,
+ ];
+
+ /**
+ * The fixed range of a linear scale with the promoter score sub type
+ */
+ public const LINEARSCALE_PROMOTER_RANGE = [
+ 'optionsLowest' => 0,
+ 'optionsHighest' => 10,
];
/**
diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php
index de5e3c44f..9b0a7c2d9 100644
--- a/lib/Controller/ApiController.php
+++ b/lib/Controller/ApiController.php
@@ -581,6 +581,9 @@ public function newQuestion(int $formId, ?string $type = null, ?string $subtype
}
$extraSettings = $subtype ? ['questionType' => $subtype] : [];
+ if ($type === Constants::ANSWER_TYPE_LINEARSCALE && $subtype === Constants::ANSWER_LINEARSCALE_TYPE_PROMOTER) {
+ $extraSettings += Constants::LINEARSCALE_PROMOTER_RANGE;
+ }
if (!$this->formsService->areExtraSettingsValid($extraSettings, $type)) {
throw new OCSBadRequestException('Invalid subtype');
}
diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php
index c50e12f15..0db8b7bd4 100644
--- a/lib/ResponseDefinitions.php
+++ b/lib/ResponseDefinitions.php
@@ -46,7 +46,7 @@
* }
*
* @psalm-type FormsQuestionType = "dropdown"|"multiple"|"multiple_unique"|"date"|"time"|"short"|"long"|"file"|"datetime"|"grid"|"linearscale"|"color"|"ranking"
- * @psalm-type FormsQuestionSubtype = "checkbox"|"number"|"radio"|"rating"
+ * @psalm-type FormsQuestionSubtype = "checkbox"|"number"|"radio"|"rating"|"promoter"
*
* @psalm-type FormsQuestion = array{
* id: int,
diff --git a/lib/Service/FormsService.php b/lib/Service/FormsService.php
index e6a8d110b..39c74a8ba 100644
--- a/lib/Service/FormsService.php
+++ b/lib/Service/FormsService.php
@@ -1061,6 +1061,12 @@ public function areExtraSettingsValid(array $extraSettings, string $questionType
return false;
}
+ if ($subtype === Constants::ANSWER_LINEARSCALE_TYPE_PROMOTER
+ && (($extraSettings['optionsLowest'] ?? null) !== Constants::LINEARSCALE_PROMOTER_RANGE['optionsLowest']
+ || ($extraSettings['optionsHighest'] ?? null) !== Constants::LINEARSCALE_PROMOTER_RANGE['optionsHighest'])) {
+ return false;
+ }
+
if (isset($extraSettings['ratingIcon'])
&& ($subtype !== Constants::ANSWER_LINEARSCALE_TYPE_RATING || !in_array($extraSettings['ratingIcon'], Constants::RATING_ICONS, true))) {
return false;
diff --git a/openapi.json b/openapi.json
index 19baa5d42..d97ee439c 100644
--- a/openapi.json
+++ b/openapi.json
@@ -612,7 +612,8 @@
"checkbox",
"number",
"radio",
- "rating"
+ "rating",
+ "promoter"
]
},
"QuestionType": {
diff --git a/playwright/support/sections/QuestionType.ts b/playwright/support/sections/QuestionType.ts
index 5d8a57b74..4ac5094bd 100644
--- a/playwright/support/sections/QuestionType.ts
+++ b/playwright/support/sections/QuestionType.ts
@@ -33,4 +33,5 @@ export enum GridSubtype {
export enum LinearScaleSubtype {
Numbers = 'Numbers',
Rating = 'Rating',
+ Promoter = 'Promoter score',
}
diff --git a/src/components/Questions/QuestionLinearScale.vue b/src/components/Questions/QuestionLinearScale.vue
index 1deafe8d7..54cd53eeb 100644
--- a/src/components/Questions/QuestionLinearScale.vue
+++ b/src/components/Questions/QuestionLinearScale.vue
@@ -11,7 +11,7 @@
:warningInvalid="answerType.warningInvalid"
:errorMessage="errorMessage"
v-on="commonListeners">
-
+
(
+ () => extraSettings.value.questionType === LinearScaleType.Promoter,
+ )
const lowest = ref<{ $refs: { input: HTMLTextAreaElement } } | null>(null)
const highest = ref<{ $refs: { input: HTMLTextAreaElement } } | null>(null)
- const defaultLowestLabel = t('forms', 'Strongly disagree')
- const defaultHighestLabel = t('forms', 'Strongly agree')
+ const { lowest: defaultLowestLabel, highest: defaultHighestLabel } =
+ getLinearScaleDefaultLabels(extraSettings.value.questionType)
const optionsLowest = computed({
get: () => {
@@ -477,6 +483,7 @@ export default defineComponent({
ratingIcons: RATING_ICONS,
ratingValue,
onRatingIconChange,
+ isPromoter,
validate,
onChange,
onOptionsLowestChange,
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index 6edc95992..4bca4bfa4 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -233,7 +233,12 @@ import { generateUrl } from '@nextcloud/router'
import { computed, defineComponent } from 'vue'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import answerTypes from '../../models/AnswerTypes.ts'
-import { GridCellType, LinearScaleType, OptionType } from '../../models/Constants.ts'
+import {
+ getLinearScaleDefaultLabels,
+ GridCellType,
+ LinearScaleType,
+ OptionType,
+} from '../../models/Constants.ts'
import { getRatingIcon } from '../../models/RatingIcons.ts'
const RATING_ICON_SIZE = 28
@@ -315,12 +320,15 @@ export default defineComponent({
}
if (props.question.type === 'linearscale') {
+ const defaultLabels = getLinearScaleDefaultLabels(
+ props.question.extraSettings?.questionType,
+ )
const labelLowest =
props.question.extraSettings?.optionsLabelLowest
- ?? t('forms', 'Strongly disagree')
+ ?? defaultLabels.lowest
const labelHighest =
props.question.extraSettings?.optionsLabelHighest
- ?? t('forms', 'Strongly agree')
+ ?? defaultLabels.highest
const optionsLowest =
props.question.extraSettings?.optionsLowest?.toString() ?? '1'
const optionsHighest =
diff --git a/src/models/AnswerTypes.ts b/src/models/AnswerTypes.ts
index c8f6b9590..d0cebc0eb 100644
--- a/src/models/AnswerTypes.ts
+++ b/src/models/AnswerTypes.ts
@@ -15,6 +15,7 @@ import IconGrid from '@material-symbols/svg-400/outlined/grid_view.svg?raw'
import IconLinearScale from '@material-symbols/svg-400/outlined/linear_scale.svg?raw'
import IconPalette from '@material-symbols/svg-400/outlined/palette.svg?raw'
import IconRadioboxMarked from '@material-symbols/svg-400/outlined/radio_button_checked.svg?raw'
+import IconRecommend from '@material-symbols/svg-400/outlined/recommend.svg?raw'
import IconClockOutline from '@material-symbols/svg-400/outlined/schedule.svg?raw'
import IconTextShort from '@material-symbols/svg-400/outlined/short_text.svg?raw'
import IconStar from '@material-symbols/svg-400/outlined/star.svg?raw'
@@ -278,6 +279,13 @@ const answerTypes: Record = {
questionType: LinearScaleType.Rating,
},
},
+ promoter: {
+ icon: IconRecommend,
+ label: t('forms', 'Promoter score'),
+ extraSettings: {
+ questionType: LinearScaleType.Promoter,
+ },
+ },
},
titlePlaceholder: t('forms', 'Linear scale question title'),
diff --git a/src/models/Constants.ts b/src/models/Constants.ts
index 5d709cd2f..ca988c0a4 100644
--- a/src/models/Constants.ts
+++ b/src/models/Constants.ts
@@ -3,6 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+import { t } from '@nextcloud/l10n'
+
/**
* Represents the state of a form.
*
@@ -46,4 +48,26 @@ export enum GridCellType {
export enum LinearScaleType {
Rating = 'rating',
+ Promoter = 'promoter',
+}
+
+/**
+ * Default labels of the lowest and the highest value of a linear scale
+ *
+ * @param questionType the sub type of the linear scale, if any
+ */
+export function getLinearScaleDefaultLabels(questionType?: string): {
+ lowest: string
+ highest: string
+} {
+ if (questionType === LinearScaleType.Promoter) {
+ return {
+ lowest: t('forms', 'Not at all likely'),
+ highest: t('forms', 'Extremely likely'),
+ }
+ }
+ return {
+ lowest: t('forms', 'Strongly disagree'),
+ highest: t('forms', 'Strongly agree'),
+ }
}
diff --git a/tests/Unit/Controller/ApiControllerTest.php b/tests/Unit/Controller/ApiControllerTest.php
index 92ed274cb..19961f113 100644
--- a/tests/Unit/Controller/ApiControllerTest.php
+++ b/tests/Unit/Controller/ApiControllerTest.php
@@ -1814,12 +1814,21 @@ public function testCloneQuestionRejectsDeletedQuestion(): void {
$this->apiController->newQuestion(1, null, null, '', 7);
}
- public function testNewQuestionRatingSubtypeStoresSubtype(): void {
+ public static function dataNewQuestionSubtype(): array {
+ return [
+ 'rating' => ['rating', ['questionType' => 'rating']],
+ 'promoter score with its fixed range' => ['promoter', ['questionType' => 'promoter', 'optionsLowest' => 0, 'optionsHighest' => 10]],
+ ];
+ }
+
+ /**
+ * @dataProvider dataNewQuestionSubtype
+ */
+ public function testNewQuestionStoresSubtype(string $subtype, array $expectedSettings): void {
$form = new Form();
$form->setId(1);
$form->setOwnerId('currentUser');
- $expectedSettings = ['questionType' => 'rating'];
$this->formsService->method('getFormIfAllowed')->with(1, Constants::PERMISSION_EDIT)->willReturn($form);
$this->formsService->method('isFormArchived')->with($form)->willReturn(false);
$this->formsService->expects($this->once())
@@ -1840,7 +1849,7 @@ public function testNewQuestionRatingSubtypeStoresSubtype(): void {
return $stored->read();
});
- $response = $this->apiController->newQuestion(1, Constants::ANSWER_TYPE_LINEARSCALE, 'rating');
+ $response = $this->apiController->newQuestion(1, Constants::ANSWER_TYPE_LINEARSCALE, $subtype);
$this->assertSame($expectedSettings, $stored->getExtraSettings());
$this->assertSame($expectedSettings, $response->getData()['extraSettings']);
diff --git a/tests/Unit/Service/FormsServiceTest.php b/tests/Unit/Service/FormsServiceTest.php
index 64fc491e5..193f5aba1 100644
--- a/tests/Unit/Service/FormsServiceTest.php
+++ b/tests/Unit/Service/FormsServiceTest.php
@@ -1990,6 +1990,68 @@ public static function dataAreExtraSettingsValid() {
'questionType' => Constants::ANSWER_TYPE_SHORT,
'expected' => false
],
+ 'promoter-linearscale' => [
+ 'extraSettings' => [
+ 'questionType' => 'promoter',
+ 'optionsLowest' => 0,
+ 'optionsHighest' => 10,
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => true
+ ],
+ 'promoter-linearscale-with-labels' => [
+ 'extraSettings' => [
+ 'questionType' => 'promoter',
+ 'optionsLowest' => 0,
+ 'optionsHighest' => 10,
+ 'optionsLabelLowest' => 'unlikely',
+ 'optionsLabelHighest' => 'likely',
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => true
+ ],
+ 'promoter-linearscale-default-range' => [
+ 'extraSettings' => [
+ 'questionType' => 'promoter',
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => false
+ ],
+ 'promoter-linearscale-1-10' => [
+ 'extraSettings' => [
+ 'questionType' => 'promoter',
+ 'optionsLowest' => 1,
+ 'optionsHighest' => 10,
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => false
+ ],
+ 'promoter-linearscale-0-9' => [
+ 'extraSettings' => [
+ 'questionType' => 'promoter',
+ 'optionsLowest' => 0,
+ 'optionsHighest' => 9,
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => false
+ ],
+ 'promoter-linearscale-range-cleared' => [
+ 'extraSettings' => [
+ 'questionType' => 'promoter',
+ 'optionsLowest' => null,
+ 'optionsHighest' => null,
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => false
+ ],
+ 'plain-linearscale-0-10' => [
+ 'extraSettings' => [
+ 'optionsLowest' => 0,
+ 'optionsHighest' => 10,
+ ],
+ 'questionType' => Constants::ANSWER_TYPE_LINEARSCALE,
+ 'expected' => true
+ ],
];
}
From 17f59e3ce3f9027ad09d828434eb28d43945d011 Mon Sep 17 00:00:00 2001
From: global-prog
Date: Sat, 21 Nov 2026 16:53:36 +0100
Subject: [PATCH 02/17] feat(results): show answer count, average, median,
minimum and maximum for scale questions
Scale questions only show a bar per value, which makes it hard to
compare two questions or two runs of the same form at a glance. The
summary now lists the number of answers, the average, the median, the
minimum and the maximum above the bars. The median sits next to the
average because, at the response counts most forms see, a single
extreme answer moves an average a long way.
The figures are formatted for the user's locale and are derived from
the per-value counts the bars already compute, so the answers are not
walked a second time. A rating keeps its own "Average rating" line
and gets no figures. No API or schema change; other question types
are unaffected.
Signed-off-by: global-prog
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 112 ++++++++++++++++++++++
1 file changed, 112 insertions(+)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index 4bca4bfa4..cc3bc01c9 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -12,6 +12,30 @@
{{ questionTypeLabel }}
+
+
+
+
- {{ t('forms', 'Answers') }}
+ - {{ formatNumber(numericStats.count) }}
+
+
+
- {{ t('forms', 'Average') }}
+ - {{ formatNumber(numericStats.mean) }}
+
+
+
- {{ t('forms', 'Median') }}
+ - {{ formatNumber(numericStats.median) }}
+
+
+
- {{ t('forms', 'Minimum') }}
+ - {{ formatNumber(numericStats.min) }}
+
+
+
- {{ t('forms', 'Maximum') }}
+ - {{ formatNumber(numericStats.max) }}
+
+
+
(() => {
+ if (props.question.type !== 'linearscale') {
+ return []
+ }
+ return questionOptions.value
+ .filter((option) => option.id !== -2)
+ .map((option) => ({
+ value: parseFloat(option.text),
+ count: option.count,
+ }))
+ .filter(({ value }) => !isNaN(value))
+ .sort((a, b) => a.value - b.value)
+ .flatMap(({ value, count }) => Array
(count).fill(value))
+ })
+
+ /**
+ * Answer count, average, median, minimum and maximum of a linear scale question;
+ * null without answers and for a rating.
+ */
+ const numericStats = computed(() => {
+ const values = numericValues.value
+ if (
+ values.length === 0
+ || props.question.extraSettings?.questionType === 'rating'
+ ) {
+ return null
+ }
+ const middle = Math.floor(values.length / 2)
+ const median =
+ values.length % 2
+ ? values[middle]
+ : (values[middle - 1] + values[middle]) / 2
+ const sum = values.reduce((a, b) => a + b, 0)
+
+ return {
+ count: values.length,
+ mean: Math.round((sum * 100) / values.length) / 100,
+ median,
+ min: values[0],
+ max: values[values.length - 1],
+ }
+ })
+
+ const numberFormat = new Intl.NumberFormat(getCanonicalLocale(), {
+ maximumFractionDigits: 2,
+ })
+
+ /**
+ * Format a number for the user's locale with at most two decimals.
+ *
+ * @param value the number to format
+ */
+ const formatNumber = (value: number): string => numberFormat.format(value)
+
return {
IconFile,
answerTypes,
+ formatNumber,
+ numericStats,
questionTypeLabel,
averageRating,
ratingSummary,
@@ -1014,4 +1098,32 @@ export default defineComponent({
}
}
}
+
+.question-summary__figures {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 16px;
+ margin: 0 0 8px;
+ padding: 0;
+
+ dt,
+ dd {
+ display: block;
+ width: auto;
+ margin: 0;
+ padding: 0;
+ white-space: normal;
+ text-align: start;
+ }
+
+ dt {
+ color: var(--color-text-maxcontrast);
+ font-size: 0.9em;
+ }
+
+ dd {
+ font-size: 1.2em;
+ font-weight: bold;
+ }
+}
From 56da5aba1764316f807460dc209615d11ad4c916 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Mon, 23 Nov 2026 00:12:41 +0100
Subject: [PATCH 03/17] fix(results): leave answers outside the scale out of
the scale figures
The figures of a linear scale counted every answer, also those outside
its current range, which remain when the lowest or highest value is
changed after answers came in. A scale from 1 to 5 could then show an
average of 9.7 and a maximum of 10. The figures now use only the
answers within the scale, as the average of a rating does; the answers
outside it still show as bars of their own.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index cc3bc01c9..138ba1ca3 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -820,15 +820,15 @@ export default defineComponent({
})
/**
- * The numeric answers given to a linear scale question in ascending order, taken from
- * the answer counts of the bars; empty for other question types.
+ * The numeric answers given to a linear scale question within its scale in ascending order,
+ * taken from the answer counts of the bars; empty for other question types.
*/
const numericValues = computed(() => {
if (props.question.type !== 'linearscale') {
return []
}
return questionOptions.value
- .filter((option) => option.id !== -2)
+ .filter((option) => option.id >= 0)
.map((option) => ({
value: parseFloat(option.text),
count: option.count,
From 89a0cbde837f7c71b5b47e9f2a0a4f4b3db7a569 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:11 +0100
Subject: [PATCH 04/17] style(results): drop an explanatory comment from the
scale figures
The template comment only restated what the markup next to it shows.
Comments in this code base document behaviour, not layout.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index 138ba1ca3..cf0ebbf9f 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -12,7 +12,6 @@
{{ questionTypeLabel }}
-
- {{ t('forms', 'Answers') }}
From 0614895a52ae993a615a1dbbd658bad55154eb13 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:12 +0100
Subject: [PATCH 05/17] refactor(results): reuse the count formatter for the
scale figures
The scale figures created their own Intl.NumberFormat per summary,
although the module already provides formatCount for the user's
locale. As the average is rounded to two decimals before formatting,
the output stays the same.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index cf0ebbf9f..2f8eb081d 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -15,23 +15,23 @@
- {{ t('forms', 'Answers') }}
- - {{ formatNumber(numericStats.count) }}
+ - {{ formatCount(numericStats.count) }}
- {{ t('forms', 'Average') }}
- - {{ formatNumber(numericStats.mean) }}
+ - {{ formatCount(numericStats.mean) }}
- {{ t('forms', 'Median') }}
- - {{ formatNumber(numericStats.median) }}
+ - {{ formatCount(numericStats.median) }}
- {{ t('forms', 'Minimum') }}
- - {{ formatNumber(numericStats.min) }}
+ - {{ formatCount(numericStats.min) }}
- {{ t('forms', 'Maximum') }}
- - {{ formatNumber(numericStats.max) }}
+ - {{ formatCount(numericStats.max) }}
@@ -865,21 +865,9 @@ export default defineComponent({
}
})
- const numberFormat = new Intl.NumberFormat(getCanonicalLocale(), {
- maximumFractionDigits: 2,
- })
-
- /**
- * Format a number for the user's locale with at most two decimals.
- *
- * @param value the number to format
- */
- const formatNumber = (value: number): string => numberFormat.format(value)
-
return {
IconFile,
answerTypes,
- formatNumber,
numericStats,
questionTypeLabel,
averageRating,
From 59b275c7a827a1aacdfca992648fc1d2ed2a9afc Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:12 +0100
Subject: [PATCH 06/17] perf(results): skip the scale figures of a rating
before collecting values
A rating shows no scale figures, yet their values were collected and
sorted first and only then discarded. The sub type is now checked
first, using the sub type constant instead of a string literal.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index 2f8eb081d..9a33e1f07 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -842,13 +842,15 @@ export default defineComponent({
* null without answers and for a rating.
*/
const numericStats = computed(() => {
- const values = numericValues.value
if (
- values.length === 0
- || props.question.extraSettings?.questionType === 'rating'
+ props.question.extraSettings?.questionType === LinearScaleType.Rating
) {
return null
}
+ const values = numericValues.value
+ if (values.length === 0) {
+ return null
+ }
const middle = Math.floor(values.length / 2)
const median =
values.length % 2
From c267af98ab96df0b3b0c6c2e14bc1ce05783d616 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:13 +0100
Subject: [PATCH 07/17] fix(results): show the average of a scale with one
decimal
The average of the scale figures showed up to two decimals, while
every other average in the results, such as the average rating, shows
one. Both now use the same one-decimal formatter.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index 9a33e1f07..5754b676e 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -19,7 +19,7 @@
- {{ t('forms', 'Average') }}
- - {{ formatCount(numericStats.mean) }}
+ - {{ oneDecimal.format(numericStats.mean) }}
- {{ t('forms', 'Median') }}
@@ -860,7 +860,7 @@ export default defineComponent({
return {
count: values.length,
- mean: Math.round((sum * 100) / values.length) / 100,
+ mean: sum / values.length,
median,
min: values[0],
max: values[values.length - 1],
@@ -883,6 +883,7 @@ export default defineComponent({
answers,
formatCount,
formatPercent,
+ oneDecimal,
t,
}
},
From 964261114354104b709ee60d28664208dd4a58d2 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:35:22 +0100
Subject: [PATCH 08/17] refactor(results): show the scale figures as cards
The figures of a scale (answers, average, median, minimum, maximum)
sat in one line with their labels so close to the values that they
were hard to read and to tell apart. Each figure is now a small card
with the label above a larger value, laid out in a grid that wraps on
narrow screens, with more room before the bars.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 33 ++++++++++++++++++-----
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index 5754b676e..80c3de56e 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -892,6 +892,7 @@ export default defineComponent({
From d944279240a38ccf208d85934d5dd900dd5ab6db Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:58 +0100
Subject: [PATCH 10/17] refactor(results): use the promoter sub type constant
The promoter score compared the sub type with a string literal, while
the other sub type checks use the LinearScaleType enum. A typo in the
literal would silently hide the score.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index e4b1fc21a..ecbf1622d 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -891,7 +891,10 @@ export default defineComponent({
* sub type and answers.
*/
const promoterBreakdown = computed(() => {
- if (props.question.extraSettings?.questionType !== 'promoter') {
+ if (
+ props.question.extraSettings?.questionType
+ !== LinearScaleType.Promoter
+ ) {
return null
}
const values = numericValues.value
From 3c165e48b034a08b75ae1a8c55cb6c50a201bbaa Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:59 +0100
Subject: [PATCH 11/17] fix(results): format the promoter shares as percentages
for the locale
The shares of promoters and detractors put a hard-coded "%" after the
number, while the per-value bars right below format their shares for
the user's locale. In German this showed "50% promoters" above
"1 (13 %)". The shares now use the same percent formatter.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index ecbf1622d..eb93ee858 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -40,10 +40,12 @@
{{
t(
'forms',
- '{promoters}% promoters, {detractors}% detractors',
+ '{promoters} promoters, {detractors} detractors',
{
- promoters: formatCount(promoterBreakdown.promoters),
- detractors: formatCount(
+ promoters: formatPercent(
+ promoterBreakdown.promoters,
+ ),
+ detractors: formatPercent(
promoterBreakdown.detractors,
),
},
From 4a46971f51338b8410a7636ec714debe167ecfdf Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:21:59 +0100
Subject: [PATCH 12/17] fix(l10n): attach the translator note to the promoter
shares
Translators need to know that {promoters} and {detractors} already
contain the percent sign. The translation tool only picks up a
TRANSLATORS comment on the line directly above the t() call, which a
template comment never is, so the text moves into a function with the
note above it.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 29 ++++++++++++++---------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index eb93ee858..af8c83ab6 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -38,17 +38,9 @@
- {{ formatCount(promoterBreakdown.score) }}
-
{{
- t(
- 'forms',
- '{promoters} promoters, {detractors} detractors',
- {
- promoters: formatPercent(
- promoterBreakdown.promoters,
- ),
- detractors: formatPercent(
- promoterBreakdown.detractors,
- ),
- },
+ formatPromoterShares(
+ promoterBreakdown.promoters,
+ promoterBreakdown.detractors,
)
}}
@@ -311,6 +303,20 @@ function formatPercent(percentage: number): string {
return percent.format(percentage / 100)
}
+/**
+ * The shares of promoters and detractors as text, e.g. "50% promoters, 25% detractors"
+ *
+ * @param promoters the share of promoters in percent
+ * @param detractors the share of detractors in percent
+ */
+function formatPromoterShares(promoters: number, detractors: number): string {
+ // TRANSLATORS {promoters} and {detractors} are percentages, e.g. "50% promoters, 25% detractors"
+ return t('forms', '{promoters} promoters, {detractors} detractors', {
+ promoters: formatPercent(promoters),
+ detractors: formatPercent(detractors),
+ })
+}
+
export default defineComponent({
name: 'ResultsSummary',
@@ -932,6 +938,7 @@ export default defineComponent({
answers,
formatCount,
formatPercent,
+ formatPromoterShares,
oneDecimal,
t,
}
From a42ee6a236e0618d123659b25b3acf1deb09d802 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sun, 22 Nov 2026 16:35:23 +0100
Subject: [PATCH 13/17] feat(results): show the promoter score as a card
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The promoter score joins the scale figures as one more card, laid out
like a dashboard figure. The label is just "Promoter score", with the
formula "(promoters − detractors)" kept for screen readers only, so it
no longer wraps. The value shows its sign ("+11", "0", "−25"), as the
score ranges from −100 to 100.
Below the value, one bar split into detractors, passives and promoters
shows the three groups at a glance in red, yellow and green, each part
sized by its number of answers, so that a group with answers always
shows; in forced colors mode the parts use system colors inside an
outline, as their backgrounds would vanish otherwise. The bar is
decorative; the line below it states the shares of all three groups, now
including the passives, which were not shown before. The score is the
share of promoters minus the share of detractors as shown, so the
numbers on the card add up. The card spans three grid columns, or the
whole row on narrow screens.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
src/components/Results/ResultsSummary.vue | 132 ++++++++++++++++++----
1 file changed, 113 insertions(+), 19 deletions(-)
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index af8c83ab6..e2d3a1272 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -33,14 +33,30 @@
- {{ t('forms', 'Maximum') }}
- {{ formatCount(numericStats.max) }}
-
-
- {{ t('forms', 'Promoter score (promoters − detractors)') }}
-
- {{ formatCount(promoterBreakdown.score) }}
+
+
-
+ {{ t('forms', 'Promoter score') }}
+
+ {{ t('forms', '(promoters − detractors)') }}
+
+
+ -
+ {{ formatScore(promoterBreakdown.score) }}
+
+ -
+
+
-
{{
formatPromoterShares(
- promoterBreakdown.promoters,
promoterBreakdown.detractors,
+ promoterBreakdown.passives,
+ promoterBreakdown.promoters,
)
}}
@@ -293,6 +309,7 @@ const oneDecimal = new Intl.NumberFormat(locale, {
maximumFractionDigits: 1,
})
const percent = new Intl.NumberFormat(locale, { style: 'percent' })
+const signedCount = new Intl.NumberFormat(locale, { signDisplay: 'exceptZero' })
/**
* Format a percentage from 0 to 100 for the user's locale
@@ -304,17 +321,39 @@ function formatPercent(percentage: number): string {
}
/**
- * The shares of promoters and detractors as text, e.g. "50% promoters, 25% detractors"
+ * The shares of detractors, passives and promoters as text, e.g. "25% detractors · 25% passives · 50% promoters"
*
- * @param promoters the share of promoters in percent
* @param detractors the share of detractors in percent
+ * @param passives the share of passives in percent
+ * @param promoters the share of promoters in percent
+ */
+function formatPromoterShares(
+ detractors: number,
+ passives: number,
+ promoters: number,
+): string {
+ // TRANSLATORS {detractors}, {passives} and {promoters} are percentages, e.g. "25% detractors · 25% passives · 50% promoters"
+ return t(
+ 'forms',
+ '{detractors} detractors · {passives} passives · {promoters} promoters',
+ {
+ detractors: formatPercent(detractors),
+ passives: formatPercent(passives),
+ promoters: formatPercent(promoters),
+ },
+ )
+}
+
+/**
+ * The promoter score with its sign, e.g. "+11", "0" or "−25"
+ *
+ * @param score the promoter score
*/
-function formatPromoterShares(promoters: number, detractors: number): string {
- // TRANSLATORS {promoters} and {detractors} are percentages, e.g. "50% promoters, 25% detractors"
- return t('forms', '{promoters} promoters, {detractors} detractors', {
- promoters: formatPercent(promoters),
- detractors: formatPercent(detractors),
- })
+function formatScore(score: number): string {
+ return signedCount
+ .formatToParts(score)
+ .map((part) => (part.type === 'minusSign' ? '−' : part.value))
+ .join('')
}
export default defineComponent({
@@ -894,9 +933,9 @@ export default defineComponent({
})
/**
- * Promoter and detractor shares in percent and the promoter score, the difference of
- * the two, using the 9-10 / 7-8 / 0-6 split. Null unless the question has the promoter
- * sub type and answers.
+ * Answers per group, detractor, passive and promoter shares in percent and the promoter
+ * score, the difference of the promoter and detractor shares, using the 9-10 / 7-8 / 0-6
+ * split. Null unless the question has the promoter sub type and answers.
*/
const promoterBreakdown = computed(() => {
if (
@@ -911,13 +950,15 @@ export default defineComponent({
}
const promoters = values.filter((value) => value >= 9).length
const detractors = values.filter((value) => value <= 6).length
+ const passives = values.length - promoters - detractors
const share = (count: number) =>
- Math.sign(count)
- * Math.round((Math.abs(count) * 100) / values.length) || 0
+ Math.round((count * 100) / values.length)
return {
+ counts: { detractors, passives, promoters },
promoters: share(promoters),
+ passives: share(passives),
detractors: share(detractors),
- score: share(promoters - detractors),
+ score: share(promoters) - share(detractors),
}
})
@@ -939,6 +980,8 @@ export default defineComponent({
formatCount,
formatPercent,
formatPromoterShares,
+ formatScore,
+ promoterGroups: ['detractors', 'passives', 'promoters'] as const,
oneDecimal,
t,
}
@@ -1156,6 +1199,10 @@ export default defineComponent({
@container (max-width: 631px) {
grid-template-columns: repeat(3, 1fr);
+
+ > div.question-summary__figures-promoter {
+ grid-column: 1 / -1;
+ }
}
@container (max-width: 375px) {
@@ -1193,10 +1240,57 @@ export default defineComponent({
font-weight: bold;
}
+ > .question-summary__figures-promoter {
+ grid-column: span 3;
+ }
+
dd.question-summary__figures-detail {
color: var(--color-text-maxcontrast);
- font-size: 0.9em;
+ font-size: var(--default-font-size);
font-weight: normal;
}
+
+ dd.question-summary__figures-split {
+ border-radius: var(--border-radius-pill);
+ display: flex;
+ gap: 2px;
+ height: calc(var(--default-grid-baseline) * 2);
+ margin-block: var(--default-grid-baseline);
+ overflow: hidden;
+
+ > span {
+ flex-basis: 0;
+ }
+ }
+
+ .question-summary__figures-split--detractors {
+ background-color: var(--color-element-error);
+ }
+
+ .question-summary__figures-split--passives {
+ background-color: var(--color-element-warning);
+ }
+
+ .question-summary__figures-split--promoters {
+ background-color: var(--color-element-success);
+ }
+
+ @media (forced-colors: active) {
+ dd.question-summary__figures-split {
+ border: 1px solid CanvasText;
+ }
+
+ .question-summary__figures-split--detractors {
+ background-color: CanvasText;
+ }
+
+ .question-summary__figures-split--passives {
+ background-color: GrayText;
+ }
+
+ .question-summary__figures-split--promoters {
+ background-color: Highlight;
+ }
+ }
}
From 5b0b8d4b0f21d519a32bea72950d13ea792dcafb Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Sat, 21 Nov 2026 16:24:59 +0100
Subject: [PATCH 14/17] test(results): cover the scale figures and the promoter
score
The figures and the promoter score are computed in the frontend only,
which has no unit tests, so end-to-end tests are their only coverage.
They check the figures above the bars of a scale question, the promoter
score of the promoter sub type, its absence on a plain 0-10 scale, the
absence of the figures on a rating, and the questions the add-question
menu creates for the "Promoter score" and "Numbers" entries, including
the default labels of a promoter score question.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
playwright/e2e/results-scale-figures.spec.ts | 243 +++++++++++++++++++
1 file changed, 243 insertions(+)
create mode 100644 playwright/e2e/results-scale-figures.spec.ts
diff --git a/playwright/e2e/results-scale-figures.spec.ts b/playwright/e2e/results-scale-figures.spec.ts
new file mode 100644
index 000000000..0b01277c0
--- /dev/null
+++ b/playwright/e2e/results-scale-figures.spec.ts
@@ -0,0 +1,243 @@
+/**
+ * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import type { APIRequestContext } from '@playwright/test'
+
+import { expect, mergeTests } from '@playwright/test'
+import { test as formTest } from '../support/fixtures/form.ts'
+import { test as appNavigationTest } from '../support/fixtures/navigation.ts'
+import { test as randomUserTest } from '../support/fixtures/random-user.ts'
+import { test as resultsTest } from '../support/fixtures/results.ts'
+import { api, waitForApiResponse } from '../support/helpers.ts'
+import {
+ LinearScaleSubtype,
+ QuestionType,
+} from '../support/sections/QuestionType.ts'
+
+const test = mergeTests(randomUserTest, appNavigationTest, formTest, resultsTest)
+
+/**
+ * Create a form with the linear scale "Recommend" and one submission per answer
+ *
+ * @param request the request context of the page
+ * @param subtype the sub type of the scale, or null for a plain scale
+ * @param extraSettings further extra settings of the scale
+ * @param answers the answers to submit, one submission each
+ */
+async function createScaleForm(
+ request: APIRequestContext,
+ subtype: string | null,
+ extraSettings: Record,
+ answers: string[] = [],
+) {
+ const form = await api(request, 'POST', '/forms')
+ await api(request, 'PATCH', `/forms/${form.id}`, {
+ keyValuePairs: { submitMultiple: true },
+ })
+ const scale = await api(request, 'POST', `/forms/${form.id}/questions`, {
+ type: 'linearscale',
+ subtype,
+ text: 'Recommend',
+ })
+ if (Object.keys(extraSettings).length > 0) {
+ await api(request, 'PATCH', `/forms/${form.id}/questions/${scale.id}`, {
+ keyValuePairs: {
+ extraSettings: { ...scale.extraSettings, ...extraSettings },
+ },
+ })
+ }
+ for (const answer of answers) {
+ await api(request, 'POST', `/forms/${form.id}/submissions`, {
+ answers: { [scale.id]: [answer] },
+ })
+ }
+ return form
+}
+
+test('Scale figures and the promoter score are shown above the bars', async ({
+ page,
+ resultsView,
+}) => {
+ const form = await createScaleForm(page.request, 'promoter', {}, [
+ '10',
+ '9',
+ '7',
+ '3',
+ ])
+ await page.goto(`apps/forms/${form.hash}/results`)
+ await page.waitForURL(/\/results\/summary$/)
+
+ const summary = resultsView.getSummaryForQuestion('Recommend')
+ await expect(
+ summary.getByText(
+ 'Linear scale (0: Not at all likely, 10: Extremely likely)',
+ { exact: true },
+ ),
+ ).toBeVisible()
+ const figure = (label: string) => summary.locator(`dt:text-is("${label}") + dd`)
+ await expect(figure('Answers')).toHaveText('4')
+ await expect(figure('Average')).toHaveText('7.3')
+ await expect(figure('Median')).toHaveText('8')
+ await expect(figure('Minimum')).toHaveText('3')
+ await expect(figure('Maximum')).toHaveText('10')
+ const promoterLabel = summary.locator('dt', { hasText: 'Promoter score' })
+ await expect(promoterLabel).toBeVisible()
+ await expect(promoterLabel.locator('.hidden-visually')).toHaveText(
+ '(promoters − detractors)',
+ )
+ await expect(promoterLabel.locator('+ dd')).toHaveText('+25')
+ await expect(
+ summary.getByText('25% detractors · 25% passives · 50% promoters'),
+ ).toBeVisible()
+ await expect(summary.locator('dl + ol meter')).not.toHaveCount(0)
+})
+
+test('The promoter score is the difference of the shares it shows', async ({
+ page,
+ resultsView,
+}) => {
+ const form = await createScaleForm(page.request, 'promoter', {}, [
+ '10',
+ '9',
+ '8',
+ '8',
+ '7',
+ '6',
+ ])
+ await page.goto(`apps/forms/${form.hash}/results`)
+ await page.waitForURL(/\/results\/summary$/)
+
+ const summary = resultsView.getSummaryForQuestion('Recommend')
+ await expect(
+ summary.getByText('17% detractors · 50% passives · 33% promoters'),
+ ).toBeVisible()
+ await expect(
+ summary.locator('dt', { hasText: 'Promoter score' }).locator('+ dd'),
+ ).toHaveText('+16')
+})
+
+test('A plain 0 to 10 scale shows no promoter score', async ({
+ page,
+ resultsView,
+}) => {
+ const form = await createScaleForm(
+ page.request,
+ null,
+ { optionsLowest: 0, optionsHighest: 10 },
+ ['10', '3'],
+ )
+ await page.goto(`apps/forms/${form.hash}/results`)
+ await page.waitForURL(/\/results\/summary$/)
+
+ const summary = resultsView.getSummaryForQuestion('Recommend')
+ await expect(summary.locator('dt:text-is("Average") + dd')).toHaveText('6.5')
+ await expect(summary.getByText(/Promoter score/)).toHaveCount(0)
+})
+
+test('The scale figures leave out answers outside the scale', async ({
+ page,
+ resultsView,
+}) => {
+ const form = await createScaleForm(page.request, null, { optionsHighest: 10 }, [
+ '2',
+ '4',
+ '9',
+ ])
+ const [scale] = (await api(page.request, 'GET', `/forms/${form.id}`)).questions
+ await api(page.request, 'PATCH', `/forms/${form.id}/questions/${scale.id}`, {
+ keyValuePairs: { extraSettings: { optionsHighest: 5 } },
+ })
+ await page.goto(`apps/forms/${form.hash}/results`)
+ await page.waitForURL(/\/results\/summary$/)
+
+ const summary = resultsView.getSummaryForQuestion('Recommend')
+ const figure = (label: string) => summary.locator(`dt:text-is("${label}") + dd`)
+ await expect(figure('Answers')).toHaveText('2')
+ await expect(figure('Average')).toHaveText('3.0')
+ await expect(figure('Maximum')).toHaveText('4')
+ await expect(summary.getByText('1 (33%): 9')).toBeVisible()
+})
+
+test('A rating shows its average rating and no scale figures', async ({
+ page,
+ resultsView,
+}) => {
+ const form = await createScaleForm(page.request, 'rating', {}, ['5', '4'])
+ await page.goto(`apps/forms/${form.hash}/results`)
+ await page.waitForURL(/\/results\/summary$/)
+
+ const summary = resultsView.getSummaryForQuestion('Recommend')
+ await expect(summary.getByText('4.5 of 5', { exact: true })).toBeVisible()
+ await expect(
+ summary.getByText('Average rating 4.5 of 5, from 2 ratings'),
+ ).toHaveCount(1)
+ await expect(summary.locator('dl')).toHaveCount(0)
+ await expect(summary.getByText(/Promoter score/)).toHaveCount(0)
+})
+
+test('A promoter score question from the menu is a fixed 0 to 10 scale', async ({
+ page,
+ appNavigation,
+ form,
+}) => {
+ await page.goto('apps/forms')
+ await appNavigation.clickNewForm()
+ await form.fillTitle('Promoter form')
+
+ const created = waitForApiResponse(page, 'POST')
+ await form.addQuestion(QuestionType.LinearScale, LinearScaleSubtype.Promoter)
+ const response = await created
+ expect(response.request().postDataJSON()).toMatchObject({
+ type: 'linearscale',
+ subtype: 'promoter',
+ })
+ expect((await response.json()).ocs.data.extraSettings).toEqual({
+ questionType: 'promoter',
+ optionsLowest: 0,
+ optionsHighest: 10,
+ })
+
+ const [question] = await form.getQuestions()
+ await expect(question.section.getByRole('radio')).toHaveCount(11)
+ await expect(question.section.getByRole('radio').first()).toHaveAccessibleName(
+ '0',
+ )
+ await expect(question.section.getByRole('radio').last()).toHaveAccessibleName(
+ '10',
+ )
+ await expect(
+ question.section.getByRole('textbox', { name: 'Label for lowest value' }),
+ ).toHaveValue('Not at all likely')
+ await expect(
+ question.section.getByRole('textbox', { name: 'Label for highest value' }),
+ ).toHaveValue('Extremely likely')
+
+ await question.openActionsMenu()
+ await expect(page.getByRole('checkbox', { name: 'Required' })).toBeVisible()
+ await expect(page.getByRole('combobox', { name: 'Lowest value' })).toHaveCount(0)
+ await expect(page.getByRole('combobox', { name: 'Highest value' })).toHaveCount(
+ 0,
+ )
+})
+
+test('A numbers question from the menu has no sub type', async ({
+ page,
+ appNavigation,
+ form,
+}) => {
+ await page.goto('apps/forms')
+ await appNavigation.clickNewForm()
+ await form.fillTitle('Numbers form')
+
+ const created = waitForApiResponse(page, 'POST')
+ await form.addQuestion(QuestionType.LinearScale, LinearScaleSubtype.Numbers)
+ const response = await created
+ expect(response.request().postDataJSON().subtype).toBeNull()
+ expect((await response.json()).ocs.data.extraSettings).toEqual({})
+
+ const [question] = await form.getQuestions()
+ await question.openActionsMenu()
+ await expect(page.getByRole('combobox', { name: 'Lowest value' })).toBeVisible()
+})
From b6a23aaf82c44f2782079048283cc982a4f11d24 Mon Sep 17 00:00:00 2001
From: Andy Scherzinger
Date: Mon, 23 Nov 2026 12:34:34 +0100
Subject: [PATCH 15/17] refactor(results): drop the minimum and maximum from
the scale figures
The lowest and highest answer add little next to the bars below, which
already show the spread of the answers. Keep the answer count, average
and median, and lay the remaining cards out in three columns.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger
---
playwright/e2e/results-scale-figures.spec.ts | 6 ++---
src/components/Results/ResultsSummary.vue | 28 ++++----------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/playwright/e2e/results-scale-figures.spec.ts b/playwright/e2e/results-scale-figures.spec.ts
index 0b01277c0..8edeb03d1 100644
--- a/playwright/e2e/results-scale-figures.spec.ts
+++ b/playwright/e2e/results-scale-figures.spec.ts
@@ -80,8 +80,8 @@ test('Scale figures and the promoter score are shown above the bars', async ({
await expect(figure('Answers')).toHaveText('4')
await expect(figure('Average')).toHaveText('7.3')
await expect(figure('Median')).toHaveText('8')
- await expect(figure('Minimum')).toHaveText('3')
- await expect(figure('Maximum')).toHaveText('10')
+ await expect(figure('Minimum')).toHaveCount(0)
+ await expect(figure('Maximum')).toHaveCount(0)
const promoterLabel = summary.locator('dt', { hasText: 'Promoter score' })
await expect(promoterLabel).toBeVisible()
await expect(promoterLabel.locator('.hidden-visually')).toHaveText(
@@ -156,7 +156,7 @@ test('The scale figures leave out answers outside the scale', async ({
const figure = (label: string) => summary.locator(`dt:text-is("${label}") + dd`)
await expect(figure('Answers')).toHaveText('2')
await expect(figure('Average')).toHaveText('3.0')
- await expect(figure('Maximum')).toHaveText('4')
+ await expect(figure('Median')).toHaveText('3')
await expect(summary.getByText('1 (33%): 9')).toBeVisible()
})
diff --git a/src/components/Results/ResultsSummary.vue b/src/components/Results/ResultsSummary.vue
index e2d3a1272..a966f1a01 100644
--- a/src/components/Results/ResultsSummary.vue
+++ b/src/components/Results/ResultsSummary.vue
@@ -25,14 +25,6 @@
- {{ t('forms', 'Median') }}
- {{ formatCount(numericStats.median) }}
-
-
- {{ t('forms', 'Minimum') }}
- - {{ formatCount(numericStats.min) }}
-
-
-
- {{ t('forms', 'Maximum') }}
- - {{ formatCount(numericStats.max) }}
-