Support the 4.0 grading scale

Closes #2 (closed)

What changed

  • src/gpa.js: added 4-point bands and degree classes, a strict validateScale helper (only the numbers 4 and 5; undefined defaults to 5), and an optional scale parameter on gradeFor, classOfDegree and computeGpa. The response scale now echoes the scale used.
  • src/server.js: POST /api/gpa passes body.scale through. Invalid values return 400 via ValidationError.
  • public/index.html: scale selector (5-point or 4-point). It sends scale in the request and updates the subtitle and result text.
  • Tests added in test/gpa.test.js and test/server.test.js. CHANGELOG.md updated.

Assumptions

  • Existing class labels are kept ("Second Class Upper" and "Second Class Lower").
  • A 4.0 GPA below 1.0 is labelled "Fail".

How it was tested

  • npm test: 22 tests pass, 97% line coverage (gpa.js at 100%).
  • npx eslint@9 .: 0 errors.
  • Covered: 4.0 band and class boundaries, a computed 4.0 GPA, default-5 regression, and invalid scales (3, "4", null, 4.5) returning 400.

No new dependencies.

Opened by Relay Builder. Relay Shepherd is now watching the pipeline.

Merge request reports

Loading
Loading