Skip to content

Feature/relative evaluation voting#3416

Merged
KATO-Hiro merged 16 commits into
stagingfrom
feature/relative_evaluation_voting
Apr 17, 2026
Merged

Feature/relative evaluation voting#3416
KATO-Hiro merged 16 commits into
stagingfrom
feature/relative_evaluation_voting

Conversation

@river0525

@river0525 river0525 commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

相対評価機能を実装いたしました。
ご確認よろしくお願いいたします。

Summary by CodeRabbit

  • 新機能
    • 確定済み成績に対し、中央値との比較を示す相対評価バッジ(++ / + / なし / - / --)を表示。投票一覧・管理画面・個別ページの成績表示に組み込み。投票数が閾値未満の項目では非表示。表示は視覚/画面リーダー対応、ツールチップの表示切替をサポート。
  • テスト
    • 差分計算・ラベル変換・ツールチップ文言の単体テストを追加。
  • ドキュメント
    • 相対評価投票の実装計画を追記。

river0525 and others added 2 commits April 15, 2026 10:09
When a task has a confirmed grade and sufficient votes to compute a
median, display a badge (+, ++, -, --) in the top-right corner of the
grade icon to indicate how the community perceives the difficulty
relative to the official grade.

- Add calcGradeDiff / getRelativeEvaluationLabel utilities with tests
- Render amber badge for harder (+/++) and sky badge for easier (-/--)
- No badge shown for PENDING tasks or when vote count is below threshold

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Document that diff = gradeOrder(median) - gradeOrder(confirmed),
  positive means harder than confirmed
- Note that badge is hidden when votes are below MIN_VOTES_FOR_STATISTICS
- Fix typo: evalution -> evaluation in branch name

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 278c4b64-235a-487c-a839-0711f60aa206

📥 Commits

Reviewing files that changed from the base of the PR and between f0582fe and 553e535.

📒 Files selected for processing (2)
  • src/features/votes/utils/relative_evaluation.test.ts
  • src/features/votes/utils/relative_evaluation.ts

📝 Walkthrough

Walkthrough

確定グレードと投票中央値の序列差を計算し、その差に基づく5段階(--,-,なし,+,++)の相対評価バッジを確定グレード表示に追加。計画書、ユーティリティ、テスト、UIコンポーネントを新規追加し既存表示に統合した。

Changes

Cohort / File(s) Summary
計画書
docs/dev-notes/2026-04-15/relative_evalution_voting/plan.md
相対評価投票の実装計画を追加(中央値利用、差分定義、閾値、5段階バッジ、表示条件、作業ブランチ記録)。
ユーティリティ & テスト
src/features/votes/utils/relative_evaluation.ts, src/features/votes/utils/relative_evaluation.test.ts
calcGradeDiff()で序列差を算出、getRelativeEvaluationLabel()getRelativeEvaluationTooltipText()でラベルとツールチップ文字列を決定。対応する単体テストを追加。
新規コンポーネント
src/features/votes/components/RelativeEvaluationBadge.svelte
公式グレードと中央値からラベルを算出して5段階バッジを描画。ツールチップはオプション、Props 型定義を追加。
既存コンポーネント更新
src/features/votes/components/VotableGrade.svelte
中央値をローカル状態で保持・更新し、確定グレード表示時に相対評価バッジを表示。スクリーンリーダーテキストを拡張。
ページ表示への組み込み
src/routes/votes/+page.svelte, src/routes/votes/[slug]/+page.svelte, src/routes/(admin)/vote_management/+page.svelte
各グレード表示をラップして条件付きで RelativeEvaluationBadge をレンダリングするよう更新(badgeId を付与)。

Sequence Diagram(s)

