Skip to content

feat: rating question type - #3637

Open
global-prog wants to merge 1 commit into
nextcloud:mainfrom
global-prog:contrib/rating-question
Open

feat: rating question type#3637
global-prog wants to merge 1 commit into
nextcloud:mainfrom
global-prog:contrib/rating-question

Conversation

@global-prog

Copy link
Copy Markdown

Implements #356.

Summary

A compact rating question, with stars, hearts or thumbs up, configurable from 2 to 10 icons (default 5).

A linear scale already covers 1..N, but renders as a row of radio buttons. A rating is the control people expect for "how would you rate this", takes far less width, and reads at a glance in the results.

Accessibility

Built from real radio inputs rather than clickable icons, so:

  • it stays keyboard navigable, and each option is announced with the value it selects (3 of 5) rather than as an unnamed radio
  • the hit area is a full --default-clickable-area square while the icon itself stays small — an icon-sized target is awkward to hit on a phone
  • the hover animation is dropped under prefers-reduced-motion
  • the icons wrap, since ten of them plus the clear button do not fit one line on a narrow screen

Storage and validation

The answer is stored as the plain number, so results and CSV export need no special handling.

It is validated server-side as a whole number within the configured maximum rather than trusting the client. A rating carries no options, so it is checked on its own rather than as a predefined-option type.

Scope

  • no schema change; maxRating and ratingIcon live in the existing extraSettings
  • FormsQuestionType is deliberately left alone, matching how linearscale, ranking and color are already handled, so openapi.json is unaffected

Testing

  • npm run lint, npm run stylelint and php -l clean
  • built against current main with no errors
  • checked: default 5 stars, switching to hearts and thumbs, changing the count, clearing an answer, a required rating left empty, and a submitted value appearing correctly in the results and CSV export

Happy to adjust the default icon count, the icon set, or drop the hearts/thumbs options if you would rather keep it to stars.

Implements nextcloud#356: a compact star rating, with hearts and thumbs as alternatives.

A linear scale already covers 1..N, but as a row of radio buttons. A rating is the
control people expect for "how would you rate this", takes far less width, and reads
at a glance in the results.

Built from real radio inputs rather than clickable icons, so it stays keyboard
navigable and every option is announced with the value it selects. The hit area is a
full clickable-area square while the icon itself stays small, since an icon-sized
target is awkward to hit on a phone. The hover animation is dropped under
prefers-reduced-motion.

Configurable from 2 to 10 icons, defaulting to 5. The answer is stored as the plain
number, so results and CSV export need no special handling.

Validated server-side as a whole number within the configured maximum rather than
trusting the client. Rating carries no options, so it is checked on its own rather
than as a predefined-option type.

No schema change. FormsQuestionType is left alone, matching how linearscale, ranking
and color are already handled, so openapi.json is unaffected.

Signed-off-by: global-prog <raqeeb@uosamarra.edu.iq>
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
lib/Service/SubmissionService.php 14.28% 6 Missing ⚠️
lib/Service/FormsService.php 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant