fix: QA report bugs BUG-01 through BUG-11 resolved - streak modal close btn, calculator crash guard, AI chat auto-scroll, leaderboard zero-streak fix, name annotation cleanup everywhere, CBT score display colors, PrepPilot difficulty badge layout
This commit is contained in:
@@ -411,7 +411,14 @@ export default function CBTPage() {
|
||||
</div>
|
||||
) : attempts.filter(a => a.source_type === "Test" && exams.some(e => e.id === a.source_id)).map((attempt, i) => {
|
||||
const exam = exams.find(e => e.id === attempt.source_id);
|
||||
const scoreCalc = (attempt.score * 4) - ((attempt.total_questions - attempt.score) * 1); // rough calc for display
|
||||
// BUG-07 fix: use actual final_score from backend if available, else derive correctly
|
||||
// backend stores final_score = (correct*4) - (incorrect*1)
|
||||
const correctCount = attempt.answers ? attempt.answers.filter((a: any) => a.is_correct).length : attempt.score;
|
||||
const incorrectCount = attempt.answers ? (attempt.answers.filter((a: any) => a.selected_answer !== null).length - correctCount) : 0;
|
||||
const scoreCalc = attempt.final_score ?? ((correctCount * 4) - (incorrectCount * 1));
|
||||
const maxScore = attempt.total_questions * 4;
|
||||
const scorePercent = maxScore > 0 ? (scoreCalc / maxScore) * 100 : 0;
|
||||
const scoreColor = scorePercent >= 60 ? 'text-green-500' : scorePercent >= 35 ? 'text-amber-500' : 'text-red-500';
|
||||
|
||||
return (
|
||||
<Card key={i} className="bg-secondary/20">
|
||||
@@ -424,8 +431,8 @@ export default function CBTPage() {
|
||||
<div className="text-right">
|
||||
<div className="text-xs md:text-sm text-muted-foreground font-bold uppercase tracking-wider">Score</div>
|
||||
<div className="font-bold text-base md:text-lg">
|
||||
<span className="text-foreground">{scoreCalc}</span>
|
||||
<span className="text-muted-foreground">/{attempt.total_questions * 4}</span>
|
||||
<span className={scoreColor}>{scoreCalc}</span>
|
||||
<span className="text-muted-foreground">/{maxScore}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
|
||||
Reference in New Issue
Block a user