sequenceDiagram
  participant Page as "Page (votes / admin)"
  participant Votable as "VotableGrade"
  participant Server as "API: fetchMedianVote"
  participant Util as "relative_evaluation.ts"
  participant Badge as "RelativeEvaluationBadge"

  Page->>Votable: render(task, grade, estimatedGrade)
  Votable->>Server: fetchMedianVote(task_id)
  Server-->>Votable: medianGrade
  Votable->>Util: calcGradeDiff(officialGrade, medianGrade)
  Util-->>Votable: diff / label / tooltipText
  Votable->>Badge: render(officialGrade, medianGrade, badgeId, showTooltip)
  Badge-->>Page: displays positioned badge (tooltip optional)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

中央の声が差を告げる、
小さな印が意味を持ち、
確定の色はそっと変わる。
バッジ一つで見える景色、
投票の波が静かに刻む ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトルが相対評価投票機能実装の主要な変更内容を適切に反映している。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/relative_evaluation_voting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/dev-notes/2026-04-15/relative_evalution_voting/plan.md`:
- Line 1: Fix Markdown formatting by ensuring blank lines before and after
headings (e.g., the top-level heading "# 概要" and the other heading instances
flagged) to satisfy markdownlint MD022, then run prettier --write to apply the
repository's formatting; re-run markdownlint to confirm no MD022 warnings remain
and commit the updated file.

In `@src/features/votes/components/VotableGrade.svelte`:
- Around line 59-65: The relativeEvaluationLabel stays stale because it only
recomputes when taskResult.grade is PENDING; update the logic so the derived
reactive (relativeEvaluationLabel) depends on both the current confirmed grade
and the latest median vote (estimatedGrade/median) and recomputes when either
changes: replace the PENDING-only gate in relativeEvaluationLabel with a check
that returns '' when grade is PENDING OR no estimatedGrade, otherwise call
getRelativeEvaluationLabel(calcGradeDiff(taskResult.grade, estimatedGrade));
also introduce a local reactive/derived variable to hold the latest median vote
(update it where you fetch the median) so both the confirmed-grade path and
vote-updates update estimatedGrade and trigger recomputation of
relativeEvaluationLabel (refer to relativeEvaluationLabel, estimatedGrade,
calcGradeDiff, getRelativeEvaluationLabel, and taskResult.grade).

In `@src/features/votes/utils/relative_evaluation.test.ts`:
- Around line 11-17: Update the incorrect inline comments in the test so they
match the implementation's grade ordering: change the two occurrences that say
"Q5(order 6)" to "Q5(order 7)" (the assertions using calcGradeDiff remain
unchanged); this aligns the test comments with getTaskGradeOrder and
TaskGrade.Q5.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 73d0a859-33b2-42eb-b8e6-4dfad6619e6e

📥 Commits

Reviewing files that changed from the base of the PR and between 7c5c4a7 and 6042e96.

📒 Files selected for processing (4)
  • docs/dev-notes/2026-04-15/relative_evalution_voting/plan.md
  • src/features/votes/components/VotableGrade.svelte
  • src/features/votes/utils/relative_evaluation.test.ts
  • src/features/votes/utils/relative_evaluation.ts

Comment thread docs/dev-notes/2026-04-15/relative_evalution_voting/plan.md
Comment thread src/features/votes/components/VotableGrade.svelte Outdated
Comment thread src/features/votes/utils/relative_evaluation.test.ts Outdated

@KATO-Hiro KATO-Hiro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

早速、実装していただき、ありがとうございます。

現時点での内容を拝見いたしました。
以下の3点について、ご確認いただけますでしょうか?

<アイコンの一貫性>
相対評価に関するアイコンは、テーブルだけではなく、投票に関連する他のページにも表示した方がいいように思いますがいかがでしょうか?
(設計思想に関わる部分だと思いますので、意見のすり合わせができればと考えています)

<テストケースの補強>
基本的なテストは書かれていると思います。一方、一部のテストは追加の正常系や境界値の確認が必要そうです。具体的なケースは、該当箇所に記載しています。

理由: テストケースを動作確認可能な仕様として活用できるようにするため

<PR 作成後のAI からのレビューの指摘事項>
必要だと判断したものに関しては、事前 にご対応いただけると幸いです。また、時には過剰な指摘や的外れな場合もあるため、対処しない理由があるときも記載していただけると助かります。お手数ですが、よろしくお願いいたします。

* @param medianGrade - The median grade derived from user votes.
* @returns `gradeOrder(medianGrade) - gradeOrder(confirmedGrade)`
*/
export function calcGradeDiff(confirmedGrade: TaskGrade, medianGrade: TaskGrade): number {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

細かいかもしれませんが、confirmedGrade だとやや曖昧さがありそうです。例えば、officialGrade とするのはいかがでしょうか?

Comment thread src/features/votes/utils/relative_evaluation.test.ts Outdated
Comment thread src/features/votes/utils/relative_evaluation.test.ts Outdated
Comment thread docs/dev-notes/2026-04-15/relative_evalution_voting/plan.md
Comment thread src/features/votes/components/VotableGrade.svelte Outdated
- Add RelativeEvaluationBadge component with tooltip explaining ++/+/-/-- meaning
- Show badge on /votes list, /votes/[slug] detail, and /vote_management admin pages
- Fix stale badge on confirmed-grade tasks after voting via latestMedianGrade local state
- Add tracking-wider and more saturated colors to improve badge readability
- Rename confirmedGrade → officialGrade in calcGradeDiff utility
- Fix test comment: Q5(order 6) → Q5(order 7)
- Add D-tier and Q1/D1 boundary tests to relative_evaluation.test.ts
- Fix MD022 heading blank lines in plan.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/routes/`(admin)/vote_management/+page.svelte:
- Around line 74-80: The check rendering RelativeEvaluationBadge should also
guard that stat.estimatedGrade exists; change the conditional that uses
TaskGrade.PENDING to require both stat.dbGrade !== TaskGrade.PENDING and
stat.estimatedGrade (or a null/undefined-safe check) before rendering
RelativeEvaluationBadge so it mirrors the guards used in votes/+page.svelte and
votes/[slug]/+page.svelte and prevents passing an undefined medianGrade prop to
RelativeEvaluationBadge.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1800d072-9032-4634-9444-e74872d5ec8a

