from odoo import models, fields


class EncoachStudentProgress(models.Model):
    _name = 'encoach.student.progress'
    _description = 'Student Progress'
    _order = 'completed_at desc'

    student_id = fields.Many2one('res.users', required=True, ondelete='cascade', index=True)
    course_id = fields.Many2one('op.course', ondelete='cascade')
    module_id = fields.Many2one('encoach.course.module', ondelete='cascade')
    resource_id = fields.Many2one('encoach.resource', ondelete='set null')
    status = fields.Selection([
        ('not_started', 'Not Started'),
        ('in_progress', 'In Progress'),
        ('completed', 'Completed'),
        ('skipped', 'Skipped'),
    ], default='not_started', required=True)
    score = fields.Float()
    time_spent_minutes = fields.Integer()
    completed_at = fields.Datetime()
    entity_id = fields.Many2one('encoach.entity', ondelete='set null')
