From 4b30679e7954ee8f1db0b5a0aaf491adf8bec5b0 Mon Sep 17 00:00:00 2001 From: Alexander Emelyanov Date: Mon, 8 Dec 2025 12:44:03 +0300 Subject: [PATCH] feat: Improved groups scoring display Added display of scores on a 10-point scale for each group of tasks. Scores are now displayed in standings and on the main page. Slightly reduced font sizes and styles on the home page. --- internal/scorer/results.go | 19 +++++++++++--- internal/scorer/scorer.go | 54 +++++++++++++++++++++++++++++++++----- web/home.tmpl | 35 ++++++++++++++++++++---- web/standings.tmpl | 21 ++++++++++++--- 4 files changed, 110 insertions(+), 19 deletions(-) diff --git a/internal/scorer/results.go b/internal/scorer/results.go index 38b900c..050a960 100644 --- a/internal/scorer/results.go +++ b/internal/scorer/results.go @@ -58,6 +58,15 @@ type ScoredTaskGroup struct { MaxScore int } +type ScoredScoringGroup struct { + Name string + Score int + MaxScore int + Weight float64 + WeightedScore float64 + TenScaleScore float64 +} + type User struct { FirstName string LastName string @@ -70,10 +79,12 @@ func (u User) FullName() string { } type UserScores struct { - Groups []ScoredTaskGroup - Score int - MaxScore int - FinalMark float64 + Groups []ScoredTaskGroup + ScoringGroups []ScoredScoringGroup + Score int + MaxScore int + FinalMark float64 + MaxFinalMark float64 User User } diff --git a/internal/scorer/scorer.go b/internal/scorer/scorer.go index 6c10a2b..73d187c 100644 --- a/internal/scorer/scorer.go +++ b/internal/scorer/scorer.go @@ -266,10 +266,11 @@ func (s Scorer) calcUserScoresImpl(currentDeadlines *deadlines.Deadlines, user * overrides := parseOverrides(rawOverrides) scores := &UserScores{ - Groups: make([]ScoredTaskGroup, 0), - Score: 0, - MaxScore: 0, - FinalMark: 0.0, + Groups: make([]ScoredTaskGroup, 0), + ScoringGroups: make([]ScoredScoringGroup, 0), + Score: 0, + MaxScore: 0, + FinalMark: 0.0, User: User{ FirstName: user.FirstName, LastName: user.LastName, @@ -278,6 +279,15 @@ func (s Scorer) calcUserScoresImpl(currentDeadlines *deadlines.Deadlines, user * }, } + groupStats := make(map[string]*ScoredScoringGroup) + for _, g := range currentDeadlines.Scoring.Groups { + groupStats[g.Name] = &ScoredScoringGroup{ + Name: g.Name, + Weight: g.Weight, + MaxScore: g.MaxScore, + } + } + for _, group := range currentDeadlines.Assignments { tasks := make([]ScoredTask, len(group.Tasks)) totalScore := 0 @@ -337,11 +347,43 @@ func (s Scorer) calcUserScoresImpl(currentDeadlines *deadlines.Deadlines, user * }) scores.Score += totalScore scores.MaxScore += maxTotalScore - if scoringGroup != nil && scoringGroup.MaxScore > 0 { - scores.FinalMark += scoringGroup.Weight * float64(totalScore) / float64(scoringGroup.MaxScore) + + if scoringGroup != nil { + stats, ok := groupStats[scoringGroup.Name] + if !ok { + stats = &ScoredScoringGroup{ + Name: scoringGroup.Name, + Weight: scoringGroup.Weight, + MaxScore: scoringGroup.MaxScore, + } + groupStats[scoringGroup.Name] = stats + } + stats.Score += totalScore + if scoringGroup.MaxScore == 0 { + stats.MaxScore += maxTotalScore + } } } + for _, g := range currentDeadlines.Scoring.Groups { + stats, ok := groupStats[g.Name] + if !ok { + continue + } + + if stats.MaxScore > 0 { + stats.WeightedScore = stats.Weight * float64(stats.Score) / float64(stats.MaxScore) + stats.TenScaleScore = 10.0 * float64(stats.Score) / float64(stats.MaxScore) + } else { + stats.WeightedScore = 0 + stats.TenScaleScore = 0 + } + + scores.MaxFinalMark += stats.Weight + scores.FinalMark += stats.WeightedScore + scores.ScoringGroups = append(scores.ScoringGroups, *stats) + } + return scores, nil } diff --git a/web/home.tmpl b/web/home.tmpl index 090dbbc..5f6b579 100644 --- a/web/home.tmpl +++ b/web/home.tmpl @@ -81,16 +81,41 @@ {{ if .Scores }} +
+
+
+
+
Final Mark
+
{{printf "%.2f" .Scores.FinalMark}}
+
+
+ {{ range .Scores.ScoringGroups }} +
+
{{ .Name }}
+
{{printf "%.1f" .TenScaleScore}}/10
+
{{ .Score }} / {{ .MaxScore }}
+
+ {{ end }} +
+
+
+ Max: {{printf "%.2f" .Scores.MaxFinalMark}} +
+
+
+ {{ range .Scores.Groups }}
-
+
-

- diff --git a/web/standings.tmpl b/web/standings.tmpl index 12dea6a..14df86c 100644 --- a/web/standings.tmpl +++ b/web/standings.tmpl @@ -134,8 +134,11 @@ # Student - {{ if $.GroupConfig.ShowMarks }}Mark{{ end }} - Score + Final Mark + {{ range .Standings.Deadlines.Scoring.Groups }} + {{ .Name }} ({{ .Weight }}) + {{ end }} + Total Score {{ range .Standings.Deadlines.Assignments }} {{ range .Tasks }} {{ .Task | prettifyTaskName }} @@ -148,7 +151,12 @@ 0 Chuck Norris - {{ if $.GroupConfig.ShowMarks }}13.37{{ end }} + {{printf "%.2f" .MaxFinalMark}} + {{ range .ScoringGroups }} + + 10.0 + + {{ end }} {{ .MaxScore }} {{ range .Groups }} {{ range .Tasks }} @@ -161,7 +169,12 @@ {{ inc $index }} {{ $user.User.FirstName }} {{ $user.User.LastName }} - {{ if $.GroupConfig.ShowMarks }}{{printf "%.3f" $user.FinalMark}}{{ end }} + {{printf "%.2f" $user.FinalMark}} + {{ range $user.ScoringGroups }} + + {{printf "%.1f" .TenScaleScore}} + + {{ end }} {{ $user.Score }} {{ range $user.Groups }} {{ range .Tasks }}