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

    <!-- ============================================================ -->
    <!--                    Custom Exam Views                         -->
    <!-- ============================================================ -->

    <record id="view_exam_custom_form" model="ir.ui.view">
        <field name="name">encoach.exam.custom.form</field>
        <field name="model">encoach.exam.custom</field>
        <field name="arch" type="xml">
            <form string="Custom Exam">
                <header>
                    <field name="status" widget="statusbar" statusbar_visible="draft,published,archived"/>
                </header>
                <sheet>
                    <div class="oe_title">
                        <h1>
                            <field name="title" placeholder="Exam Title"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="template_id"/>
                            <field name="subject_id"/>
                            <field name="entity_id"/>
                            <field name="teacher_id"/>
                        </group>
                        <group>
                            <field name="total_time_min"/>
                            <field name="pass_threshold"/>
                            <field name="results_release_mode"/>
                            <field name="randomize_questions"/>
                        </group>
                    </group>
                    <group>
                        <field name="description" placeholder="Exam description..."/>
                    </group>
                    <notebook>
                        <page string="Sections" name="sections">
                            <field name="section_ids">
                                <list editable="bottom">
                                    <field name="sequence" widget="handle"/>
                                    <field name="title"/>
                                    <field name="skill"/>
                                    <field name="question_count"/>
                                    <field name="time_limit_min" string="Time (min)"/>
                                    <field name="scoring_method"/>
                                </list>
                            </field>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_exam_custom_list" model="ir.ui.view">
        <field name="name">encoach.exam.custom.list</field>
        <field name="model">encoach.exam.custom</field>
        <field name="arch" type="xml">
            <list string="Custom Exams" decoration-info="status == 'draft'" decoration-success="status == 'published'">
                <field name="title"/>
                <field name="subject_id"/>
                <field name="entity_id"/>
                <field name="teacher_id"/>
                <field name="total_time_min" string="Time (min)"/>
                <field name="status"/>
            </list>
        </field>
    </record>

    <record id="view_exam_custom_search" model="ir.ui.view">
        <field name="name">encoach.exam.custom.search</field>
        <field name="model">encoach.exam.custom</field>
        <field name="arch" type="xml">
            <search string="Search Custom Exams">
                <field name="title"/>
                <field name="subject_id"/>
                <field name="entity_id"/>
                <field name="teacher_id"/>
                <separator/>
                <filter string="Draft" name="filter_draft" domain="[('status', '=', 'draft')]"/>
                <filter string="Published" name="filter_published" domain="[('status', '=', 'published')]"/>
                <filter string="Archived" name="filter_archived" domain="[('status', '=', 'archived')]"/>
                <filter string="Status" name="group_status" context="{'group_by': 'status'}"/>
                <filter string="Subject" name="group_subject" context="{'group_by': 'subject_id'}"/>
                <filter string="Entity" name="group_entity" context="{'group_by': 'entity_id'}"/>
            </search>
        </field>
    </record>

    <record id="action_exam_custom" model="ir.actions.act_window">
        <field name="name">Custom Exams</field>
        <field name="res_model">encoach.exam.custom</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_exam_custom_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first custom exam
            </p>
        </field>
    </record>

</odoo>