📥 Commits

Reviewing files that changed from the base of the PR and between 6042e96 and a1568f3.

📒 Files selected for processing (8)
  • docs/dev-notes/2026-04-15/relative_evalution_voting/plan.md
  • src/features/votes/components/RelativeEvaluationBadge.svelte
  • src/features/votes/components/VotableGrade.svelte
  • src/features/votes/utils/relative_evaluation.test.ts
  • src/features/votes/utils/relative_evaluation.ts
  • src/routes/(admin)/vote_management/+page.svelte
  • src/routes/votes/+page.svelte
  • src/routes/votes/[slug]/+page.svelte

Comment thread src/routes/(admin)/vote_management/+page.svelte Outdated
…condition

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@river0525

Copy link
Copy Markdown
Collaborator Author

レビューいただきありがとうございます。
以下、私の考えです。

<アイコンの一貫性>

相対評価に関するアイコンは、テーブルだけではなく、投票に関連する他のページにも表示した方がいいように思いますがいかがでしょうか?
(設計思想に関わる部分だと思いますので、意見のすり合わせができればと考えています)

おっしゃる通りです。対応します。

<テストケースの補強>

基本的なテストは書かれていると思います。一方、一部のテストは追加の正常系や境界値の確認が必要そうです。具体的なケースは、該当箇所に記載しています。

理由: テストケースを動作確認可能な仕様として活用できるようにするため

承知しました。この件についても対応を進めます。

<PR 作成後のAI からのレビューの指摘事項>

必要だと判断したものに関しては、事前 にご対応いただけると幸いです。また、時には過剰な指摘や的外れな場合もあるため、対処しない理由があるときも記載していただけると助かります。お手数ですが、よろしくお願いいたします。

承知しました。今後のPR確認願いはcoderabbitのレビューに対応した後で出します。

river0525 and others added 6 commits April 16, 2026 11:18
- tracking-wider → tracking-widest to separate '--' characters
- bg-*-200 text-*-800 → bg-*-400 text-white for stronger contrast against page background

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…adge

