/**
 * KorrekturPage Constants — grade tables, criteria definitions, types.
 *
 * Extracted from KorrekturPage.tsx.
 */

// Grade calculation
export const GRADE_THRESHOLDS: Record<number, number> = {
  15: 95, 14: 90, 13: 85, 12: 80, 11: 75, 10: 70,
  9: 65, 8: 60, 7: 55, 6: 50, 5: 45, 4: 40,
  3: 33, 2: 27, 1: 20, 0: 0
}

export const GRADE_LABELS: Record<number, string> = {
  15: '1+', 14: '1', 13: '1-', 12: '2+', 11: '2', 10: '2-',
  9: '3+', 8: '3', 7: '3-', 6: '4+', 5: '4', 4: '4-',
  3: '5+', 2: '5', 1: '5-', 0: '6'
}

export const CRITERIA = [
  { key: 'inhalt', label: 'Inhaltliche Leistung', weight: 0.40 },
  { key: 'struktur', label: 'Aufbau & Struktur', weight: 0.15 },
  { key: 'stil', label: 'Ausdruck & Stil', weight: 0.15 },
  { key: 'grammatik', label: 'Grammatik', weight: 0.15 },
  { key: 'rechtschreibung', label: 'Rechtschreibung', weight: 0.15 }
] as const

export type WizardStep = 'korrektur' | 'bewertung' | 'gutachten'

export function calculateGradePoints(percentage: number): number {
  for (const [points, threshold] of Object.entries(GRADE_THRESHOLDS).sort((a, b) => Number(b[0]) - Number(a[0]))) {
    if (percentage >= threshold) {
      return Number(points)
    }
  }
  return 0
}
