Skip to content

feat(results): average, median, range and promoter score for scale questions - #3635

Open
global-prog wants to merge 11 commits into
nextcloud:mainfrom
global-prog:contrib/response-statistics
Open

global-prog wants to merge 11 commits into
nextcloud:mainfrom
global-prog:contrib/response-statistics

Conversation

@global-prog

@global-prog global-prog commented Sep 9, 2026 •

Copy link
Copy Markdown

Summary

Scale questions currently show a bar per value, which makes it hard to compare two questions, or two runs of the same form, at a glance.

This adds a small set of figures above the existing bars for linearscale questions:

  • number of answers, average, median, minimum, maximum, formatted for the user's locale
  • for a 0–10 scale with the promoter score switched on, a promoter score (promoters − detractors) with its promoter and detractor shares (the usual 9–10 / 7–8 / 0–6 split)

The median sits next to the average deliberately — at the response counts most forms see, one extreme answer moves an average a long way, and showing both makes that visible.

The promoter score is labelled by its calculation rather than as "Net Promoter Score", because "Net Promoter" and "NPS" are registered trademarks of Bain & Company, NICE Systems and Fred Reichheld.

Scope

  • the figures are shown above the existing per-value bars; questions of other types render as before
  • the promoter score is opt-in: a new showPromoterScore extra setting on linear scale questions, switched on in the question's menu ("Promoter score (0 to 10 scale)"). It can be switched on for a 0–10 scale only, which then locks the range, and switching it never changes the range itself; the server rejects the setting on any other range. Existing questions don't have the setting, so they never show a promoter score until it is switched on
  • openapi.json and docs/DataStructure.md list the new setting; no schema change, no migration

Testing

  • npm run lint, npm run stylelint and the build are clean; vue-tsc shows no new errors
  • PHP unit tests for the showPromoterScore validation; Playwright spec playwright/e2e/results-scale-figures.spec.ts
  • checked on NC 36: figures above the bars at 1280 and 320 px in light and dark theme, axe clean on the summary, the editor toggle locks the range at once

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@global-prog
global-prog force-pushed the contrib/response-statistics branch from 4f0ebc9 to 6eedc91 Compare September 9, 2026 00:58
@Chartman123

Copy link
Copy Markdown
Collaborator

@global-prog Thanks for your contribution. As said in the other PR: please create an issue/feature request before starting implentation to discuss it. Also please add screenshots to the description with before/after. This should also be added to the new rating quetions in #3637.

Also please add the AI declaration to your description if you used AI for this.

@Chartman123 Chartman123 added this to the 5.5 milestone Sep 11, 2026
@global-prog

Copy link
Copy Markdown
Author

Thanks, noted on opening an issue first. I'll add before/after screenshots to the description. The AI declaration is added there as well.

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

…or scale questions

Scale questions currently show only a bar per value, which makes it hard to compare
two questions or two runs of the same form at a glance.

This adds count, average, median, lowest and highest above the existing bars. The
median is shown next to the average deliberately: at the response counts most forms
see, a single extreme answer moves an average a long way.

A 0-10 scale additionally reports a Net Promoter Score with its promoter and detractor
shares, using the usual 9-10 / 7-8 / 0-6 split, since that is the shape those scales
are almost always used for.

Purely additive and presentational: no API change, no schema change, and questions of
other types are unaffected.

