from odoo import models, fields


class EncoachCourseModule(models.Model):
    _name = 'encoach.course.module'
    _description = 'Course Module'

    name = fields.Char(size=200, required=True)
    course_id = fields.Many2one('op.course', required=True, ondelete='cascade')
    cefr_target = fields.Selection([
        ('pre_a1', 'Pre-A1'),
        ('a1', 'A1'),
        ('a2', 'A2'),
        ('b1', 'B1'),
        ('b2', 'B2'),
        ('c1', 'C1'),
        ('c2', 'C2'),
    ])
    auto_generated = fields.Boolean(default=False)
    generation_brief = fields.Text()
    completion_criteria = fields.Selection([
        ('all_resources', 'All Resources'),
        ('score_threshold', 'Score Threshold'),
        ('teacher_approval', 'Teacher Approval'),
    ], default='all_resources')
    score_threshold = fields.Float()
    prerequisite_module_id = fields.Many2one('encoach.course.module', ondelete='set null')
    status = fields.Selection([
        ('locked', 'Locked'),
        ('available', 'Available'),
        ('in_progress', 'In Progress'),
        ('completed', 'Completed'),
        ('skipped', 'Skipped'),
    ], default='locked', required=True)
    sequence = fields.Integer(default=10)
    section_id = fields.Many2one('encoach.course.section', ondelete='set null')
    resource_ids = fields.Many2many('encoach.resource', string='Resources')
