from odoo import models, fields


class EncoachGradebook(models.Model):
    _name = 'encoach.gradebook'
    _description = 'Gradebook'

    student_id = fields.Many2one('op.student', required=True, ondelete='cascade')
    course_id = fields.Many2one('op.course', required=True, ondelete='cascade')
    academic_year_id = fields.Many2one('op.academic.year', ondelete='set null')
    line_ids = fields.One2many('encoach.gradebook.line', 'gradebook_id')


class EncoachGradebookLine(models.Model):
    _name = 'encoach.gradebook.line'
    _description = 'Gradebook Line'

    gradebook_id = fields.Many2one('encoach.gradebook', required=True, ondelete='cascade')
    assignment_name = fields.Char()
    marks = fields.Float()
    percentage = fields.Float()
    state = fields.Selection([
        ('draft', 'Draft'),
        ('submitted', 'Submitted'),
        ('graded', 'Graded'),
    ], default='draft')
