0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-14 13:58:53 +08:00
discourse/plugins/discourse-solved/config/settings.yml
Chris Alberti 9706fb8cfb
DEV: Allow multiple solutions in solved plugin (#39806)
Adds a site setting to allow multiple solutions to be accepted in the
solved plugin. Behavior without the setting enabled should remain as
before these changes.

### Model/DB changes

Previously, solutions were stored in a `SolvedTopic` model backed by the
`discourse_solved_solved_topic` table, which pointed to a topic id, a
post id, an accepting user id, and optionally a timer id for a timer to
auto-close the topic after a set amount of time if configured.

Now, the `SolvedTopic` model drops the post id and accepting user id,
but still points to the topic id and the timer id (there will only be
one timer per topic), and adds a has_many relationship to a new
`TopicAnswer` model. The `TopicAnswer` model backed by the
`discourse_solved_topic_answer` table points to a `SolvedTopic` id, a
post id and accepting user id, with one `TopicAnswer` for each accepted
solution post.

References to `topic.accepted_answer` or `topic.solved.accepted_post`
have been changed to `topic.accepted_answers.first` or
`topic.solved.topic_answers.first.post`, etc. Updated all specs/tests
and added new cases for the multiple solutions mode.

Several references in other build-in plugins are also fixed in this PR.

### Allow multiple solutions mode
These changes add the site setting `solved_allow_multiple_solutions`
which is disabled by default.

When disabled, behavior should be as it was before these changes. Users
can not accept multiple solutions for a single topic. If a post in the
topic is already marked as a solution, then the "Solution" button is
hidden, and if a user still accepts a different solution then the
original solution will be unaccepted.

When enabled, users can accept more than one solution for each topic.
Even if a solution is already accepted, other posts still show the
"Solution" button. Users can still unaccept any accepted solutions.

If a topic has multiple solutions, each one is displayed as a summary
under the OP using the existing component to represent the summary. For
displaying the solved checkmark icon, filtering, etc, a topic is
considered solved if it has at least one solution.

### UI

Added a PostExcerptAccordion component which displays post excerpts in
an accordion style with a header and expandable/collapsible items, and
that component is used to render the solution post(s) under the OP. The
first item is displayed expanded while the others are collapsed, by
default. The expanded items are truncated based on a number of lines
calculated from the `solved_quote_length` site setting, with a "read
more" link to view the full post.

Without multiple solutions allowed:
<img width="1606" height="1046" alt="image"
src="https://github.com/user-attachments/assets/5d6229f2-9052-473a-8953-574667761544"
/>

With multiple solutions allowed:
<img width="1594" height="1254" alt="image"
src="https://github.com/user-attachments/assets/6e7b7ac5-23fa-4b0e-b6d6-b8a53cdf2756"
/>

With multiple solutions, after expanding each:
<img width="932" height="1000" alt="image"
src="https://github.com/user-attachments/assets/2a8842b6-040d-44d8-bad4-f61d819789ef"
/>

### QAPage schema

The QAPage schema metadata is updated to include multiple accepted
solutions, which is allowed according to [google's QAPage
doc](https://developers.google.com/search/docs/appearance/structured-data/qapage#question)

---------

Co-authored-by: discourse-patch-triage[bot] <272280883+discourse-patch-triage[bot]@users.noreply.github.com>
Co-authored-by: Manuel Kostka <manuel@discourse.org>
2026-05-28 07:12:28 -05:00

84 lines
2 KiB
YAML
Vendored

discourse_solved:
solved_enabled:
default: true
client: true
solved_allow_multiple_solutions:
default: false
client: true
hidden: true
show_who_marked_solved:
default: false
client: true
allow_solved_on_all_topics:
default: false
client: true
allow_solved_in_groups:
type: group_list
default: ""
allow_any: false
refresh: true
accept_all_solutions_trust_level:
default: 4
client: true
enum: "TrustLevelSetting"
hidden: true
accept_all_solutions_allowed_groups:
default: "1|2|14" # auto group admin, moderators and trust_level_4
mandatory_values: "1|2" # auto group admins, moderators
type: group_list
client: false
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
empty_box_on_unsolved:
default: false
hidden: true
solved_quote_length:
default: 700
client: true
solved_topics_auto_close_hours:
default: 0
min: 0
max: 175200 # 20 years
show_filter_by_solved_status:
default: false
client: true
notify_on_staff_accept_solved:
default: false
hidden: true
disable_solved_education_message:
default: false
accept_solutions_topic_author:
default: true
solved_add_schema_markup:
type: enum
default: "always"
choices:
- "never"
- "always"
- "answered only"
prioritize_solved_topics_in_search: false
enable_solved_tags:
type: tag_list
default: ""
client: true
enable_support_category_type_setup:
default: false
hidden: true
client: true
upcoming_change:
status: "permanent"
impact: "feature,staff"
learn_more_url: "https://meta.discourse.org/t/-/398338"
enable_solved_shared_issues:
default: false
hidden: true
client: true
upcoming_change:
status: "experimental"
impact: "feature,all_members"
learn_more_url: "https://meta.discourse.org/t/-/402498"
discourse_solved_admin_dashboard_seeded:
default: false
hidden: true