aboutsummaryrefslogtreecommitdiff
path: root/scoring.go
diff options
context:
space:
mode:
Diffstat (limited to 'scoring.go')
-rw-r--r--scoring.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/scoring.go b/scoring.go
new file mode 100644
index 0000000..675058a
--- /dev/null
+++ b/scoring.go
@@ -0,0 +1,31 @@
+package planr
+
+type Scoring struct {
+ EarnedPoints float64
+ TotalPoints float64
+ Passed int
+ Total int
+}
+
+func Score(trs []TestResult) Scoring {
+ score := Scoring {}
+
+ for _, tr := range trs {
+ cfg := tr.Tc.Config
+ points := 0.0
+
+ if cfg.Points != nil {
+ points = float64(*cfg.Points)
+ }
+
+ score.TotalPoints += points
+ if tr.Status == PASSING {
+ score.EarnedPoints += points
+ score.Passed++
+ }
+
+ score.Total += 1
+ }
+
+ return score
+}