Skip to content

feat: highest achievable grade#147

Draft
EllMoorby wants to merge 7 commits into
Turnlings:mainfrom
EllMoorby:feature/highest-achievable-grade
Draft

feat: highest achievable grade#147
EllMoorby wants to merge 7 commits into
Turnlings:mainfrom
EllMoorby:feature/highest-achievable-grade

Conversation

@EllMoorby

Copy link
Copy Markdown
Contributor

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 to UniModule, Semester, Year and User. UniModule#highest_achievable_score computes 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:

(current × completion% + 100 × (100 - completion%)) / 100

Where current=achieved_score(user) and completion=completion_percentage(user)

UI Changes

The highest achievable score is displayed next to achieved score on the
Dashboard:
image
Year:
image
Semester:
image
Module:
image

Copilot AI 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.

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_score methods to UniModule, Semester, Year, and User models.
  • 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 thread app/models/user.rb
Comment thread app/models/year.rb
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 thread app/models/uni_module.rb Outdated
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just checked, I think this is a correct change.

@EllMoorby EllMoorby marked this pull request as draft July 14, 2026 19:26
@EllMoorby

Copy link
Copy Markdown
Contributor Author

I have converted to a draft, I will write tests before converting it back to being ready.

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.

3 participants