Feature/relative evaluation voting#3416
Conversation
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>
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough確定グレードと投票中央値の序列差を計算し、その差に基づく5段階( Changes
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (4)
docs/dev-notes/2026-04-15/relative_evalution_voting/plan.mdsrc/features/votes/components/VotableGrade.sveltesrc/features/votes/utils/relative_evaluation.test.tssrc/features/votes/utils/relative_evaluation.ts
KATO-Hiro
left a comment
There was a problem hiding this comment.
早速、実装していただき、ありがとうございます。
現時点での内容を拝見いたしました。
以下の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 { |
There was a problem hiding this comment.
細かいかもしれませんが、confirmedGrade だとやや曖昧さがありそうです。例えば、officialGrade とするのはいかがでしょうか?
- 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>
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
docs/dev-notes/2026-04-15/relative_evalution_voting/plan.mdsrc/features/votes/components/RelativeEvaluationBadge.sveltesrc/features/votes/components/VotableGrade.sveltesrc/features/votes/utils/relative_evaluation.test.tssrc/features/votes/utils/relative_evaluation.tssrc/routes/(admin)/vote_management/+page.sveltesrc/routes/votes/+page.sveltesrc/routes/votes/[slug]/+page.svelte
…condition Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
レビューいただきありがとうございます。 <アイコンの一貫性>
おっしゃる通りです。対応します。 <テストケースの補強>
承知しました。この件についても対応を進めます。 <PR 作成後のAI からのレビューの指摘事項>
承知しました。今後のPR確認願いはcoderabbitのレビューに対応した後で出します。 |
- 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   between characters only for '--' and '++' labels so spacing is symmetric. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/features/votes/components/RelativeEvaluationBadge.sveltesrc/routes/(admin)/vote_management/+page.svelte
…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>
…ps into feature/relative_evaluation_voting
…er-NoviSteps/AtCoderNoviSteps into feature/relative_evaluation_voting
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
src/features/votes/components/RelativeEvaluationBadge.sveltesrc/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>
|
tooltipの説明を変更していただきありがとうございます。 |
|
ご確認いただき、ありがとうございます |
相対評価機能を実装いたしました。
ご確認よろしくお願いいたします。
Summary by CodeRabbit