from odoo import models, fields


class EncoachExamCustom(models.Model):
    _name = 'encoach.exam.custom'
    _description = 'Custom Exam'

    title = fields.Char(size=200, required=True)
    template_id = fields.Many2one('encoach.exam.template', ondelete='set null')
    subject_id = fields.Many2one('encoach.subject', ondelete='set null')
    entity_id = fields.Many2one('encoach.entity', ondelete='set null')
    teacher_id = fields.Many2one('res.users', ondelete='set null')
    description = fields.Text()
    total_time_min = fields.Integer()
    pass_threshold = fields.Float()
    results_release_mode = fields.Selection([
        ('auto', 'Auto'),
        ('manual_approval', 'Manual Approval'),
    ], default='auto')
    randomize_questions = fields.Boolean(default=False)
    status = fields.Selection([
        ('draft', 'Draft'),
        ('published', 'Published'),
        ('archived', 'Archived'),
    ], default='draft', required=True)
    section_ids = fields.One2many('encoach.exam.custom.section', 'exam_id')
