/** * PCQ-24 Reverse Scoring Configuration * * Reverse scoring formula: 7 - rawValue * After reversal, a value of 1 becomes 6, 2 becomes 5, 3 becomes 4, etc. * * Reverse-scored questions (as specified): * - pcq_13 (Question 13 — Resilience dimension) * - pcq_20 (Question 20 — Optimism dimension) * - pcq_23 (Question 23 — Optimism dimension) * * Scale: 1–6 * Reversed: 1→6, 2→5, 3→4, 4→3, 5→2, 6→1 */ import type { PcqLikertValue } from '@/config/pcq24'; /** Set of question IDs that must be reverse-scored */ export const REVERSE_SCORED_QUESTIONS = new Set(['pcq_13', 'pcq_20', 'pcq_23']); /** Returns true if the given question ID is reverse-scored */ export function isReverseScored(questionId: string): boolean { return REVERSE_SCORED_QUESTIONS.has(questionId); } /** * Apply the PCQ-24 reverse scoring formula: 7 − rawValue * * @param rawValue - Likert value as string or number (expected 1–6) * @returns reversed score (6→1, 5→2, 4→3, 3→4, 2→5, 1→6) */ export function applyReverseScoring(rawValue: PcqLikertValue | string): number { return 7 - Number(rawValue); }