<?php

namespace addons\exam;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Exam extends Addons
{
    protected $menu
        = [
            [
                "name"    => "exam",
                "title"   => "考试系统",
                "icon"    => "fa fa-columns",
                "sublist" => [
                    [
                        "name"    => "exam/config_info",
                        "title"   => "参数配置",
                        "icon"    => "fa fa-cogs",
                        "sublist" => [
                            [
                                "name"  => "exam/config_info/index",
                                "title" => "查看"
                            ],
                            [
                                "name"  => "exam/config_info/add",
                                "title" => "添加"
                            ],
                            [
                                "name"  => "exam/config_info/edit",
                                "title" => "编辑"
                            ],
                            [
                                "name"  => "exam/config_info/del",
                                "title" => "删除"
                            ],
                            [
                                "name"  => "exam/config_info/multi",
                                "title" => "批量更新"
                            ]
                        ]
                    ],
                    [
                        "name"    => "exam/grade",
                        "title"   => "考卷成绩",
                        "icon"    => "fa fa-list",
                        "sublist" => [
                            [
                                "name"  => "exam/grade/index",
                                "title" => "查看"
                            ],
                            [
                                "name"  => "exam/grade/add",
                                "title" => "添加"
                            ],
                            [
                                "name"  => "exam/grade/edit",
                                "title" => "编辑"
                            ],
                            [
                                "name"  => "exam/grade/del",
                                "title" => "删除"
                            ],
                            [
                                "name"  => "exam/grade/multi",
                                "title" => "批量更新"
                            ],
                            [
                                "name"  => "exam/grade/detail",
                                "title" => "详情"
                            ],
                        ]
                    ],
                    [
                        "name"    => "exam/paper",
                        "title"   => "试卷管理",
                        "icon"    => "fa fa-newspaper-o",
                        "sublist" => [
                            [
                                "name"  => "exam/paper/index",
                                "title" => "查看"
                            ],
                            [
                                "name"  => "exam/paper/add",
                                "title" => "添加"
                            ],
                            [
                                "name"  => "exam/paper/edit",
                                "title" => "编辑"
                            ],
                            [
                                "name"  => "exam/paper/del",
                                "title" => "删除"
                            ],
                            [
                                "name"  => "exam/paper/multi",
                                "title" => "批量更新"
                            ],
                            [
                                "name"  => "exam/paper/recyclebin",
                                "title" => "回收站"
                            ],
                            [
                                "name"  => "exam/paper/destroy",
                                "title" => "真实删除"
                            ],
                            [
                                "name"  => "exam/paper/restore",
                                "title" => "还原"
                            ],
                        ]
                    ],
                    [
                        "name"    => "exam/question",
                        "title"   => "试题管理",
                        "icon"    => "fa fa-question-circle-o",
                        "sublist" => [
                            [
                                "name"  => "exam/question/index",
                                "title" => "查看"
                            ],
                            [
                                "name"  => "exam/question/add",
                                "title" => "添加"
                            ],
                            [
                                "name"  => "exam/question/edit",
                                "title" => "编辑"
                            ],
                            [
                                "name"  => "exam/question/del",
                                "title" => "删除"
                            ],
                            [
                                "name"  => "exam/question/multi",
                                "title" => "批量更新"
                            ],
                            [
                                "name"  => "exam/question/recyclebin",
                                "title" => "回收站"
                            ],
                            [
                                "name"  => "exam/question/destroy",
                                "title" => "真实删除"
                            ],
                            [
                                "name"  => "exam/question/restore",
                                "title" => "还原"
                            ],
                            [
                                "name"  => "exam/question/import",
                                "title" => "导入"
                            ],
                        ]
                    ],
                    [
                        "name"    => "exam/cate",
                        "title"   => "分类管理",
                        "icon"    => "fa fa-align-left",
                        "sublist" => [
                            [
                                "name"  => "exam/cate/import",
                                "title" => "Import"
                            ],
                            [
                                "name"  => "exam/cate/index",
                                "title" => "查看"
                            ],
                            [
                                "name"  => "exam/cate/add",
                                "title" => "添加"
                            ],
                            [
                                "name"  => "exam/cate/edit",
                                "title" => "编辑"
                            ],
                            [
                                "name"  => "exam/cate/del",
                                "title" => "删除"
                            ],
                            [
                                "name"  => "exam/cate/multi",
                                "title" => "批量更新"
                            ],
                            [
                                "name"  => "exam/cate/recyclebin",
                                "title" => "回收站"
                            ],
                            [
                                "name"  => "exam/cate/destroy",
                                "title" => "真实删除"
                            ],
                            [
                                "name"  => "exam/cate/restore",
                                "title" => "还原"
                            ],
                        ]
                    ],
                    [
                        "name"    => "exam/notice",
                        "title"   => "系统公告",
                        "icon"    => "fa fa-volume-up",
                        "sublist" => [
                            [
                                "name"  => "exam/notice/index",
                                "title" => "查看"
                            ],
                            [
                                "name"  => "exam/notice/add",
                                "title" => "添加"
                            ],
                            [
                                "name"  => "exam/notice/edit",
                                "title" => "编辑"
                            ],
                            [
                                "name"  => "exam/notice/del",
                                "title" => "删除"
                            ],
                            [
                                "name"  => "exam/notice/multi",
                                "title" => "批量更新"
                            ]
                        ]
                    ],
                    [
                        "name"    => "exam/roommanage",
                        "title"   => "考场功能",
                        "icon"    => "fa fa-home",
                        "sublist" => [
                            [
                                "name"    => "exam/room",
                                "title"   => "考场管理",
                                "icon"    => "fa fa-home",
                                "sublist" => [
                                    [
                                        "name"  => "exam/room/index",
                                        "title" => "查看"
                                    ],
                                    [
                                        "name"  => "exam/room/add",
                                        "title" => "添加"
                                    ],
                                    [
                                        "name"  => "exam/room/edit",
                                        "title" => "编辑"
                                    ],
                                    [
                                        "name"  => "exam/room/del",
                                        "title" => "删除"
                                    ],
                                    [
                                        "name"  => "exam/room/multi",
                                        "title" => "批量更新"
                                    ],
                                    [
                                        "name"  => "exam/room/recyclebin",
                                        "title" => "回收站"
                                    ],
                                    [
                                        "name"  => "exam/room/destroy",
                                        "title" => "真实删除"
                                    ],
                                    [
                                        "name"  => "exam/room/restore",
                                        "title" => "还原"
                                    ]
                                ]
                            ],
                            [
                                "name"    => "exam/room_signup",
                                "title"   => "考场报名",
                                "icon"    => "fa fa-pencil",
                                "sublist" => [
                                    [
                                        "name"  => "exam/room_signup/index",
                                        "title" => "查看"
                                    ],
                                    [
                                        "name"  => "exam/room_signup/add",
                                        "title" => "添加"
                                    ],
                                    [
                                        "name"  => "exam/room_signup/edit",
                                        "title" => "编辑"
                                    ],
                                    [
                                        "name"  => "exam/room_signup/del",
                                        "title" => "删除"
                                    ],
                                    [
                                        "name"  => "exam/room_signup/multi",
                                        "title" => "批量更新"
                                    ]
                                ]
                            ],
                            [
                                "name"    => "exam/room_grade",
                                "title"   => "考场考试成绩",
                                "icon"    => "fa fa-list-ol",
                                "sublist" => [
                                    [
                                        "name"  => "exam/room_grade/index",
                                        "title" => "查看"
                                    ],
                                    [
                                        "name"  => "exam/room_grade/add",
                                        "title" => "添加"
                                    ],
                                    [
                                        "name"  => "exam/room_grade/edit",
                                        "title" => "编辑"
                                    ],
                                    [
                                        "name"  => "exam/room_grade/del",
                                        "title" => "删除"
                                    ],
                                    [
                                        "name"  => "exam/room_grade/multi",
                                        "title" => "批量更新"
                                    ],
                                    [
                                        "name"  => "exam/room_grade/detail",
                                        "title" => "详情"
                                    ],
                                ]
                            ]
                        ]
                    ],
                    [
                        "name"    => "exam/correction",
                        "title"   => "纠错反馈",
                        "icon"    => "fa fa-wpforms",
                        "sublist" => [
                            [
                                "name"    => "exam/correction_type",
                                "title"   => "纠错反馈类型",
                                "icon"    => "fa fa-dot-circle-o",
                                "sublist" => [
                                    [
                                        "name"  => "exam/correction_type/index",
                                        "title" => "查看"
                                    ],
                                    [
                                        "name"  => "exam/correction_type/add",
                                        "title" => "添加"
                                    ],
                                    [
                                        "name"  => "exam/correction_type/edit",
                                        "title" => "编辑"
                                    ],
                                    [
                                        "name"  => "exam/correction_type/del",
                                        "title" => "删除"
                                    ],
                                    [
                                        "name"  => "exam/correction_type/multi",
                                        "title" => "批量更新"
                                    ],
                                ]
                            ],
                            [
                                "name"    => "exam/correction_question",
                                "title"   => "纠错反馈试题",
                                "icon"    => "fa fa-pencil",
                                "sublist" => [
                                    [
                                        "name"  => "exam/correction_question/index",
                                        "title" => "查看"
                                    ],
                                    [
                                        "name"  => "exam/correction_question/add",
                                        "title" => "添加"
                                    ],
                                    [
                                        "name"  => "exam/correction_question/edit",
                                        "title" => "编辑"
                                    ],
                                    [
                                        "name"  => "exam/correction_question/del",
                                        "title" => "删除"
                                    ],
                                    [
                                        "name"  => "exam/correction_question/multi",
                                        "title" => "批量更新"
                                    ]
                                ]
                            ],
                        ]
                    ],
                    [
                        "name"    => "exam/dashboard/index",
                        "title"   => "控制台",
                        "icon"    => "fa fa-dashboard",
                        "sublist" => []
                    ]
                ]
            ]
        ];

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        Menu::create($this->menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete('exam');
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable('exam');
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable('exam');
        return true;
    }

    /**
     * 插件升级方法
     * @return bool
     */
    public function upgrade()
    {
        // 如果菜单有变更则升级菜单
        Menu::upgrade('exam', $this->menu);
        return true;
    }

}
