'use client' /** * Criteria scoring tab content. * Shows sliders and annotation counts for each grading criterion. */ import type { Annotation, GradeInfo, CriteriaScores, AnnotationType } from '../../app/admin/klausur-korrektur/types' import { ANNOTATION_COLORS } from '../../app/admin/klausur-korrektur/types' interface CriteriaTabProps { gradeInfo: GradeInfo criteriaScores: CriteriaScores annotations: Annotation[] onCriteriaChange: (criterion: string, value: number) => void onSelectTool: (tool: AnnotationType) => void } export default function CriteriaTab({ gradeInfo, criteriaScores, annotations, onCriteriaChange, onSelectTool, }: CriteriaTabProps) { return ( <> {Object.entries(gradeInfo.criteria || {}).map(([key, criterion]) => { const score = criteriaScores[key] || 0 const linkedAnnotations = annotations.filter( (a) => a.linked_criterion === key || a.type === key ) const errorCount = linkedAnnotations.length const severityCounts = { minor: linkedAnnotations.filter((a) => a.severity === 'minor').length, major: linkedAnnotations.filter((a) => a.severity === 'major').length, critical: linkedAnnotations.filter((a) => a.severity === 'critical').length, } const criterionColor = ANNOTATION_COLORS[key as AnnotationType] || '#6b7280' return (
{criterion.name} ({criterion.weight}%)
{score}%
{/* Annotation count for this criterion */} {errorCount > 0 && (
{errorCount} Markierungen: {severityCounts.minor > 0 && ( {severityCounts.minor} leicht )} {severityCounts.major > 0 && ( {severityCounts.major} mittel )} {severityCounts.critical > 0 && ( {severityCounts.critical} schwer )}
)} {/* Slider */} onCriteriaChange(key, parseInt(e.target.value))} className="w-full h-2 bg-slate-200 rounded-lg appearance-none cursor-pointer" style={{ accentColor: criterionColor }} /> {/* Quick buttons */}
{[0, 25, 50, 75, 100].map((val) => ( ))}
{/* Quick add annotation button for RS/Grammatik */} {(key === 'rechtschreibung' || key === 'grammatik') && ( )}
) })} ) }