# Bộ Tài Liệu Kỹ Thuật: Phân Hệ Quản Lý Bài Làm Của Học Viên & Chấm Bài Thi
> **Module Identifiers**: `web_exam_histories` & `web_student_exam_histories`  
> **Menu Path**: Quản lý lịch sử làm bài ➔ Quản lý bài làm của HV | **Route**: `exam-histories.index`

---

## 📌 Giới Thiệu Tổng Quan

Phân hệ **Quản lý bài làm của học viên & Chấm bài thi** là khối chức năng trung tâm điều phối toàn bộ quy trình sau thi (Post-Exam Workflow):
1. **Quản trị kết quả thi**: Tìm kiếm, lọc, phân loại và xuất dữ liệu bài thi 4 kỹ năng của học viên.
2. **Xem chi tiết bài làm**: Giao diện Modal trực quan hiển thị bài thi, câu trả lời, audio ghi âm, bài viết và đáp án.
3. **Chấm thi & Đánh giá (Grading)**: Cung cấp bộ công cụ chấm theo Rubric tiêu chuẩn quốc tế cho Writing và Speaking.
4. **Phân công & Điều phối chấm**: Gán giáo viên chấm thi theo kỹ năng / team, kiểm soát quyền chấm nghiêm ngặt.
5. **Kiểm định chất lượng (QA Phúc khảo)**: Cơ chế gán QA ngẫu nhiên, rà soát đối soát điểm và chốt điểm chính thức.
6. **Đồng bộ hệ thống**: Tích hợp đồng bộ điểm sang hệ thống ICL / Zeus.

---

## 📂 Cấu Trúc Bộ Tài Liệu

Bộ tài liệu kỹ thuật được chuẩn hóa thành 6 phần chuyên sâu:

