feat(assessment): assign the demonstration category and keep result history
This commit is contained in:
1 parent
b3c6dc870b
commit
8277133712
61 files changed
+4338
-268
No files matched your search
@@ -31,15 +31,90 @@ function result(patch: Record<string, unknown>): AssessmentResult {
|
||||
}
|
||||
|
||||
describe("assessmentResultSummary", () => {
|
||||
it("restates a confirmed grade without deriving one", () => {
|
||||
const decision = (status: string, patch: Record<string, unknown> = {}) => ({
|
||||
status,
|
||||
previous_confirmed_grade: null,
|
||||
current_confirmed_grade: null,
|
||||
method: "demo_basic_pass_mark",
|
||||
source: "synthetic_demo",
|
||||
calibration_status: "uncalibrated",
|
||||
...patch,
|
||||
});
|
||||
|
||||
it("restates an assigned grade without deriving one", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({ outcome: "confirmed", confirmed_grade: "middle" }),
|
||||
result({
|
||||
outcome: "confirmed",
|
||||
confirmed_grade: "middle",
|
||||
category_decision: decision("assigned", { current_confirmed_grade: "middle" }),
|
||||
}),
|
||||
);
|
||||
expect(summary.text).toBe("Уровень подтвержден: Backend, Middle.");
|
||||
expect(summary.reason).toBeNull();
|
||||
expect(summary.reason).toBe(
|
||||
"Это демонстрационная категория: пороги не калибровались, банк заданий демонстрационный.",
|
||||
);
|
||||
expect(summary.isDemonstration).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the higher grade when a reviewed result does not change the category", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({
|
||||
outcome: "confirmed",
|
||||
confirmed_grade: "middle",
|
||||
previous_confirmed_grade: "senior",
|
||||
category_decision: decision("unchanged", {
|
||||
previous_confirmed_grade: "senior",
|
||||
current_confirmed_grade: "senior",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(summary.text).toBe("Уровень подтвержден: Backend, Middle.");
|
||||
expect(summary.reason).toBe(
|
||||
"Прежний подтвержденный уровень Senior сохраняется. Это демонстрационная категория: пороги не калибровались, банк заданий демонстрационный.",
|
||||
);
|
||||
});
|
||||
|
||||
it("adds no demonstration note when neither calibration nor the bank says so", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({
|
||||
outcome: "confirmed",
|
||||
confirmed_grade: "middle",
|
||||
calibration_status: "calibrated",
|
||||
limitations: [],
|
||||
category_decision: decision("assigned", {
|
||||
current_confirmed_grade: "middle",
|
||||
calibration_status: "calibrated",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(summary.reason).toBeNull();
|
||||
});
|
||||
|
||||
it("says that the threshold was reached but no category was assigned", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({
|
||||
outcome: "confirmed",
|
||||
confirmed_grade: null,
|
||||
category_decision: decision("not_eligible", {
|
||||
method: null,
|
||||
source: null,
|
||||
calibration_status: null,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(summary.text).toBe("Порог пройден, категория не присвоена: Backend, Middle.");
|
||||
expect(summary.text).not.toContain("Уровень подтвержден");
|
||||
expect(summary.reason).toContain("отключены");
|
||||
});
|
||||
|
||||
it("does not claim a grade for a result stored before category decisions", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({ outcome: "confirmed", confirmed_grade: null }),
|
||||
);
|
||||
expect(summary.text).toBe("Порог пройден, категория не присвоена: Backend, Middle.");
|
||||
expect(summary.reason).toContain("без решения о категории");
|
||||
});
|
||||
|
||||
it("keeps the previous grade when nothing was confirmed", () => {
|
||||
const summary = assessmentResultSummary(
|
||||
result({ outcome: "not_confirmed", previous_confirmed_grade: "junior" }),
|
||||
|
||||
@@ -21,6 +21,14 @@ const notDeterminedReasons: Readonly<Record<NotDeterminedReason, string>> = {
|
||||
sandbox_unavailable: "Проверка практического решения была недоступна по технической причине.",
|
||||
};
|
||||
|
||||
/** Plain words for a passed threshold without an assigned category. */
|
||||
function noCategoryReason(status: string | undefined): string {
|
||||
if (status === "not_eligible") {
|
||||
return "Демонстрационные категории на этом стенде отключены или для этой проверки нет подтверждения оператора, поэтому уровень не присваивается.";
|
||||
}
|
||||
return "Результат сохранен без решения о категории, поэтому уровень не присваивается.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the text shown for a finished attempt. It only restates fields of
|
||||
* the server result and never derives a grade on its own.
|
||||
@@ -42,10 +50,35 @@ export function assessmentResultSummary(result: AssessmentResult): AssessmentRes
|
||||
|
||||
switch (result.outcome) {
|
||||
case "confirmed": {
|
||||
const grade = result.confirmed_grade ?? result.target_grade;
|
||||
const decisionStatus = result.category_decision?.status;
|
||||
if (
|
||||
result.confirmed_grade === null ||
|
||||
decisionStatus === "not_eligible" ||
|
||||
decisionStatus === undefined
|
||||
) {
|
||||
// The score reached the threshold, but the server assigned no category:
|
||||
// never present a grade that the server did not confirm.
|
||||
return {
|
||||
text: `Порог пройден, категория не присвоена: ${specialization}, ${gradeLabels[result.target_grade]}.`,
|
||||
reason: noCategoryReason(decisionStatus),
|
||||
isDemonstration,
|
||||
};
|
||||
}
|
||||
const demonstrational =
|
||||
result.category_decision?.calibration_status === "uncalibrated" ||
|
||||
result.calibration_status === "uncalibrated" ||
|
||||
result.limitations.includes("demo_bank");
|
||||
const reason = [
|
||||
decisionStatus === "unchanged" ? keptGrade : null,
|
||||
demonstrational
|
||||
? "Это демонстрационная категория: пороги не калибровались, банк заданий демонстрационный."
|
||||
: null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
return {
|
||||
text: `${outcomeLabels.confirmed}: ${specialization}, ${gradeLabels[grade]}.`,
|
||||
reason: null,
|
||||
text: `${outcomeLabels.confirmed}: ${specialization}, ${gradeLabels[result.confirmed_grade]}.`,
|
||||
reason: reason === "" ? null : reason,
|
||||
isDemonstration,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user