from odoo import api, models, fields


class EncoachAdaptiveSettings(models.Model):
    _name = 'encoach.adaptive.settings'
    _description = 'Adaptive Engine Settings'

    teacher_id = fields.Many2one('res.users', ondelete='cascade')
    entity_id = fields.Many2one('encoach.entity', ondelete='cascade')
    step_up_threshold = fields.Float(default=0.85)
    step_down_threshold = fields.Float(default=0.50)
    micro_lesson_trigger = fields.Integer(default=2)
    module_skip_threshold = fields.Float(default=0.95)
    no_progress_alert_days = fields.Integer(default=3)
    max_retries = fields.Integer(default=3)

    @api.model
    def _cron_check_no_progress(self):
        from odoo.addons.encoach_adaptive.services.alert_service import AdaptiveAlertService
        AdaptiveAlertService.check_no_progress(self.env)