Signed-off-by: global-prog <raqeeb@uosamarra.edu.iq>
@AndyScherzinger
AndyScherzinger force-pushed the contrib/response-statistics branch from 99fc214 to f698725 Compare November 21, 2026 00:01
@AndyScherzinger AndyScherzinger changed the title feat(results): average, median, range and Net Promoter Score for scale questions feat(results): average, median, range and promoter score for scale questions Nov 21, 2026
@AndyScherzinger
AndyScherzinger force-pushed the contrib/response-statistics branch from a9c5a26 to b1f0b88 Compare November 21, 2026 00:06
"Net Promoter" and "NPS" are registered trademarks of Bain & Company,
NICE Systems and Fred Reichheld. The summary only needs to say what the
number is, so the label describes the calculation instead of using the
trademarked name, and the variables behind it are named after the
promoter score as well.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The figures block took over the head of the v-if chain that renders the
per-value bars. A linear scale with answers lost its bars, and a ranking
question showed a plain option list under its Borda ranking. Placing the
figures before that chain restores both.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger
AndyScherzinger force-pushed the contrib/response-statistics branch from b1f0b88 to 01b75fc Compare November 21, 2026 00:22
@AndyScherzinger
AndyScherzinger force-pushed the contrib/response-statistics branch from 01b75fc to 9663412 Compare November 21, 2026 01:11
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread lib/Constants.php Resolved
(props.extraSettings as LinearScaleExtraSettings | undefined) ?? {}
)
})
const unsavedExtraSettings = ref<LinearScaleExtraSettings>({})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (optional): unsavedExtraSettings is a second copy of the pending changes that useQuestion already keeps in pendingExtraSettings, and the two are cleared by different events (the props object being replaced, the debounce firing). With the current parents they cannot diverge, so this is no bug today. It only fixes the 400 ms lag for linear scale, though: QuestionFile, QuestionMultiple and the others still read props that trail their pending changes, and on main that already loses data in QuestionFile (ticking two file types within 400 ms on a new question saves only the second).

A follow-up could make the pending changes a ref in useQuestion and expose the merged settings under a name other than extraSettings, because a setup binding with that name would silently shadow the prop in the templates of QuestionMultiple, QuestionDropdown and QuestionRanking, and then switch every question type to it. That is wider than this PR, so I would keep the overlay here.

Assisted by ClaudeCode:claude-opus-5-5

@AndyScherzinger

Copy link
Copy Markdown
Member

Nit (optional), about the first commit (f698725): its author and sign-off use the handle global-prog, while AGENTS.md asks for a sign-off "by the human contributor per the Developer Certificate of Origin (DCO), using their real name". It also has no Assisted-by: trailer, although this PR declares AI use and AGENTS.md says every commit made with AI assistance must include one. Neither check catches this: the DCO check only compares the e-mail addresses, and check-ai-trailers passes on the trailers of the later commits. Only the author of that commit can fix it, by amending it with their real name in author and sign-off and an Assisted-by: <tool>:<model> trailer.

Assisted by ClaudeCode:claude-opus-5-5

Subtracting the rounded promoter and detractor percentages can be one
point off, e.g. 4 promoters and 2 detractors out of 7 showed 28 instead
of 29. The unused passives share and response count are dropped.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
A 0-10 scale is not always a "how likely are you to recommend" question,
so the promoter score now needs the new showPromoterScore extra setting.
It can be switched on in the editor for a 0-10 scale only and then locks
the range; the server rejects the setting on any other range. Switching
it on leaves the range alone, so answers given on another scale are
never scored as if they were on 0-10, and switching it off undoes it.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Server CSS gives every dt a fixed, unwrapped, end-aligned width, so the
figure labels overlapped their values. The figures reset that layout,
and the promoter and detractor shares get their own dd, so screen
readers no longer read the score and the first share as one number.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Average, median and the promoter score were shown as raw numbers, with
a decimal point in every language and a misplaced minus sign in
right-to-left languages. The average is also rounded without the float
error that turned an exact half into a lower value.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The figures only count given answers, while the bars below also count
the submissions that skipped the question, so the same answers showed
different percentages without saying why.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
"Minimum" and "Maximum" name the figures without reading like the
scale's own bounds, the docblocks describe what the values contain,
and a fallback for submissions without answers is dropped because the
answers are always present.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
End-to-end cases for the figures above the bars, the promoter score
shown only when switched on, the editor offering it only on a 0-10
scale, and the range locking as soon as it is switched on, before the
debounced save.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
The figures walked every answer of every submission a second time for
each linear scale question, through Vue's reactive proxies, which took
as long as building the bars themselves. The bars already count the
answers per value, so the figures are now taken from those counts.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger
AndyScherzinger force-pushed the contrib/response-statistics branch from cea6081 to 02f312f Compare November 21, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants