Files
pwa/src/lib/assessment/scoring/reverseScoring.ts
T
ar.badieiandCursor 370ac15471 Ship Novya PWA with backend for deployable production use.
Fix production TypeScript builds and add DEPLOY.md so the app can be hosted from this repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 21:01:52 +03:30

35 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 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<string>(['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);
}