feat: highest achievable grade#147
Draft
EllMoorby wants to merge 7 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a “Highest Achievable Score” metric (maximum possible final grade assuming 100% on all remaining assessments) and surfaces it across the dashboard and the user/year/semester/module views.
Changes:
- Added
highest_achievable_scoremethods toUniModule,Semester,Year, andUsermodels. - Displayed “Highest Achievable Score” alongside existing score stats in the dashboard and detail pages.
- Updated user predicted-score code formatting (block style) in
User#predicted_score.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| app/views/years/show.html.haml | Displays highest achievable score in the Year stats panel. |
| app/views/users/show.html.haml | Displays highest achievable score in the User stats panel. |
| app/views/uni_modules/show.html.haml | Displays highest achievable score in the Module stats panel. |
| app/views/shared/_dashboard_stats.html.haml | Displays highest achievable score on the dashboard. |
| app/views/semesters/show.html.haml | Displays highest achievable score in the Semester stats panel. |
| app/models/year.rb | Adds year-level aggregation of highest achievable score (credit-weighted). |
| app/models/user.rb | Adds user-level aggregation of highest achievable score (currently credit-weighted). |
| app/models/uni_module.rb | Adds module-level highest achievable score calculation. |
| app/models/semester.rb | Adds semester-level aggregation of highest achievable score (credit-share-weighted). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+50
to
+59
| # Gets the highest possible percentage grade of the year, if all uncompleted assessments were 100% | ||
| def highest_achievable_score(user) | ||
| return final_score if final_score.present? | ||
| return 0 if semesters.empty? | ||
|
|
||
| total_credits = credits | ||
| return 0 if total_credits.zero? | ||
|
|
||
| weighted_sum = semesters.sum { |s| s.highest_achievable_score(user) * s.credits } | ||
| (weighted_sum / total_credits).round(2) |
Comment on lines
+80
to
+84
| current = achieved_score(user) | ||
| done = completion_percentage(user) | ||
| return 100 if done == 0 && current == 0 | ||
|
|
||
| ((current * done) + (100 * (100 - done))) / 100.0 |
Contributor
Author
There was a problem hiding this comment.
Just checked, I think this is a correct change.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
I have converted to a draft, I will write tests before converting it back to being ready. |
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.
Highest Achievable Score
This PR adds the highest achievable grade to the dashboard and user, year, semester, module display. The highest achievable grade is the maximum possible final grade a student can achieve if they score 100% on all remaining assessments.
Why
Currently only their current grade and target are shown. This shows the user how much their grade can improve by, a useful metric for understanding if they can reach certain percentages (e.g 70% for a first) at a glance.
How
A new
highest_achievable_score(user)method is added toUniModule,Semester,YearandUser.UniModule#highest_achievable_scorecomputes the maximum score for a single module, taking into account the completion percentage and current achieved score. The other functions collects the module highest achievable score and weight by credits.The equation is:
Where
current=achieved_score(user)andcompletion=completion_percentage(user)UI Changes
The highest achievable score is displayed next to achieved score on the




Dashboard:
Year:
Semester:
Module: