Stop calling a feedback-only grade "no numeric grade recorded"
You were right that the output was wrong, though not quite for the
reason given: the schema has no textual grade. It is
grade: { type: Number, min: 0, max: 100 } with gradeComment: String, so
"OK" is the comment, not the grade.
What the model does allow is exactly your case — teachers grade with the
comment alone and leave grade unset. Rendering that as "graded (no
numeric grade recorded)" reads as missing or broken data when in fact
the written verdict is the whole grade. It now says "graded by feedback,
with no percentage given", and reserves the it-is-absent wording for
when there is genuinely neither a percentage nor a comment.
Also fixes a real misrepresentation next to it: grade is a percentage,
and both the detail and list views printed it bare, so an 85 could be
read as a mark out of 100, 15 or 6. Now rendered as 85%.
formatGradeState is pure and covered by seven cases, including 0% staying
distinct from "no grade" — the bug that an `if (grade)` test would have
introduced.
85 tests, 38/38 smoke.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
46
test/submissions.test.ts
Normal file
46
test/submissions.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import { formatGradeState } from '../src/mcp/tools/submissions.ts';
|
||||
|
||||
/**
|
||||
* The schema has no textual grade — `grade` is a 0-100 percentage and
|
||||
* `gradeComment` is free text — but teachers commonly grade with the comment
|
||||
* alone. These cases keep the wording honest about which of those happened.
|
||||
*/
|
||||
describe('formatGradeState', () => {
|
||||
it('reports a percentage as a percentage, not a bare number', () => {
|
||||
assert.equal(formatGradeState({ isGraded: true, grade: 85 }, false), 'graded **85%**');
|
||||
});
|
||||
|
||||
it('keeps 0% distinct from "no grade given"', () => {
|
||||
assert.equal(formatGradeState({ isGraded: true, grade: 0 }, false), 'graded **0%**');
|
||||
});
|
||||
|
||||
it('treats feedback alone as the verdict, not as missing data', () => {
|
||||
// The real case: teacher wrote "OK" and set no percentage.
|
||||
assert.equal(
|
||||
formatGradeState({ isGraded: true, grade: null }, true),
|
||||
'graded by feedback, with no percentage given',
|
||||
);
|
||||
});
|
||||
|
||||
it('mentions both when a percentage and feedback are present', () => {
|
||||
assert.equal(formatGradeState({ isGraded: true, grade: 70 }, true), 'graded **70%**, with feedback');
|
||||
});
|
||||
|
||||
it('falls back to the percentage read off the page when the API omits it', () => {
|
||||
assert.equal(formatGradeState({ isGraded: true, grade: null }, false, 40), 'graded **40%**');
|
||||
});
|
||||
|
||||
it('says plainly when graded but nothing at all was found', () => {
|
||||
assert.match(
|
||||
formatGradeState({ isGraded: true, grade: null }, false),
|
||||
/neither a percentage nor feedback was found/,
|
||||
);
|
||||
});
|
||||
|
||||
it('does not claim a grade for an ungraded submission', () => {
|
||||
assert.equal(formatGradeState({ isGraded: false, grade: null }, false), 'not graded yet');
|
||||
assert.equal(formatGradeState({ isGraded: false, grade: null }, true), 'not graded yet');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user