プラクティスに理解度テスト機能を追加#10241
Conversation
|
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:
📝 WalkthroughWalkthrough理解度テストの永続化、受験、修了判定、メンター管理画面、関連テストとフィクスチャが追加されています。 Changesプラクティス理解度テスト
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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
🧹 Nitpick comments (3)
db/migrate/20260627120618_create_practice_quiz_attempts.rb (1)
3-10: 🚀 Performance & Scalability | 🔵 Trivial再受験クールダウン/合格判定クエリ向けに複合インデックスの追加を検討してください。
再受験ロックアウト判定や合格済み判定では、ユーザーとクイズの組み合わせで最新の受験 (
submitted_at) を引く問い合わせが繰り返し発生する想定です。t.referencesが作る単一カラムのインデックスだけでは効率が落ちる可能性があるため、(practice_quiz_id, user_id, submitted_at)の複合インデックスを検討するとよいです。♻️ 追加例
t.datetime :submitted_at, null: false t.boolean :passed, null: false, default: false t.timestamps + + t.index [:practice_quiz_id, :user_id, :submitted_at] end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@db/migrate/20260627120618_create_practice_quiz_attempts.rb` around lines 3 - 10, The practice_quiz_attempts table only has single-column indexes from the references, but the cooldown and passed-check queries will repeatedly filter by practice_quiz_id and user_id and sort or look up by submitted_at. Add a composite index on practice_quiz_attempts using the create_table block in the migration so the schema supports those access patterns efficiently; use the existing practice_quiz_attempts table definition as the place to introduce the new index alongside the references.test/integration/practice_quizzes_test.rb (2)
43-65: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win再受験ロック中の案内文を確認したほうがよいです。
ここでは再投稿が拒否されることしか検証しておらず、「次に受験可能な時刻を表示する」要件が未カバーです。リダイレクト先の flash か本文に次回時刻が出ることまで押さえると、仕様の抜け漏れを防げます。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/practice_quizzes_test.rb` around lines 43 - 65, The retry-lock test for PracticeQuiz attempts only checks that the second submission is rejected, but it does not cover the expected user guidance showing when the quiz can be taken again. Update the test around practice_practice_quiz_attempts_path and practice_practice_quiz_path to assert that the redirect response includes the next available attempt time in either the flash message or rendered content, alongside the existing no-new-attempt check.
6-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win合格後の表示要件まで検証しておきたいです。
このケースは合格後のリダイレクトまでしか見ていないので、「正答・解説・合格状態が見える」という要件の退行を拾えません。
follow_redirect!して表示内容まで固定しておくと安心です。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/practice_quizzes_test.rb` around lines 6 - 30, The practice quiz flow currently only asserts the redirect after a passing attempt, so it can miss regressions in the post-pass UI. Update the integration test in practice_quizzes_test around practice_practice_quiz_attempts_path to follow_redirect! after the successful post, then assert the resulting page shows the correct answer, explanation, and passed/completed state for the quiz; use the existing quiz, question, and user setup to keep the test focused on the pass-after-attempt behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/controllers/api/practices/learning_controller.rb`:
- Around line 42-49: The find_or_initialize_learning flow currently assigns
params[:status] directly to learning.status, which can raise when the value is
not a valid enum. Update LearningController#find_or_initialize_learning to
whitelist only the allowed status values (unstarted, started, submitted,
complete) before converting and assigning, and fall back safely when
params[:status] is nil or invalid so the enum setter never receives an
unsupported value.
In `@app/controllers/mentor/practices/practice_quiz/questions_controller.rb`:
- Around line 53-55: `QuestionsController#set_practice_quiz` currently assigns
`@practice.practice_quiz` without handling the nil case, which can lead to
`NoMethodError` in `new`, `create`, and `set_question` when a practice quiz has
not been created. Update this before-action to match
`PracticeQuizController#set_practice_quiz` by checking for a blank
`@practice_quiz` and redirecting appropriately instead of continuing. Make sure
the guard covers all question actions so
`@practice_quiz.practice_quiz_questions` is never called on nil.
In `@test/integration/practice_quizzes_test.rb`:
- Around line 32-40: The test is using practice5, which is a submission-based
practice in this PR, so it is asserting the wrong completion contract. Update
the integration test around api_practice_learning_path and Learning.find_by! to
use a non-submission practice for the “complete without quiz” case, or
explicitly create an approved submission/Product before calling the complete
action. Keep the test aligned with the actual behavior of practices that require
submissions.
---
Nitpick comments:
In `@db/migrate/20260627120618_create_practice_quiz_attempts.rb`:
- Around line 3-10: The practice_quiz_attempts table only has single-column
indexes from the references, but the cooldown and passed-check queries will
repeatedly filter by practice_quiz_id and user_id and sort or look up by
submitted_at. Add a composite index on practice_quiz_attempts using the
create_table block in the migration so the schema supports those access patterns
efficiently; use the existing practice_quiz_attempts table definition as the
place to introduce the new index alongside the references.
In `@test/integration/practice_quizzes_test.rb`:
- Around line 43-65: The retry-lock test for PracticeQuiz attempts only checks
that the second submission is rejected, but it does not cover the expected user
guidance showing when the quiz can be taken again. Update the test around
practice_practice_quiz_attempts_path and practice_practice_quiz_path to assert
that the redirect response includes the next available attempt time in either
the flash message or rendered content, alongside the existing no-new-attempt
check.
- Around line 6-30: The practice quiz flow currently only asserts the redirect
after a passing attempt, so it can miss regressions in the post-pass UI. Update
the integration test in practice_quizzes_test around
practice_practice_quiz_attempts_path to follow_redirect! after the successful
post, then assert the resulting page shows the correct answer, explanation, and
passed/completed state for the quiz; use the existing quiz, question, and user
setup to keep the test focused on the pass-after-attempt behavior.
🪄 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: CHILL
Plan: Pro
Run ID: dfcb932b-cd25-4e75-a017-22b69e88968c
📒 Files selected for processing (41)
app/controllers/api/practices/learning_controller.rbapp/controllers/mentor/practices/practice_quiz/questions_controller.rbapp/controllers/mentor/practices/practice_quiz_controller.rbapp/controllers/practices/practice_quiz/attempts_controller.rbapp/controllers/practices/practice_quiz_controller.rbapp/helpers/page_tabs/practices_helper.rbapp/models/learning_status_updater.rbapp/models/practice.rbapp/models/practice_quiz.rbapp/models/practice_quiz_answer.rbapp/models/practice_quiz_attempt.rbapp/models/practice_quiz_choice.rbapp/models/practice_quiz_question.rbapp/views/mentor/practices/_mentor_practices.html.slimapp/views/mentor/practices/practice_quiz/_form.html.slimapp/views/mentor/practices/practice_quiz/edit.html.slimapp/views/mentor/practices/practice_quiz/new.html.slimapp/views/mentor/practices/practice_quiz/questions/_form.html.slimapp/views/mentor/practices/practice_quiz/questions/edit.html.slimapp/views/mentor/practices/practice_quiz/questions/new.html.slimapp/views/practices/practice_quiz/show.html.slimapp/views/practices/show.html.slimconfig/routes.rbconfig/routes/mentor.rbdb/migrate/20260627120612_create_practice_quizzes.rbdb/migrate/20260627120614_create_practice_quiz_questions.rbdb/migrate/20260627120616_create_practice_quiz_choices.rbdb/migrate/20260627120618_create_practice_quiz_attempts.rbdb/migrate/20260627120621_create_practice_quiz_answers.rbdb/schema.rbtest/fixtures/practice_quiz_answers.ymltest/fixtures/practice_quiz_attempts.ymltest/fixtures/practice_quiz_choices.ymltest/fixtures/practice_quiz_questions.ymltest/fixtures/practice_quizzes.ymltest/integration/mentor/practice_quizzes_test.rbtest/integration/practice_quizzes_test.rbtest/models/learning_status_updater_test.rbtest/models/practice_quiz_attempt_test.rbtest/models/practice_quiz_question_test.rbtest/models/practice_quiz_test.rb
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
db/schema.rb (1)
589-599: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
practice_quiz_answersが設問と選択肢の対応関係をDBで保証していません。今の定義だと、別設問に属する
practice_quiz_choice_idと任意のpractice_quiz_question_idを同じ回答行に保存できてしまいます。これでは採点結果や正解表示の元データが壊れるので、組み合わせを複合制約で縛るか、practice_quiz_question_idを冗長保持しない形に寄せたほうが安全です。Also applies to: 1223-1225
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@db/schema.rb` around lines 589 - 599, `practice_quiz_answers` の定義では `practice_quiz_choice_id` と `practice_quiz_question_id` の整合性がDBで保証されていないため、`practice_quiz_answer` の保存時に別設問の選択肢を紐づけられてしまう点を修正してください。`PracticeQuizAnswer` の関連とスキーマを見直し、`practice_quiz_choices` と `practice_quiz_questions` の対応が複合制約で検証されるようにするか、`practice_quiz_question_id` を冗長に持たず `practice_quiz_choice_id` から参照する形へ寄せてください。関連箇所は `practice_quiz_answers` のテーブル定義と、回答作成処理を行う `PracticeQuizAnswer` 周辺です。
🧹 Nitpick comments (2)
test/integration/practice_quizzes_test.rb (2)
96-109: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
multiple_choiceの通しテストも1本ほしいです。今回の機能範囲には単一選択と複数選択の両方が含まれていますが、このヘルパー経由のテストは
single_choiceしか通していません。複数正解の送信・採点・合格判定を1ケース追加しないと、片系統だけ通ってもう一方が壊れていても検知できません。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/practice_quizzes_test.rb` around lines 96 - 109, The integration helper create_quiz currently only builds a single_choice quiz, so add a separate multiple_choice end-to-end test that uses the same PracticeQuiz and practice_quiz_questions flow but creates a multiple_choice question with more than one correct practice_quiz_choice. Verify the full submit-and-score path in practice/integration coverage, including answering multiple correct options and checking the pass/fail outcome, so both branches of the quiz logic are exercised.
59-83: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win失敗時に正答・解説を見せない契約もここで固定したいです。
このケースはリトライ抑止と待機文言だけを見ていて、PR要件の「失敗時は正解・解説を表示しない」を担保できていません。
follow_redirect!後に'正解'や'解説です。'を含まないことも確認しておくと、この分岐の回帰を防げます。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/practice_quizzes_test.rb` around lines 59 - 83, Update the integration test for the retry-blocking flow in practice_quizzes_test by extending the existing post-failure assertions after follow_redirect! so it also verifies the response does not expose the correct answer or explanation. Use the existing practice_practice_quiz_attempts_path, practice_practice_quiz_path, and create_quiz flow as the anchor, and add negative checks for the failure page content such as the answer/explanation text to lock in the “no 正解・解説 on failure” contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@db/schema.rb`:
- Around line 589-599: `practice_quiz_answers` の定義では `practice_quiz_choice_id` と
`practice_quiz_question_id` の整合性がDBで保証されていないため、`practice_quiz_answer`
の保存時に別設問の選択肢を紐づけられてしまう点を修正してください。`PracticeQuizAnswer`
の関連とスキーマを見直し、`practice_quiz_choices` と `practice_quiz_questions`
の対応が複合制約で検証されるようにするか、`practice_quiz_question_id` を冗長に持たず
`practice_quiz_choice_id` から参照する形へ寄せてください。関連箇所は `practice_quiz_answers`
のテーブル定義と、回答作成処理を行う `PracticeQuizAnswer` 周辺です。
---
Nitpick comments:
In `@test/integration/practice_quizzes_test.rb`:
- Around line 96-109: The integration helper create_quiz currently only builds a
single_choice quiz, so add a separate multiple_choice end-to-end test that uses
the same PracticeQuiz and practice_quiz_questions flow but creates a
multiple_choice question with more than one correct practice_quiz_choice. Verify
the full submit-and-score path in practice/integration coverage, including
answering multiple correct options and checking the pass/fail outcome, so both
branches of the quiz logic are exercised.
- Around line 59-83: Update the integration test for the retry-blocking flow in
practice_quizzes_test by extending the existing post-failure assertions after
follow_redirect! so it also verifies the response does not expose the correct
answer or explanation. Use the existing practice_practice_quiz_attempts_path,
practice_practice_quiz_path, and create_quiz flow as the anchor, and add
negative checks for the failure page content such as the answer/explanation text
to lock in the “no 正解・解説 on failure” contract.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 873c0abe-54ff-4750-b653-88acd3efb93e
📒 Files selected for processing (5)
app/controllers/api/practices/learning_controller.rbapp/controllers/mentor/practices/practice_quiz/questions_controller.rbdb/migrate/20260627120618_create_practice_quiz_attempts.rbdb/schema.rbtest/integration/practice_quizzes_test.rb
🚧 Files skipped from review as they are similar to previous changes (3)
- db/migrate/20260627120618_create_practice_quiz_attempts.rb
- app/controllers/mentor/practices/practice_quiz/questions_controller.rb
- app/controllers/api/practices/learning_controller.rb
|
追加指摘に対応しました。
|
|
Tip For best results, initiate chat on the files or code changes.
ᕱ⑅ᕱ If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/integration/practice_quizzes_test.rb`:
- Around line 82-84: The `create_quiz` response assertion is using the generic
string `正解`, which can match the `不正解` label and cause false failures. Update
the check in `practice_quizzes_test` to assert against a non-overlapping, unique
phrase from the success/explanation text instead, or replace it with a more
specific absence assertion tied to the actual rendered content so the test only
fails when the correct answer text is truly present.
🪄 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: CHILL
Plan: Pro
Run ID: a3b79c70-b8bd-484e-be4c-589e5accca3a
📒 Files selected for processing (14)
app/assets/stylesheets/application.cssapp/assets/stylesheets/application/blocks/practice-quiz/_practice-quiz.cssapp/models/practice_quiz_answer.rbapp/models/practice_quiz_attempt.rbapp/views/mentor/practices/practice_quiz/_form.html.slimapp/views/mentor/practices/practice_quiz/edit.html.slimapp/views/mentor/practices/practice_quiz/new.html.slimapp/views/mentor/practices/practice_quiz/questions/_form.html.slimapp/views/mentor/practices/practice_quiz/questions/edit.html.slimapp/views/mentor/practices/practice_quiz/questions/new.html.slimapp/views/practices/practice_quiz/show.html.slimdb/migrate/20260627120621_create_practice_quiz_answers.rbdb/schema.rbtest/integration/practice_quizzes_test.rb
💤 Files with no reviewable changes (3)
- db/migrate/20260627120621_create_practice_quiz_answers.rb
- app/models/practice_quiz_answer.rb
- db/schema.rb
✅ Files skipped from review due to trivial changes (1)
- app/assets/stylesheets/application.css
🚧 Files skipped from review as they are similar to previous changes (7)
- app/views/mentor/practices/practice_quiz/questions/edit.html.slim
- app/views/mentor/practices/practice_quiz/_form.html.slim
- app/views/mentor/practices/practice_quiz/questions/_form.html.slim
- app/views/mentor/practices/practice_quiz/edit.html.slim
- app/views/mentor/practices/practice_quiz/questions/new.html.slim
- app/views/practices/practice_quiz/show.html.slim
- app/models/practice_quiz_attempt.rb
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/models/practice_quiz_choice.rb`:
- Line 5: The `practice_quiz_choice` association is currently destroying related
`practice_quiz_answers`, which can erase historical answer data when choices are
replaced. Update `has_many :practice_quiz_answers` to avoid cascading deletes
from `PracticeQuizChoice`—prefer restricting deletion or otherwise preserving
`practice_quiz_answers` so `practice_quiz_attempts` remain consistent. Keep the
fix localized to the `PracticeQuizChoice` model association.
In `@db/fixtures/practice_quiz_attempts.yml`:
- Around line 4-10: The practice quiz attempt fixtures use relative timestamps
in the `submitted_at` field, which makes cooldown and next-available-time
behavior depend on fixture load time. Update the `practice_quiz_attempts.yml`
fixture entries to use fixed, deterministic datetimes instead of `2.hours.ago`
and `20.minutes.ago`, or otherwise ensure the time source is fixed in the code
that reads these records.
🪄 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: CHILL
Plan: Pro
Run ID: 516111cd-4b32-40fb-ac44-03bea3a249a6
📒 Files selected for processing (8)
app/models/practice_quiz_choice.rbapp/models/practice_quiz_question.rbdb/fixtures/practice_quiz_answers.ymldb/fixtures/practice_quiz_attempts.ymldb/fixtures/practice_quiz_choices.ymldb/fixtures/practice_quiz_questions.ymldb/fixtures/practice_quizzes.ymldb/seeds.rb
✅ Files skipped from review due to trivial changes (1)
- db/fixtures/practice_quiz_answers.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- app/models/practice_quiz_question.rb
- 学生向けshowを状態別バナー+問題カード+block-checks選択肢に刷新し、 合格後は正解ハイライト・正解バッジ・解説ボックスを表示 - メンターの作成/編集/問題フォームを模範解答ページと同じ プラクティス文脈のヘッダー+タブ構成に統一し、カード・バッジ・ トグル式チェックでサーベイ機能と表現を揃える - クイズ専用スタイルを practice-quiz ブロックとして追加 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
de26891 to
f831eb8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
db/schema.rb (1)
589-597: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win
practice_quiz_answersに一意制約の追加を検討してください。
practice_quiz_attempt_idとpractice_quiz_choice_idの組み合わせに対するユニークインデックスがありません。二重送信や再送信バグにより同一の選択肢に対する回答が重複して保存される可能性があり、正答判定ロジックに影響しうるデータ整合性上のリスクとなります。💡 提案(マイグレーション例)
add_index :practice_quiz_answers, [:practice_quiz_attempt_id, :practice_quiz_choice_id], unique: true, name: 'index_practice_quiz_answers_uniqueness'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@db/schema.rb` around lines 589 - 597, `practice_quiz_answers` のデータ整合性を守るため、`practice_quiz_attempt_id` と `practice_quiz_choice_id` の組み合わせに一意制約を追加してください。`practice_quiz_answers` のスキーマ定義を更新し、`practice_quiz_answers` に対する複合ユニークインデックスを追加するマイグレーションを入れてください。既存の `practice_quiz_answers` の `practice_quiz_attempt_id` / `practice_quiz_choice_id` を参照する箇所も確認し、重複作成を防ぐ `PracticeQuizAnswer` の保存ロジックと整合するようにしてください。app/helpers/page_tabs/practices_helper.rb (1)
22-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLGTM(命名は軽微な懸念あり)
edit/new分岐によるパス決定ロジックは単純で正しいです。ただしmentor_practice_quiz_pathという命名は、実在するRailsルートヘルパーのように見えるため、実際にはローカルヘルパーであることが分かりにくい点は任意で改善余地があります(例:mentor_practice_quiz_management_path)。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/helpers/page_tabs/practices_helper.rb` around lines 22 - 28, The logic in mentor_practice_quiz_path is fine, but the name can be misleading because it looks like a generated Rails route helper rather than a local helper method. Consider renaming the helper to something more explicit, such as a management- or wrapper-style name, and update any callers so it is clear this method chooses between edit_mentor_practice_practice_quiz_path and new_mentor_practice_practice_quiz_path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/helpers/page_tabs/practices_helper.rb`:
- Line 17: The tab builder in page_tabs/practices_helper.rb is calling
current_user.admin_or_mentor? without handling guests, which can raise
NoMethodError on the public practice show page. Update the condition in the
helper method that adds the “理解度テスト管理” tab to safely handle a nil current_user,
using safe navigation or an equivalent nil check before calling
admin_or_mentor?. Keep the change localized to the tab generation logic so
authenticated users still see the tab and guests do not.
---
Nitpick comments:
In `@app/helpers/page_tabs/practices_helper.rb`:
- Around line 22-28: The logic in mentor_practice_quiz_path is fine, but the
name can be misleading because it looks like a generated Rails route helper
rather than a local helper method. Consider renaming the helper to something
more explicit, such as a management- or wrapper-style name, and update any
callers so it is clear this method chooses between
edit_mentor_practice_practice_quiz_path and
new_mentor_practice_practice_quiz_path.
In `@db/schema.rb`:
- Around line 589-597: `practice_quiz_answers`
のデータ整合性を守るため、`practice_quiz_attempt_id` と `practice_quiz_choice_id`
の組み合わせに一意制約を追加してください。`practice_quiz_answers` のスキーマ定義を更新し、`practice_quiz_answers`
に対する複合ユニークインデックスを追加するマイグレーションを入れてください。既存の `practice_quiz_answers` の
`practice_quiz_attempt_id` / `practice_quiz_choice_id` を参照する箇所も確認し、重複作成を防ぐ
`PracticeQuizAnswer` の保存ロジックと整合するようにしてください。
🪄 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: CHILL
Plan: Pro
Run ID: e334c60c-8207-4142-926b-72e6b8c2141f
📒 Files selected for processing (50)
app/assets/stylesheets/application.cssapp/assets/stylesheets/application/blocks/practice-quiz/_practice-quiz.cssapp/controllers/api/practices/learning_controller.rbapp/controllers/mentor/practices/practice_quiz/questions_controller.rbapp/controllers/mentor/practices/practice_quiz_controller.rbapp/controllers/practices/practice_quiz/attempts_controller.rbapp/controllers/practices/practice_quiz_controller.rbapp/helpers/page_tabs/practices_helper.rbapp/models/learning_status_updater.rbapp/models/practice.rbapp/models/practice_quiz.rbapp/models/practice_quiz_answer.rbapp/models/practice_quiz_attempt.rbapp/models/practice_quiz_choice.rbapp/models/practice_quiz_question.rbapp/views/mentor/practices/_mentor_practices.html.slimapp/views/mentor/practices/practice_quiz/_form.html.slimapp/views/mentor/practices/practice_quiz/edit.html.slimapp/views/mentor/practices/practice_quiz/new.html.slimapp/views/mentor/practices/practice_quiz/questions/_form.html.slimapp/views/mentor/practices/practice_quiz/questions/edit.html.slimapp/views/mentor/practices/practice_quiz/questions/new.html.slimapp/views/practices/practice_quiz/show.html.slimapp/views/practices/show.html.slimconfig/routes.rbconfig/routes/mentor.rbdb/fixtures/practice_quiz_answers.ymldb/fixtures/practice_quiz_attempts.ymldb/fixtures/practice_quiz_choices.ymldb/fixtures/practice_quiz_questions.ymldb/fixtures/practice_quizzes.ymldb/fixtures/practices.ymldb/migrate/20260627120612_create_practice_quizzes.rbdb/migrate/20260627120614_create_practice_quiz_questions.rbdb/migrate/20260627120616_create_practice_quiz_choices.rbdb/migrate/20260627120618_create_practice_quiz_attempts.rbdb/migrate/20260627120621_create_practice_quiz_answers.rbdb/schema.rbdb/seeds.rbtest/fixtures/practice_quiz_answers.ymltest/fixtures/practice_quiz_attempts.ymltest/fixtures/practice_quiz_choices.ymltest/fixtures/practice_quiz_questions.ymltest/fixtures/practice_quizzes.ymltest/integration/mentor/practice_quizzes_test.rbtest/integration/practice_quizzes_test.rbtest/models/learning_status_updater_test.rbtest/models/practice_quiz_attempt_test.rbtest/models/practice_quiz_question_test.rbtest/models/practice_quiz_test.rb
✅ Files skipped from review due to trivial changes (9)
- test/fixtures/practice_quiz_answers.yml
- test/fixtures/practice_quizzes.yml
- db/fixtures/practice_quiz_answers.yml
- test/fixtures/practice_quiz_attempts.yml
- test/fixtures/practice_quiz_questions.yml
- db/fixtures/practice_quizzes.yml
- test/fixtures/practice_quiz_choices.yml
- db/fixtures/practice_quiz_choices.yml
- db/fixtures/practices.yml
🚧 Files skipped from review as they are similar to previous changes (38)
- app/assets/stylesheets/application.css
- config/routes.rb
- test/models/learning_status_updater_test.rb
- app/controllers/practices/practice_quiz_controller.rb
- db/migrate/20260627120621_create_practice_quiz_answers.rb
- db/migrate/20260627120616_create_practice_quiz_choices.rb
- app/models/learning_status_updater.rb
- db/fixtures/practice_quiz_attempts.yml
- db/fixtures/practice_quiz_questions.yml
- db/seeds.rb
- app/views/mentor/practices/practice_quiz/questions/new.html.slim
- db/migrate/20260627120614_create_practice_quiz_questions.rb
- app/views/mentor/practices/practice_quiz/questions/edit.html.slim
- app/views/mentor/practices/practice_quiz/new.html.slim
- test/models/practice_quiz_attempt_test.rb
- app/assets/stylesheets/application/blocks/practice-quiz/_practice-quiz.css
- app/models/practice_quiz_choice.rb
- app/models/practice_quiz_attempt.rb
- app/models/practice_quiz_answer.rb
- db/migrate/20260627120618_create_practice_quiz_attempts.rb
- db/migrate/20260627120612_create_practice_quizzes.rb
- test/models/practice_quiz_question_test.rb
- config/routes/mentor.rb
- app/views/mentor/practices/_mentor_practices.html.slim
- test/models/practice_quiz_test.rb
- app/views/mentor/practices/practice_quiz/edit.html.slim
- app/views/practices/show.html.slim
- app/views/mentor/practices/practice_quiz/_form.html.slim
- app/views/practices/practice_quiz/show.html.slim
- app/views/mentor/practices/practice_quiz/questions/_form.html.slim
- app/models/practice_quiz.rb
- app/models/practice_quiz_question.rb
- app/controllers/mentor/practices/practice_quiz_controller.rb
- app/controllers/practices/practice_quiz/attempts_controller.rb
- app/controllers/mentor/practices/practice_quiz/questions_controller.rb
- app/models/practice.rb
- app/controllers/api/practices/learning_controller.rb
- test/integration/practice_quizzes_test.rb
概要
確認
Closes #10240
Summary by CodeRabbit
Flakewatch Report
Review App