<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="view_student_attempt_form" model="ir.ui.view">
        <field name="name">encoach.student.attempt.form</field>
        <field name="model">encoach.student.attempt</field>
        <field name="arch" type="xml">
            <form string="Student Attempt">
                <header>
                    <field name="status" widget="statusbar" statusbar_visible="in_progress,completed,scoring,scored,released"/>
                </header>
                <sheet>
                    <group>
                        <group>
                            <field name="student_id"/>
                            <field name="exam_id"/>
                            <field name="entity_id"/>
                            <field name="is_placement"/>
                        </group>
                        <group>
                            <field name="started_at"/>
                            <field name="completed_at"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Scores" name="scores">
                            <group>
                                <group>
                                    <field name="listening_band"/>
                                    <field name="reading_band"/>
                                    <field name="writing_band"/>
                                    <field name="speaking_band"/>
                                </group>
                                <group>
                                    <field name="overall_band"/>
                                    <field name="cefr_level"/>
                                </group>
                            </group>
                        </page>
                        <page string="Answers" name="answers">
                            <field name="answer_ids">
                                <list editable="bottom">
                                    <field name="question_id"/>
                                    <field name="answer"/>
                                    <field name="is_correct"/>
                                    <field name="score"/>
                                    <field name="time_spent_ms"/>
                                    <field name="flagged"/>
                                </list>
                            </field>
                        </page>
                        <page string="Feedback" name="feedback">
                            <field name="feedback_ids">
                                <list editable="bottom">
                                    <field name="question_id"/>
                                    <field name="feedback_text"/>
                                    <field name="source"/>
                                    <field name="graded_by"/>
                                </list>
                            </field>
                        </page>
                        <page string="Release Info" name="release_info">
                            <group>
                                <field name="released_at"/>
                                <field name="released_by"/>
                            </group>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_student_attempt_list" model="ir.ui.view">
        <field name="name">encoach.student.attempt.list</field>
        <field name="model">encoach.student.attempt</field>
        <field name="arch" type="xml">
            <list string="Student Attempts">
                <field name="student_id"/>
                <field name="exam_id"/>
                <field name="status" widget="badge" decoration-info="status == 'in_progress'" decoration-success="status == 'released'" decoration-warning="status == 'scoring'"/>
                <field name="overall_band"/>
                <field name="cefr_level"/>
                <field name="started_at"/>
            </list>
        </field>
    </record>

    <record id="view_student_attempt_search" model="ir.ui.view">
        <field name="name">encoach.student.attempt.search</field>
        <field name="model">encoach.student.attempt</field>
        <field name="arch" type="xml">
            <search string="Search Attempts">
                <field name="student_id"/>
                <field name="exam_id"/>
                <separator/>
                <filter string="In Progress" name="in_progress" domain="[('status', '=', 'in_progress')]"/>
                <filter string="Completed" name="completed" domain="[('status', '=', 'completed')]"/>
                <filter string="Scoring" name="scoring" domain="[('status', '=', 'scoring')]"/>
                <filter string="Scored" name="scored" domain="[('status', '=', 'scored')]"/>
                <filter string="Pending Approval" name="pending_approval" domain="[('status', '=', 'pending_approval')]"/>
                <filter string="Released" name="released" domain="[('status', '=', 'released')]"/>
                <separator/>
                <filter string="Student" name="group_student" context="{'group_by': 'student_id'}"/>
                <filter string="Exam" name="group_exam" context="{'group_by': 'exam_id'}"/>
                <filter string="Entity" name="group_entity" context="{'group_by': 'entity_id'}"/>
            </search>
        </field>
    </record>

    <record id="action_student_attempt" model="ir.actions.act_window">
        <field name="name">Exam Sessions</field>
        <field name="res_model">encoach.student.attempt</field>
        <field name="view_mode">list,form</field>
    </record>

    <record id="action_grading_queue" model="ir.actions.act_window">
        <field name="name">Grading Queue</field>
        <field name="res_model">encoach.student.attempt</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'search_default_scoring': 1}</field>
    </record>

    <record id="action_score_approval" model="ir.actions.act_window">
        <field name="name">Score Approval</field>
        <field name="res_model">encoach.student.attempt</field>
        <field name="view_mode">list,form</field>
        <field name="context">{'search_default_pending_approval': 1}</field>
    </record>

</odoo>
