from odoo import models, fields


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

    title = fields.Char(size=200, required=True)
    label = fields.Char(size=100)
    exam_mode = fields.Selection([
        ('official', 'Official'),
        ('practice', 'Practice'),
    ], default='official')
    template_id = fields.Many2one('encoach.exam.template', ondelete='set null')
    structure_id = fields.Many2one('encoach.exam.structure', 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')
    rubric_id = fields.Many2one('encoach.rubric', ondelete='set null')
    approval_workflow_id = fields.Integer()
    description = fields.Text()
    total_time_min = fields.Integer()
    total_marks = fields.Float()
    pass_threshold = fields.Float()
    grading_system = fields.Selection([
        ('ielts', 'IELTS Band'),
        ('percentage', 'Percentage'),
        ('pass_fail', 'Pass / Fail'),
        ('cefr', 'CEFR Level'),
    ], default='ielts')
    access_type = fields.Selection([
        ('private', 'Private'),
        ('public', 'Public'),
    ], default='private')
    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')
