import type { AssessmentDefinition, AssessmentOption, AssessmentQuestion, EvaluationResult, LocalizedAssessmentView, ValidationResult } from "./types.ts"; import { AssessmentResponse } from "./response.ts"; import { type EvaluateOptions } from "./evaluation.ts"; /** * Structurally validates an assessment definition (useful before persisting * user-created assessments). Returns issues instead of throwing. */ export declare function validateDefinition(input: unknown): ValidationResult; /** * An assessment: questions plus an enumerated option scale, with helpers for * localization, serialization, response creation, and evaluation. */ export declare class Assessment { readonly definition: AssessmentDefinition; private readonly questionIndex; /** @throws PsytoolsError `invalid_definition` when the definition is malformed. */ constructor(definition: AssessmentDefinition); get id(): string; get questions(): readonly AssessmentQuestion[]; /** Locales for which at least one text of this assessment is available. */ get locales(): string[]; question(questionId: string): AssessmentQuestion | undefined; /** The option scale that applies to a question (its own or the default). */ optionsFor(questionId: string): readonly AssessmentOption[]; title(locale?: string): string; /** * Flat, render-ready projection in one locale — hand this straight to a * frontend to display the questionnaire. */ localize(locale?: string): LocalizedAssessmentView; /** Starts a new (empty) response for this assessment. */ createResponse(options?: { respondentId?: string; meta?: Record; }): AssessmentResponse; /** * Evaluates a response (or raw answers) with the definition's declarative * scoring, or with `options.evaluator` when provided. * * When given an `AssessmentResponse`, its status must be `complete` or * `submitted` — pass `allowIncomplete` to score partial responses anyway. * Raw answer maps skip the completeness check, but their values are * still validated against the option scales, and the scoring definition's * missing-data policy still applies. * * @throws PsytoolsError `incomplete_response` | `unknown_question` | `invalid_value` | `no_scoring` */ evaluate(response: AssessmentResponse | Record, options?: EvaluateOptions & { allowIncomplete?: boolean; }): EvaluationResult; /** The plain serializable definition (used by `JSON.stringify`). */ toJSON(): AssessmentDefinition; /** Serializes the definition to a JSON string (for DB storage etc.). */ stringify(space?: number): string; /** * Parses and validates a definition from a JSON string or plain object. * @throws PsytoolsError `invalid_json` | `invalid_definition` */ static parse(input: string | object): Assessment; private text; }