<?php

declare(strict_types=1);

use Illuminate\Support\Facades\Route;

// 课程管理
Route::apiResource('courses', \Kylin\Education\Http\Controllers\CourseController::class);
Route::get('courses/{course}/chapters', [\Kylin\Education\Http\Controllers\CourseChapterController::class, 'index']);
Route::post('courses/{course}/chapters', [\Kylin\Education\Http\Controllers\CourseChapterController::class, 'store']);
Route::put('courses/{course}/chapters/{chapter}', [\Kylin\Education\Http\Controllers\CourseChapterController::class, 'update']);
Route::delete('courses/{course}/chapters/{chapter}', [\Kylin\Education\Http\Controllers\CourseChapterController::class, 'destroy']);
Route::post('courses/{course}/submit-review', [\Kylin\Education\Http\Controllers\CourseController::class, 'submitReview']);
Route::post('courses/{course}/publish', [\Kylin\Education\Http\Controllers\CourseController::class, 'publish']);
Route::post('courses/{course}/archive', [\Kylin\Education\Http\Controllers\CourseController::class, 'archive']);

// 课程分类
Route::apiResource('course-categories', \Kylin\Education\Http\Controllers\CourseCategoryController::class);

// 学员管理
Route::apiResource('students', \Kylin\Education\Http\Controllers\StudentController::class);
Route::post('students/{student}/enroll', [\Kylin\Education\Http\Controllers\StudentController::class, 'enroll']);
Route::post('students/{student}/withdraw', [\Kylin\Education\Http\Controllers\StudentController::class, 'withdraw']);
Route::post('students/import', [\Kylin\Education\Http\Controllers\StudentController::class, 'import']);
Route::get('students/export', [\Kylin\Education\Http\Controllers\StudentController::class, 'export']);

// 班级管理
Route::apiResource('student-classes', \Kylin\Education\Http\Controllers\StudentClassController::class);

// 排课系统
Route::apiResource('schedules', \Kylin\Education\Http\Controllers\ScheduleController::class);
Route::post('schedules/auto', [\Kylin\Education\Http\Controllers\ScheduleController::class, 'autoSchedule']);
Route::get('schedules/conflicts', [\Kylin\Education\Http\Controllers\ScheduleController::class, 'checkConflicts']);

// 教室管理
Route::apiResource('classrooms', \Kylin\Education\Http\Controllers\ClassroomController::class);

// 在线考试
Route::apiResource('exams', \Kylin\Education\Http\Controllers\ExamController::class);
Route::post('exams/{exam}/start', [\Kylin\Education\Http\Controllers\ExamController::class, 'start']);
Route::post('exams/{exam}/publish', [\Kylin\Education\Http\Controllers\ExamController::class, 'publish']);

// 题库管理
Route::apiResource('questions', \Kylin\Education\Http\Controllers\QuestionController::class);
Route::post('questions/import', [\Kylin\Education\Http\Controllers\QuestionController::class, 'import']);

// 答题
Route::post('attempts/{attempt}/answer', [\Kylin\Education\Http\Controllers\AttemptController::class, 'answer']);
Route::post('attempts/{attempt}/submit', [\Kylin\Education\Http\Controllers\AttemptController::class, 'submit']);
