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

    <!-- ============================================================ -->
    <!--                    Exam Template Views                       -->
    <!-- ============================================================ -->

    <record id="view_exam_template_form" model="ir.ui.view">
        <field name="name">encoach.exam.template.form</field>
        <field name="model">encoach.exam.template</field>
        <field name="arch" type="xml">
            <form string="Exam Template">
                <sheet>
                    <div class="oe_button_box" name="button_box"/>
                    <widget name="web_ribbon" title="Archived" bg_color="text-bg-danger" invisible="active"/>
                    <div class="oe_title">
                        <h1>
                            <field name="name" placeholder="Template Name"/>
                        </h1>
                    </div>
                    <group>
                        <group>
                            <field name="code"/>
                            <field name="type"/>
                            <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"/>
                            <field name="editable"/>
                            <field name="active" invisible="1"/>
                        </group>
                    </group>
                    <group>
                        <field name="description" placeholder="Describe this exam template..."/>
                    </group>
                    <notebook>
                        <page string="Structure" name="structure">
                            <field name="structure" widget="text"/>
                        </page>
                    </notebook>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_exam_template_list" model="ir.ui.view">
        <field name="name">encoach.exam.template.list</field>
        <field name="model">encoach.exam.template</field>
        <field name="arch" type="xml">
            <list string="Exam Templates">
                <field name="name"/>
                <field name="code"/>
                <field name="type"/>
                <field name="subject_id"/>
                <field name="entity_id"/>
                <field name="total_time_min" string="Time (min)"/>
                <field name="active"/>
            </list>
        </field>
    </record>

    <record id="view_exam_template_search" model="ir.ui.view">
        <field name="name">encoach.exam.template.search</field>
        <field name="model">encoach.exam.template</field>
        <field name="arch" type="xml">
            <search string="Search Exam Templates">
                <field name="name"/>
                <field name="code"/>
                <field name="subject_id"/>
                <field name="entity_id"/>
                <separator/>
                <filter string="International" name="filter_international" domain="[('type', '=', 'international')]"/>
                <filter string="Custom" name="filter_custom" domain="[('type', '=', 'custom')]"/>
                <separator/>
                <filter string="Active" name="filter_active" domain="[('active', '=', True)]"/>
                <filter string="Archived" name="filter_archived" domain="[('active', '=', False)]"/>
                <filter string="Type" name="group_type" context="{'group_by': 'type'}"/>
                <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_template" model="ir.actions.act_window">
        <field name="name">Exam Templates</field>
        <field name="res_model">encoach.exam.template</field>
        <field name="view_mode">list,form</field>
        <field name="search_view_id" ref="view_exam_template_search"/>
        <field name="help" type="html">
            <p class="o_view_nocontent_smiling_face">
                Create your first exam template
            </p>
        </field>
    </record>

</odoo>
