T17 — E-Learning Certification: Cách gắn Survey tốt nghiệp vào khoá học
Tóm tắt
Odoo 19 E-Learning certification KHÔNG gắn survey vào slide.channel — phải tạo slide.slide với slide_category='certification' + survey_id. Ngoài ra, survey.question.answer.answer_score mặc định = 0.0 kể cả đáp án đúng → NV luôn fail nếu không fix.
Chi tiết
Issue 1: slide.channel KHÔNG có field survey_id
Nhiều tài liệu cũ (Odoo 14-16) nói slide.channel có survey_id để gắn certification survey. Odoo 19 không có field này.
Certification gắn qua slide.slide bên trong channel:
ĐÚNG — tạo/update slide thành certification slide
models.execute_kw(db, uid, key, 'slide.slide', 'write', [[slide_id], {
'slide_category': 'certification',
'slide_type': 'certification',
'survey_id': survey_id, # link tới survey.survey
}])
Computed fields trên slide.channel sau khi gắn:
nbr_certification: đếm slides có slide_category='certification'members_certified_count: đếm members đã pass certificationmembers_completed_count: đếm members hoàn thành 100% slidesIssue 2: survey.survey.certification mặc định = False
Tạo survey xong PHẢI bật certification=True thủ công:
models.execute_kw(db, uid, key, 'survey.survey', 'write', [[survey_id], {
'certification': True,
}])
Nếu không bật, survey chỉ là form khảo sát — không cấp badge, không track trên khoá học.
Issue 3: answer_score = 0.0 kể cả đáp án đúng (CRITICAL)
survey.question.answer có field is_correct=True nhưng answer_score mặc định = 0.0. Khi survey dùng scoring_type='scoring_with_answers', score tính bằng tổng answer_score, KHÔNG phải đếm is_correct.
→ NV trả lời đúng hết vẫn được 0% và fail.
Fix: set answer_score cho tất cả đáp án đúng
answers = models.execute_kw(db, uid, key, 'survey.question.answer', 'search_read',
[[('question_id.survey_id', '=', survey_id), ('is_correct', '=', True)]],
{'fields': ['id', 'answer_score'], 'limit': 0})
for a in answers:
if a['answer_score'] == 0.0:
models.execute_kw(db, uid, key, 'survey.question.answer', 'write',
[[a['id']], {'answer_score': 1.0}])
Issue 4: Fields KHÔNG tồn tại trong Odoo 19
| Model | Field bị lỗi | Thay thế |
|-------|-------------|----------|
| survey.survey | state | KHÔNG có — survey luôn active |
| slide.channel.partner | completed (boolean) | member_status ('joined', 'ongoing', 'completed') + completion (integer %) |
Issue 5: JSON-2 trả 500 cho survey.survey
survey.survey KHÔNG hoạt động qua JSON-2 endpoint — phải dùng XML-RPC.
SAI — 500 Internal Server Error
requests.post(f'{url}/json/2/survey.survey/search_read', ...)
ĐÚNG — XML-RPC
models.execute_kw(db, uid, key, 'survey.survey', 'search_read', [[]], {
'fields': ['title', 'scoring_type', 'certification'],
'limit': 0,
})
Cấu trúc đúng — E-Learning với Certification
slide.channel (khoá học)
├── slide.slide (article) — Bài 1 + quiz mini
├── slide.slide (article) — Bài 2 + quiz mini
├── ...
└── slide.slide (certification) ← slide_category='certification'
└── survey_id → survey.survey ← certification=True
├── survey.question (20 câu)
│ └── survey.question.answer ← answer_score=1.0 cho đáp án đúng
└── scoring_success_min=70%
Flow NV:
1. Học hết slides → completion=100%, member_status='completed'
2. Click certification slide → mở survey
3. Pass ≥ 70% → survey_certification_success=True → members_certified_count +1
4. Fail → thi lại (tuỳ is_attempts_limited)
Ảnh hưởng
Cách xử lý / Phòng tránh
1. Tạo khoá mới: Luôn tạo 1 slide slide_category='certification' ở cuối
2. Survey: Luôn bật certification=True + set scoring_success_min
3. Đáp án: Verify answer_score > 0 cho mọi đáp án đúng — KHÔNG tin is_correct alone
4. API: Dùng XML-RPC cho survey.survey — JSON-2 trả 500
5. Checklist tạo khoá:
- [ ] Channel tạo → slides tạo → quiz mini mỗi bài
- [ ] Survey tốt nghiệp tạo + certification=True + scoring
- [ ] Đáp án đúng có answer_score > 0
- [ ] Slide certification tạo + link survey_id
- [ ] Test 1 NV: học → thi → certified
Bằng chứng / Tham khảo
Liên quan
📚 Published from Company Knowledge Base — T17
Last updated: 2026-03-14
Review by: 2026-06-12