from odoo import models, fields


class EncoachCatSession(models.Model):
    _name = 'encoach.cat.session'
    _description = 'CAT Placement Session'

    student_id = fields.Many2one('res.users', required=True, ondelete='cascade', index=True)
    subject_id = fields.Many2one('encoach.subject', ondelete='set null')
    started_at = fields.Datetime(default=fields.Datetime.now)
    completed_at = fields.Datetime()
    status = fields.Selection([
        ('active', 'Active'),
        ('completed', 'Completed'),
        ('abandoned', 'Abandoned'),
    ], default='active', required=True)
    current_section = fields.Selection([
        ('listening', 'Listening'),
        ('reading', 'Reading'),
        ('writing', 'Writing'),
        ('speaking', 'Speaking'),
        ('grammar', 'Grammar'),
        ('vocabulary', 'Vocabulary'),
    ])
    current_theta = fields.Float(default=0.0)
    current_sem = fields.Float(default=1.0)
    questions_answered = fields.Integer(default=0)
    autosave_data = fields.Text()
