Exam mode: Color the result percentage from the up-to-date score after a complaint#13123
Exam mode: Color the result percentage from the up-to-date score after a complaint#13123az108 wants to merge 1 commit into
Exam mode: Color the result percentage from the up-to-date score after a complaint#13123Conversation
In the exam result summary the achieved percentage was colored from the participation's latest result, while the percentage itself comes from the exam grade info. After an accepted complaint the grade info is updated but the participation result can be stale, so a 100% score stayed red. Derive the color/icon from the same achieved score used for the percentage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
WalkthroughThe ChangesExam Result Color Fix
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Student
participant ExamResultSummaryComponent
participant StudentParticipation
participant ExamGradeInfo
Student->>ExamResultSummaryComponent: View exam result
ExamResultSummaryComponent->>StudentParticipation: getLatestResultOfStudentParticipation(exercise)
StudentParticipation-->>ExamResultSummaryComponent: participation result
ExamResultSummaryComponent->>ExamGradeInfo: getExerciseResultByExerciseId(exercise.id)
ExamGradeInfo-->>ExamResultSummaryComponent: achievedScore
alt achievedScore present
ExamResultSummaryComponent->>ExamResultSummaryComponent: override result.score with achievedScore
end
ExamResultSummaryComponent->>ExamResultSummaryComponent: getTextColorClass / getResultIconClass
ExamResultSummaryComponent-->>Student: Render color/icon
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/main/webapp/app/exam/overview/summary/exam-result-summary.component.spec.ts (1)
533-550: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlso assert
resultIconClassfor full coverage.Both new tests only check
textColorClass, but the fix ingetTextColorAndIconClassByExerciseoverrides the score used for bothtextColorClassandresultIconClass. Asserting the icon class too would fully cover the changed behavior.✅ Suggested additional assertions
- expect(component.getTextColorAndIconClassByExercise(exercise).textColorClass).toBe('text-success'); + const { textColorClass, resultIconClass } = component.getTextColorAndIconClassByExercise(exercise); + expect(textColorClass).toBe('text-success'); + expect(resultIconClass).toBeDefined();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/webapp/app/exam/overview/summary/exam-result-summary.component.spec.ts` around lines 533 - 550, The new tests for getTextColorAndIconClassByExercise only assert textColorClass, but the same authoritative-score fallback also affects resultIconClass. Update both test cases in exam-result-summary.component.spec.ts to assert the expected resultIconClass alongside textColorClass so the changed behavior in getTextColorAndIconClassByExercise is fully covered.src/main/webapp/app/exam/overview/summary/exam-result-summary.component.ts (1)
502-513: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse a class-preserving copy instead of object spread here.
Resultis a class, soObject.assign(new Result(), result, { score: achievedScore })keeps the instance shape and avoids the spread operator guideline.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/webapp/app/exam/overview/summary/exam-result-summary.component.ts` around lines 502 - 513, The Result object is being copied with object spread in getTextColorAndIconClassByExercise, which loses the class instance shape. Update this branch to create a class-preserving copy using Result as the target (for example via Object.assign with a new Result instance), while keeping the achievedScore override from getExerciseResultByExerciseId(exercise.id). Use getTextColorAndIconClassByExercise and Result to locate the change.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/main/webapp/app/exam/overview/summary/exam-result-summary.component.spec.ts`:
- Around line 533-550: The new tests for getTextColorAndIconClassByExercise only
assert textColorClass, but the same authoritative-score fallback also affects
resultIconClass. Update both test cases in exam-result-summary.component.spec.ts
to assert the expected resultIconClass alongside textColorClass so the changed
behavior in getTextColorAndIconClassByExercise is fully covered.
In `@src/main/webapp/app/exam/overview/summary/exam-result-summary.component.ts`:
- Around line 502-513: The Result object is being copied with object spread in
getTextColorAndIconClassByExercise, which loses the class instance shape. Update
this branch to create a class-preserving copy using Result as the target (for
example via Object.assign with a new Result instance), while keeping the
achievedScore override from getExerciseResultByExerciseId(exercise.id). Use
getTextColorAndIconClassByExercise and Result to locate the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ac702bc9-16cd-4d0e-bad0-c37f40a692d1
📒 Files selected for processing (2)
src/main/webapp/app/exam/overview/summary/exam-result-summary.component.spec.tssrc/main/webapp/app/exam/overview/summary/exam-result-summary.component.ts
End-to-End Test Results
❌ Failed Tests (Phase 1)
Flakiness Scores for Failed Tests
Test Strategy: Two-phase execution
Overall: ❌ E2E tests failed |
Summary
In the exam result summary, the achieved-points percentage kept the red "low score" color even when it showed 100% after a successful complaint. The percentage value is taken from the exam grade info (
studentResult.exerciseGroupIdToExerciseResult[…].achievedScore), which is updated when a complaint is accepted, but the color/icon were derived from the participation's latest result (getLatestResultOfStudentParticipation(...)), which can still hold the pre-complaint (failing) score. The two sources diverged, so a 100% cell stayed red. This PR derives the color/icon from the same authoritative score used for the displayed percentage.Checklist
General
Client
Motivation and Context
Closes #13064.
A green "100%" that renders red is confusing and looks like a bug to students reviewing their exam. The color must match the score that is actually displayed.
Description
ExamResultSummaryComponent.getTextColorAndIconClassByExercise, when an authoritativeachievedScoreexists for the exercise (from the exam grade info — the same source that feeds the displayed percentage), use it as the result's score before computing the text color and result icon. The participation result is otherwise unchanged, so all existing special cases (late, preliminary, build failed, Athena, unsubmitted) are preserved.achievedScoreare present; otherwise the previous behavior (color from the participation result) is kept — covered by a fallback test.achievedScore: 100now yieldstext-success; (2) with no authoritative exam score, the color still falls back to the participation result.Steps for Testing
Prerequisites:
Screenshots
To be added.
Summary by CodeRabbit