143 lines
2.7 KiB
TypeScript
143 lines
2.7 KiB
TypeScript
|
|
/**
|
||
|
|
* @file course.ts
|
||
|
|
* @description Type definitions for courses, enrollments, quizzes, and certificates.
|
||
|
|
*/
|
||
|
|
|
||
|
|
export interface Course {
|
||
|
|
id: number
|
||
|
|
title: string | { th: string; en: string }
|
||
|
|
slug: string
|
||
|
|
description: string | { th: string; en: string }
|
||
|
|
thumbnail_url: string
|
||
|
|
price: string
|
||
|
|
is_free: boolean
|
||
|
|
original_price?: string
|
||
|
|
have_certificate: boolean
|
||
|
|
status: string
|
||
|
|
category_id: number
|
||
|
|
created_at?: string
|
||
|
|
updated_at?: string
|
||
|
|
created_by?: number
|
||
|
|
updated_by?: number
|
||
|
|
approved_at?: string
|
||
|
|
approved_by?: number
|
||
|
|
rejection_reason?: string
|
||
|
|
enrolled?: boolean
|
||
|
|
total_lessons?: number
|
||
|
|
rating?: string
|
||
|
|
lessons?: number | string
|
||
|
|
levelType?: 'neutral' | 'warning' | 'success'
|
||
|
|
chapters?: {
|
||
|
|
id: number
|
||
|
|
title: string | { th: string; en: string }
|
||
|
|
lessons: {
|
||
|
|
id: number
|
||
|
|
title: string | { th: string; en: string }
|
||
|
|
duration_minutes: number
|
||
|
|
video_url?: string
|
||
|
|
}[]
|
||
|
|
}[]
|
||
|
|
creator?: {
|
||
|
|
id: number
|
||
|
|
username: string
|
||
|
|
email: string
|
||
|
|
profile: {
|
||
|
|
first_name: string
|
||
|
|
last_name: string
|
||
|
|
avatar_url: string
|
||
|
|
}
|
||
|
|
}
|
||
|
|
instructors?: {
|
||
|
|
user_id: number
|
||
|
|
is_primary: boolean
|
||
|
|
user: {
|
||
|
|
id: number
|
||
|
|
username: string
|
||
|
|
email: string
|
||
|
|
profile: {
|
||
|
|
first_name: string
|
||
|
|
last_name: string
|
||
|
|
avatar_url: string
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}[]
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface CourseResponse {
|
||
|
|
code: number
|
||
|
|
message: string
|
||
|
|
data: Course[]
|
||
|
|
total: number
|
||
|
|
page?: number
|
||
|
|
limit?: number
|
||
|
|
totalPages?: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface SingleCourseResponse {
|
||
|
|
code: number
|
||
|
|
message: string
|
||
|
|
data: Course
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface EnrolledCourse {
|
||
|
|
id: number
|
||
|
|
course_id: number
|
||
|
|
course: Course
|
||
|
|
status: 'ENROLLED' | 'IN_PROGRESS' | 'COMPLETED' | 'DROPPED'
|
||
|
|
progress_percentage: number
|
||
|
|
enrolled_at: string
|
||
|
|
started_at?: string
|
||
|
|
completed_at?: string
|
||
|
|
last_accessed_at?: string
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface EnrolledCourseResponse {
|
||
|
|
code: number
|
||
|
|
message: string
|
||
|
|
data: EnrolledCourse[]
|
||
|
|
total: number
|
||
|
|
page: number
|
||
|
|
limit: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface QuizAnswerSubmission {
|
||
|
|
question_id: number
|
||
|
|
choice_id: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface QuizSubmitRequest {
|
||
|
|
answers: QuizAnswerSubmission[]
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface QuizResult {
|
||
|
|
answers_review: {
|
||
|
|
score: number
|
||
|
|
is_correct: boolean
|
||
|
|
correct_choice_id: number
|
||
|
|
selected_choice_id: number
|
||
|
|
question_id: number
|
||
|
|
}[]
|
||
|
|
completed_at: string
|
||
|
|
started_at: string
|
||
|
|
attempt_number: number
|
||
|
|
passing_score: number
|
||
|
|
is_passed: boolean
|
||
|
|
correct_answers: number
|
||
|
|
total_questions: number
|
||
|
|
total_score: number
|
||
|
|
score: number
|
||
|
|
quiz_id: number
|
||
|
|
attempt_id: number
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface Certificate {
|
||
|
|
certificate_id: number
|
||
|
|
course_id: number
|
||
|
|
course_title: {
|
||
|
|
en: string
|
||
|
|
th: string
|
||
|
|
}
|
||
|
|
issued_at: string
|
||
|
|
download_url: string
|
||
|
|
}
|