<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExamImport_List.aspx.cs"
    Inherits="RM.Web.Training.Exam.ExamImport_List" %>

<%@ Register Src="~/UserControl/LoadButton.ascx" TagName="LoadButton" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>
        <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ExamImport_List")%></title>
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/artDialog/skins/opera.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/artDialog/artDialog.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.js" type="text/javascript"></script>
        <script src="/Themes/Scripts/ShowMsg/msgbox.js" type="text/javascript"></script>
    <link href="/Themes/Scripts/ShowMsg/msgbox.css" rel="stylesheet" type="text/css" />
</head>
<body style="overflow:scroll;" >
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div>
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ExamImport_List")%>
        </div>
    </div>
    <div class="btnbarcontetn">
        <div style="text-align: right">
            <input type="button" class="button green" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ExamImport_List_determine")%>"
                onclick="addAll();" />
            <input type="button" class="button green" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ExamImport_List_Delete")%>"
                onclick="quesdelete('');" />
            <input type="button" class="button green" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("UpdateSrort")%>"
                onclick="UpdateSrort()" />
        </div>
    </div>
    <div class="div-body" >
        <table border="0" cellpadding="0" cellspacing="0" class="grid">
            <thead>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("All class")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("RandomQue_Num")%>
                </th>
            </thead>
            <tbody id="headshow">
            </tbody>
        </table>
    </div>
    <div class="div-body" style=" overflow:auto; height:600px; "  >
        <table border="0"cellpadding="0" cellspacing="0" class="grid">
            <thead>
                <th>
                    <label id="checkAllOff" onclick="CheckAllLine()" title="全选"> &nbsp;</label>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_tmmc")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_zqda")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_zssm")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_fenzhi")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_tixing")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("SmartQuestion_stnandu")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("All class")%>
                </th>
                <th>
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Tags_List_tagname")%>
                </th>
                <th>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_xgcz")%>
                </th>
            </thead>
            <tbody id="queshow">
            </tbody>
        </table>
    </div>
    </form>
    <script type="text/javascript">
        $(function () {
            GetqueList();
                $("img").each(function (i) {
                    var imgsrc = $(this).attr("src");
                    $(this).attr("src", "/Resources/ExamImportWord/" + imgsrc);
                    $(this).attr("data-zoom-image", imgsrc);
                    $(this).attr("id", "img" + i);
                    $(this).attr("style", "margin-left:2px;max-height:100px;max-width:100px;");
                    $("#img" + i).elevateZoom({});
                });
        });
        //查询
        function GetqueList() {
            Loading(true);
            getAjax("GetExamImport_List.ashx", "action=Get", function (rs) {
                loadinghide();
                if (rs != "no") {
                    var data = eval('(' + rs + ')');
                    var countlist = data.quescount; //题数集合
                    var typelist = data.type; //分类集合
                    var quest = data.queslist; //试题集合
                    ShowDeit(countlist, typelist);
                    ShowQue(quest, typelist);
                }
            });
        }
        //汇总数据
        function ShowDeit(count, typelist) {
            var showhtm = "";
            for (var i = 0; i < typelist.length; i++) {
                showhtm += "<tr><td>" + typelist[i].CoursewareType_CtName + "</td><td>" + count[i] + "</td></tr>";
            }
            $("#headshow").append(showhtm);
        }
        //试题列表
        function ShowQue(quest, typelist) {
            var showhtm = "";
            for (var i = 0; i < quest.length; i++) {
                var typename = ""; //分类名
                var level = ""; //难度
                var tixing = ""; //题型
                showhtm += "<tr><td><input type='checkbox' value=" + quest[i].Questions_Id + " name='checkbox'></td><td>" + quest[i].Questions_Title + "</td>";
                showhtm += "<td>" + quest[i].Questions_Answer + "</td>";
                showhtm += "<td>" + quest[i].Questions_Discription + "</td>";
                showhtm += "<td>" + quest[i].Questions_DefaultScore + "</td>";
                //题型
                switch (quest[i].Questions_QtId) {
                    case "ae393b43-9163-4c1a-8ae7-33c8c3b19271": //单选
                        tixing = lgdanxuanti;
                        break;
                    case "9fa3b2b4-c5e5-400a-99a4-2033c00ac776": //多选
                        tixing = lgduoxuanti;
                        break;
                    case "33404960-f317-4fdc-8d4b-ede53436afe3": //问答
                        tixing = lgjiandati;
                        break;
                    case "50367a53-a774-40fa-8cfa-d21e9ca43b9e": //判断题
                        tixing = lgpanduanti;
                        break;
                    case "ae393b43-9163-4c1a-8ae7-33c8c3b12": //填空题
                        tixing = lgtiankongti;
                        break;
                    case "bb393b43-9162-5e6b-8ae7-33c8z3b19221": //排序题
                        tixing = lgpaixuti;
                        break;
                    case "bb393b43-9162-5e6b-8ae7-33c8z12": //综合题
                        tixing = lgzongheti;
                        break;
                    case "czp67a53-a774-40fa-8cfa-d21e9ca43czp": //B型题(选项)
                        tixing = lgbxingti;
                        break;
                    case "67aczp53-a774-40fa-8cfa-d21e9cczpa43": //B型题(题干)
                        tixing = lgbxingtigan;
                        break;
                }
                showhtm += "<td>" + tixing + "</td>";
                //难度
                switch (quest[i].Questions_Level) {
                    case 1:
                        level = lgSmartQuestion_yiban;
                        break;
                    case 2:
                        level = lgSmartQuestion_kunnan;
                        break;
                    case 3:
                        level = lgSmartQuestion_learn;
                        break;
                    default:
                        level = lgSmartQuestion_easy;

                }
                showhtm += "<td>" + level + "</td>";

                //分类
                $.each(typelist, function (idx, obj) {
                    if (obj.CoursewareType_CtId == quest[i].Questions_ReferencePoint) {
                        typename = obj.CoursewareType_CtName;
                    }
                });
                if (typename == "") {
                    typename = lgweifenlei;
                }
                showhtm += "<td>" + typename + "</td>";
                showhtm += "<td>" + quest[i].Questions_Tags + "</td>";
                
                //操作
                showhtm += "<td><a href=\"#\" onclick=\"quesedit('" + quest[i].Questions_Id + "');\" >" + lgbianji + "</a> | <a href=\"#\" onclick=\"quesdelete('" + quest[i].Questions_Id + "');\" >" + lgshanchu + "</a></td></tr>";
            }
            $("#queshow").append(showhtm);
        }
        //编辑
        function quesedit(key) {
            var url = "/Training/TrainingTest/Questions_Form.aspx?HashKey=" + key;
            top.openDialog(url, 'Questions_Form', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_list")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Ques_edit")%>', 750, 570, 50, 50);
        }
        //删除题目
        function quesdelete(queid) {
            showConfirmMsg(lgqrsanchu2, function () {
                //单个删除
                if (queid != "") {
                    getAjax("GetExamImport_List.ashx", "action=KeyDel&&key=" + queid, function (rs) {
                        if (rs > 0) {
                            showTipsMsg(lgdel3, 2000, 4);
                            location.reload();
                        } else {
                            showTipsMsg(lgdel5, 2000, 5);
                        }
                    });
                }
                else {//全部删除
                    getAjax("GetExamImport_List.ashx", "action=Del", function (rs) {
                        if (rs > 0) {
                            showTipsMsg(lgdel3, 2000, 4);
                            location.reload();
                        } else {
                            showTipsMsg(lgdel5, 2000, 5);
                        }
                    });
                }
            });
        }
        //全部入库
        function addAll() {
            showConfirmMsg(lgquerenbaocuncaozuo, function () {
                getAjax("GetExamImport_List.ashx", "action=All", function (rs) {
                    if (rs > 0) {
                        showTipsMsg(lgchenggong, 2000, 4);
                        location.href = "/Training/TrainingTest/Question_Manager.aspx";
                    } else {
                        showTipsMsg(lgczshibai, 2000, 5);
                    }
                });
            });
        }
        //修改类别
        function UpdateSrort() {
            var key = CheckboxValue();
            if (IsDelData(CheckboxValue())) {
                var url = "/Training/Exam/UpdateSrort.aspx?key=" + key;
                top.openDialog(url, 'CampaignForm_edit1', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ExamImport_List")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("批量修改类别")%>', 200, 100, 50, 50);
            }
        }
    </script>
</body>
</html>