aria-label already covers screen reader needs; tabindex on a non-interactive
element triggers a11y_no_noninteractive_tabindex.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…cters

tracking-widest (0.1em) was insufficient at 0.65rem font size; use tracking-[0.25em].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tracking-[0.25em] -> tracking-[0.375em] (1.5x wider gap between '--' chars)
Add -mr-[0.375em] to cancel the trailing letter-spacing, keeping the badge symmetric.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… badge

Tailwind arbitrary class -mr-[0.375em] was not compensating the trailing
letter-spacing. Use inline style to reliably cancel the trailing gap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
letter-spacing adds trailing space after the last character, which cannot be
cancelled on absolute-positioned elements. Insert &thinsp; between characters
only for '--' and '++' labels so spacing is symmetric.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/votes/components/RelativeEvaluationBadge.svelte`:
- Around line 29-42: Extract the switch-based mapping out of
RelativeEvaluationBadge.svelte into a new exported helper
getRelativeEvaluationTooltipText(label: string) in
src/features/votes/utils/relative_evaluation.ts that returns the same Japanese
strings for '++', '+', '-', '--' and '' by default; then import that function
into RelativeEvaluationBadge.svelte and replace the current tooltipText derived
block with a call to getRelativeEvaluationTooltipText(label) (keeping the
reactive/derived behavior and label typing intact) so the component only
consumes the utility result for rendering.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9eeb0d64-6f45-4b50-81f8-a71c723fc900

📥 Commits

Reviewing files that changed from the base of the PR and between a1568f3 and d61a23f.

📒 Files selected for processing (2)
  • src/features/votes/components/RelativeEvaluationBadge.svelte
  • src/routes/(admin)/vote_management/+page.svelte

Comment thread src/features/votes/components/RelativeEvaluationBadge.svelte Outdated
…tion utils

Move tooltip text mapping out of RelativeEvaluationBadge.svelte into
src/features/votes/utils/relative_evaluation.ts per coding guidelines
(business logic belongs in utils/, not inside <script> blocks).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…er-NoviSteps/AtCoderNoviSteps into feature/relative_evaluation_voting

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/votes/utils/relative_evaluation.ts`:
- Around line 22-35: Add unit tests for getRelativeEvaluationTooltipText in
src/features/votes/utils/relative_evaluation.test.ts to cover the five specified
cases: passing '++' should return '投票中央値が公式グレードより2段階以上高い(難しい)', '+' returns
'投票中央値が公式グレードより1段階高い(難しい)', '-' returns '投票中央値が公式グレードより1段階低い(易しい)', '--' returns
'投票中央値が公式グレードより2段階以上低い(易しい)', and '' (empty string) returns ''. Use the existing
test file structure that already tests calcGradeDiff and
getRelativeEvaluationLabel, import getRelativeEvaluationTooltipText from
relative_evaluation.ts, and add assertions (e.g., expect(...).toBe(...)) for
each input.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6e014d64-e7ab-4c63-9169-a5ae98e89a98

📥 Commits

Reviewing files that changed from the base of the PR and between d61a23f and f0582fe.

📒 Files selected for processing (2)
  • src/features/votes/components/RelativeEvaluationBadge.svelte
  • src/features/votes/utils/relative_evaluation.ts

Comment thread src/features/votes/utils/relative_evaluation.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@KATO-Hiro KATO-Hiro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ご対応いただき、ありがとうございます

・アイコンが前回よりもさらに識別しやすくなっていると思います
・投票関連のページに配置されていることやテストの追加分も拝見しました

LGTMです

tooltip の説明を少し短くしました。いかがでしょうか?

@river0525

Copy link
Copy Markdown
Collaborator Author

tooltipの説明を変更していただきありがとうございます。
より簡潔になり、分かりやすくなったと思います。

@KATO-Hiro

Copy link
Copy Markdown
Collaborator

ご確認いただき、ありがとうございます
マージします

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.

2 participants