Public Access
feat: add TypeScript types for exam platform
This commit is contained in:
1 parent
7ad0667668
commit
99b40e46dc
1 file changed
+124
@@ -0,0 +1,124 @@
|
|||||||
|
// src/types.ts
|
||||||
|
|
||||||
|
export type QuestionType =
|
||||||
|
| 'multiple-choice'
|
||||||
|
| 'multiple-select'
|
||||||
|
| 'short-answer'
|
||||||
|
| 'translation'
|
||||||
|
| 'math-input'
|
||||||
|
| 'essay'
|
||||||
|
| 'match'
|
||||||
|
| 'order'
|
||||||
|
|
||||||
|
export interface Choice {
|
||||||
|
id: string
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MatchItem {
|
||||||
|
id: string
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QuestionImage {
|
||||||
|
src: string
|
||||||
|
alt?: string
|
||||||
|
caption?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QuestionAudio {
|
||||||
|
src: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QuestionCode {
|
||||||
|
language: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface QuestionTable {
|
||||||
|
headers: string[]
|
||||||
|
rows: string[][]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Question {
|
||||||
|
id: string
|
||||||
|
type: QuestionType
|
||||||
|
category?: string
|
||||||
|
points?: number
|
||||||
|
prompt: string
|
||||||
|
explanation?: string
|
||||||
|
image?: QuestionImage
|
||||||
|
audio?: QuestionAudio
|
||||||
|
code?: QuestionCode
|
||||||
|
table?: QuestionTable
|
||||||
|
svg?: string
|
||||||
|
answer?: string | string[] | Record<string, string>
|
||||||
|
acceptedForms?: string[]
|
||||||
|
caseSensitive?: boolean
|
||||||
|
ignorePunctuation?: boolean
|
||||||
|
ignoreAccents?: boolean
|
||||||
|
sourceLanguage?: string
|
||||||
|
targetLanguage?: string
|
||||||
|
choices?: Choice[]
|
||||||
|
minWords?: number
|
||||||
|
rubric?: string[]
|
||||||
|
left?: MatchItem[]
|
||||||
|
right?: MatchItem[]
|
||||||
|
items?: MatchItem[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Exam {
|
||||||
|
title: string
|
||||||
|
subtitle?: string
|
||||||
|
author?: string
|
||||||
|
timeLimitMinutes?: number | null
|
||||||
|
feedbackMode?: 'end' | 'immediate'
|
||||||
|
passingScore?: number
|
||||||
|
categories?: string[]
|
||||||
|
questions: Question[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FeedbackMode = 'immediate' | 'end'
|
||||||
|
|
||||||
|
export interface ExamState {
|
||||||
|
currentIdx: number
|
||||||
|
answers: Record<string, unknown>
|
||||||
|
flags: Record<string, boolean>
|
||||||
|
revealed: Record<string, boolean>
|
||||||
|
startedAt: number
|
||||||
|
completedAt?: number
|
||||||
|
feedbackMode: FeedbackMode
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HistoryEntry {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
completedAt: number
|
||||||
|
elapsedMs: number
|
||||||
|
gradedCount: number
|
||||||
|
correctCount: number
|
||||||
|
totalPoints: number
|
||||||
|
scorePoints: number
|
||||||
|
passingScore: number
|
||||||
|
exam: Exam
|
||||||
|
state: ExamState
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GradeStatus = 'correct' | 'wrong' | 'ungraded' | 'unanswered'
|
||||||
|
|
||||||
|
export interface GradeResult {
|
||||||
|
status: GradeStatus
|
||||||
|
correct: boolean
|
||||||
|
points: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AppScreen = 'landing' | 'exam' | 'results' | 'review'
|
||||||
|
export type ThemeMode = 'light' | 'dark'
|
||||||
|
export type FontSize = 'small' | 'medium' | 'large'
|
||||||
|
export type FeedbackTweak = 'auto' | 'immediate' | 'end'
|
||||||
|
|
||||||
|
export interface Tweaks {
|
||||||
|
theme: ThemeMode
|
||||||
|
fontSize: FontSize
|
||||||
|
feedbackMode: FeedbackTweak
|
||||||
|
}
|
||||||
Reference in new issue
Block a user