| STT | Tài liệu | Nội dung chính | Liên kết |
| :---: | :--- | :--- | :--- |
| **01** | **Use Case & Luồng Hoạt Động** | • Danh sách tác nhân (Actor)<br>• Sơ đồ Use Case tổng thể<br>• Chi tiết 6 Use Case & Luồng hoạt động cốt lõi (Tra cứu, Xem chi tiết, Gán giáo viên, Chấm bài Writing/Speaking, QA Phúc khảo, Xuất báo cáo) kèm Sequence Diagram | [Xem chi tiết](file:///var/www/html/lms_hocmai/van-hanh-thi/quan-ly-bai-lam-hv/01_use_case_va_luong_hoat_dong.md) |
| **02** | **Quy Tắc Nghiệp Vụ & Tính Điểm** | • Vòng đời trạng thái bài thi (`exam_status`, `score_processing_status`)<br>• Phân loại Contest Types (19 ➔ 36)<br>• Công thức tính điểm IELTS Overall & Thuật toán làm tròn chuẩn quốc tế (.125, .25, .625, .75)<br>• Quy tắc chấm Rubric 4 tiêu chí Writing & Speaking<br>• Phân quyền chấm bài & Audit Trail lịch sử chấm<br>• Xử lý gian lận (Cheating) & Đồng bộ ICL | [Xem chi tiết](file:///var/www/html/lms_hocmai/van-hanh-thi/quan-ly-bai-lam-hv/02_business_logic.md) |
| **03** | **Sơ Đồ Chức Năng & Thiết Kế API** | • Kiến trúc thành phần hệ thống (Component Architecture)<br>• Flowchart xử lý chi tiết cho từng hàm trong `ExamHistoryController` và `StudentExamHistoryController`<br>• Quy trình xuất file Async qua Queue Job (`ExportExamHistoryJob`)<br>• Đặc tả chi tiết các API Endpoints (Request params, Response JSON) | [Xem chi tiết](file:///var/www/html/lms_hocmai/van-hanh-thi/quan-ly-bai-lam-hv/03_function_diagram_va_function_design.md) |
| **04** | **Cơ Sở Dữ Liệu & Schema** | • Sơ đồ thực thể liên kết (ERD Diagram)<br>• Từ điển dữ liệu (Data Dictionary) chi tiết kèm comment tiếng Việt từng cột cho các bảng: `student_score`, `student_exam_histories`, `student_score_grading_histories`, `teacher_assigned_histories`, `student_score_icl_logs` | [Xem chi tiết](file:///var/www/html/lms_hocmai/van-hanh-thi/quan-ly-bai-lam-hv/04_database_va_database_schema.md) |
| **05** | **Kịch Bản Kiểm Thử (Test Cases)** | • Ma trận kiểm thử chức năng giao diện (Search, Modal chi tiết, Gán GV, Chấm Rubric, Cheating flag, Export)<br>• Bộ kịch bản chi tiết P0-P2 (Tiền điều kiện, Các bước thao tác UI, Kết quả mong đợi)<br>• Kiểm thử biên làm tròn IELTS (.125, .25, .625, .75) & Xử lý ngoại lệ | [Xem chi tiết](file:///var/www/html/lms_hocmai/van-hanh-thi/quan-ly-bai-lam-hv/05_test_cases_va_kiem_thu.md) |
| **06** | **Hướng Dẫn Vận Hành & Sự Cố** | • Quy trình thao tác chuẩn (SOP) dành cho Cán bộ Vận hành và Giáo viên chấm thi<br>• Cẩm nang xử lý sự cố thường gặp (Lỗi không phát được Audio, Điểm làm tròn, Lỗi gán GV)<br>• Bảng cam kết thời gian hoàn thành (SLA 24h - 48h) | [Xem chi tiết](file:///var/www/html/lms_hocmai/van-hanh-thi/quan-ly-bai-lam-hv/06_huong_dan_van_hanh_va_troubleshooting.md) |

---

## 🛠️ Ma Trận File & Thành Phần Kỹ Thuật (Source Code Mapping)

| Khối Chức Năng | File Mã Nguồn Liên Quan |
| :--- | :--- |
| **Cấu hình Quyền & Menu** | • [config/tenant_groups.php](file:///var/www/html/lms_hocmai/config/tenant_groups.php#L549-L658) |
| **Định tuyến (Routes)** | • [routes/web.php](file:///var/www/html/lms_hocmai/routes/web.php#L586-L606) (`prefix: exam-histories`)<br>• [routes/web.php](file:///var/www/html/lms_hocmai/routes/web.php#L683-L702) (`prefix: student-exam-histories`)<br>• [routes/api.php](file:///var/www/html/lms_hocmai/routes/api.php#L1422-L1445) |
| **Controllers** | • [app/Http/Controllers/ExamHistoryController.php](file:///var/www/html/lms_hocmai/app/Http/Controllers/ExamHistoryController.php)<br>• [app/Http/Controllers/StudentExamHistoryController.php](file:///var/www/html/lms_hocmai/app/Http/Controllers/StudentExamHistoryController.php) |
| **Background Queue Job** | • `app/Jobs/ExportExamHistoryJob.php` |
| **Models (Eloquent)** | • `app/Models/StudentScore.php`<br>• `app/Models/StudentExamHistory.php`<br>• `app/Models/StudentScoreExt.php`<br>• `app/Models/StudentScoreGradingHistory.php`<br>• `app/Models/TeacherAssignedHistory.php`<br>• `app/Models/StudentExamHistoryTeacher.php`<br>• `app/Models/TeacherGradingLog.php`<br>• `app/Models/StudentScoreIclLog.php` |
| **Services & Engines** | • `app/Services/StudentExamHistoryService.php`<br>• `app/Services/AiHub/RoundMixOverallService.php`<br>• `app/Services/AiHub/ScoringScale/ScoringScaleFactory.php`<br>• `app/Services/IclScoreService.php`<br>• `app/Services/AiHub/ContestType19.php` ➔ `ContestType36.php` |
| **Giao diện (Blade Views)** | • `resources/views/exam-history/index-v2.blade.php`<br>• `resources/views/exam-history/detail.blade.php`<br>• `resources/views/exam-history/assessment.blade.php` |
| **Frontend Logic (JS)** | • `public/js/exam-history/exam-history.js`<br>• `public/js/exam-schedule-result/exam-history/exam-detail-modal.js`<br>• `public/js/exam-schedule-result/exam-history/exam-detail-modal.detail.js`<br>• `public/js/exam-schedule-result/exam-history/exam-detail-modal.edit.js` |
