Skip to content

LMS assessments pass on absolute score instead of percentage of max_score #139

Description

@Senthil455

Describe the bug

In the LMS, an assessment attempt is graded "passed" against an absolute PassingScore instead of a percentage of the assessment's max score:

// lms-service/handlers/assessments.go:374
passed := totalScore >= assessment.PassingScore

Defaults are: MaxScore = 100, PassingScore = 70 (assessments.go:104-108). The endpoint lets callers set both (POST /api/v1/assessments / PUT). So:

  • An assessment with max_score = 200, passing_score = 70 (the default) → a candidate who scores 70/200 (35%) passes.
  • An assessment with max_score = 1000 and a passing threshold that should be 70% (700) instead passes at 70/1000 = 7%.

The declared passing_score is never normalized against max_score, so for any assessment where max_score != 100, the pass/fail outcome is effectively random relative to the intent.

Also worth noting: the maxScore used for reporting is recomputed server-side from answers (assessments.go:393) while totalScore is points summed from the answers map — with non-default weight scales the ratio drifts further.

Steps to reproduce

  1. Create an assessment with {"max_score": 200, "passing_score": 70} (defaults preview: passing 70)
  2. Open POST /api/v1/assessments/{id}/attempt start, submit answers summing to 70
  3. Attempt is PASSED, despite 70/200 = 35%

Expected behavior

passed = totalScore / maxScore >= passingScore / maxScore (or store the threshold as a percentage/ratio).

Actual behavior

passed = totalScore >= passingScore — absolute comparison.

Files involved

  • services/lms-service/handlers/assessments.go:352-378 (grading)
  • services/lms-service/handlers/assessments.go:104-108 (defaults)

Suggested fix

Either compute the pass threshold from max score consistently, or store passing_percentage and grade as totalScore/maxScore >= passingPercentage/100. Happy to open a PR with a unit test for the 200-max/existential-35% case.

Environment

  • docker compose, Go build, branch main @ 4afc605

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmediumMedium severity

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions