Add AI grading statistics/feedback and refined AI comment persistence workflow#1345
Open
tzj04 wants to merge 71 commits intosource-academy:masterfrom
Open
Add AI grading statistics/feedback and refined AI comment persistence workflow#1345tzj04 wants to merge 71 commits intosource-academy:masterfrom
tzj04 wants to merge 71 commits intosource-academy:masterfrom
Conversation
…t/ai-comment-workflow
There was a problem hiding this comment.
Pull request overview
Adds backend support for tracking LLM “Generate Comments” usage + collecting feedback, while updating the AI comments flow to store chosen comment indices and per-comment edit/version history. Also extends assessment aggregates to expose whether an assessment contains any LLM-enabled questions.
Changes:
- Introduces
LLMStatscontext + schemas, with admin endpoints for per-assessment/per-question usage stats and feedback submission/retrieval. - Refactors AI comment finalization to persist
selected_indices, finalization metadata, and per-comment version entries (tutor edits). - Extends assessment aggregates with
has_llm_questionsand exposesisLlmGradedin assessment JSON views.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| priv/repo/migrations/20260316123000_remove_diff_columns_from_ai_comment_versions.exs | Drops unused diff columns from ai_comment_versions. |
| priv/repo/migrations/20260316120000_remove_final_comment_from_ai_comment_logs.exs | Removes legacy final_comment column from ai_comment_logs. |
| priv/repo/migrations/20260303120002_add_question_id_to_llm_feedback.exs | Adds question_id FK + index to llm_feedback. |
| priv/repo/migrations/20260303120001_create_llm_feedback.exs | Creates llm_feedback table for user feedback. |
| priv/repo/migrations/20260303120000_create_llm_usage_logs.exs | Creates llm_usage_logs table for usage events. |
| priv/repo/migrations/20260225120001_add_fields_to_ai_comments.exs | Adds selected/finalization metadata fields to ai_comment_logs. |
| priv/repo/migrations/20260225120000_create_ai_comment_versions.exs | Creates ai_comment_versions table for per-comment edit history. |
| lib/cadet/llm_stats/llm_usage_log.ex | Ecto schema/changeset for usage log inserts. |
| lib/cadet/llm_stats/llm_feedback.ex | Ecto schema/changeset for feedback inserts. |
| lib/cadet/llm_stats.ex | Context queries for usage stats aggregation + feedback workflows. |
| lib/cadet/assessments/query.ex | Adds has_llm_questions aggregate via JSON prompt detection. |
| lib/cadet/assessments/assessment.ex | Adds virtual has_llm_questions field to assessment struct. |
| lib/cadet/ai_comments/ai_comment.ex | Updates AI comment schema to new finalization fields + versions association. |
| lib/cadet/ai_comments/ai_comment_version.ex | New schema/changeset for comment version rows. |
| lib/cadet/ai_comments.ex | Adds APIs to save selections and create/fetch comment versions. |
| lib/cadet_web/views/assessments_view.ex | Exposes isLlmGraded in student-facing assessment JSON. |
| lib/cadet_web/admin_views/admin_assessments_view.ex | Exposes isLlmGraded in admin assessment JSON. |
| lib/cadet_web/router.ex | Adds admin routes for LLM stats/feedback; updates save-chosen-comments route. |
| lib/cadet_web/controllers/generate_ai_comments.ex | Logs usage; replaces final-comment saving with chosen-indices + edits/versioning; updates swagger docs. |
| lib/cadet_web/admin_controllers/admin_llm_stats_controller.ex | New controller for LLM stats + feedback endpoints. |
| config/cadet.exs | Adds an example production configuration file. |
| .tool-versions | Adds Elixir/Erlang tool version pins. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
priv/repo/migrations/20260316120000_remove_final_comment_from_ai_comment_logs.exs
Outdated
Show resolved
Hide resolved
priv/repo/migrations/20260316123000_remove_diff_columns_from_ai_comment_versions.exs
Outdated
Show resolved
Hide resolved
priv/repo/migrations/20260225120000_create_ai_comment_versions.exs
Outdated
Show resolved
Hide resolved
RichDom2185
requested changes
Mar 16, 2026
Member
RichDom2185
left a comment
There was a problem hiding this comment.
In addition to the Copilot comments
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…to create migration
…t 500 on invalid route params
…ROMPT for task-level llm_prompt
…ore exposing AI grading prompts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the AI comment workflow backend and LLM usage tracking end-to-end.
What Changed
Backend Scope
lib/cadet/ai_comments.exlib/cadet/ai_comments/ai_comment.exlib/cadet/ai_comments/ai_comment_version.exlib/cadet/llm_stats.exlib/cadet/llm_stats/llm_usage_log.exlib/cadet/llm_stats/llm_feedback.exlib/cadet_web/controllers/generate_ai_comments.exlib/cadet_web/admin_controllers/admin_llm_stats_controller.exlib/cadet_web/router.expriv/repo/migrations/20260225120000_create_ai_comment_versions.exspriv/repo/migrations/20260225120001_add_fields_to_ai_comments.exspriv/repo/migrations/20260303120000_create_llm_usage_logs.exspriv/repo/migrations/20260303120001_create_llm_feedback.exspriv/repo/migrations/20260303120002_add_question_id_to_llm_feedback.exspriv/repo/migrations/20260316120000_remove_final_comment_from_ai_comment_logs.exspriv/repo/migrations/20260316123000_remove_diff_columns_from_ai_comment_versions.exs