<%@ 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" />
    <style type="text/css" >
      .fudongceng { width:250px; height:150px;position:absolute; background-color:#F7F7F7;top:30%;left:40%;  z-index:999; border-radius:8px;}
      .txt1{width:150px; height:20px;}
      .btnbartitle{ border-radius:8px 8px 0px 0px; }
    </style>
</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("UpdateSrort")%>"
                onclick="RecoveryStyle()" />
            <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" style="display:none;" 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  id="mask" style="display:none;width: 100%; height: 100%; position: fixed; z-index: 995; top: 0px; left: 0px; overflow: hidden;"><div style="height: 100%; opacity: 0.1; background: rgb(0, 0, 0);"></div></div>
     <div class="fudongceng" style="display:none;">     
     <div class="btnbartitle"><div>导入试题列表-批量修改分类</div></div>
      <table id="tablebody" border="0" cellpadding="0" cellspacing="0" class="frm" style="margin-top:20px;">
        <tr style=" text-align:center;">
            <td style="border-bottom:0px;">
                <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Srort")%>:
            </td>
            <td style="padding:0px;border-bottom:0px;"><select id="examtype" class="txt1"
                    runat="server"></select>
            </td>
        </tr>
    </table>
        <div class="frmbottom">            
            <asp:LinkButton ID="Save" runat="server" class="l-btn" OnClientClick="UPdatetype(); return false;"><span class="l-btn-left">
            <img src="/Themes/Images/disk.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("student_index_xg")%></span></asp:LinkButton>
            <a class="l-btn" href="javascript:void(0)" onclick="ClerStyle();"><span class="l-btn-left">
                <img src="/Themes/Images/cancel.png" alt="" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Close")%></span></a>
        </div>
    </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();
        });
        function ClerStyle() {
            $(".fudongceng").hide();
            $("#mask").hide();
        }
        function RecoveryStyle() {
         var key = CheckboxValue();
         if (IsDelData(CheckboxValue())) {
             $(".fudongceng").show();
             $("#mask").show();
         }
        }
        //查询
        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);
            th();
        }
        //编辑
        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);
            }
        }
        function UPdatetype() {
            var key = CheckboxValue();
            var type = $("#examtype").val();
            if (IsDelData(CheckboxValue())) {
                $.post("GetExamImport_List.ashx", "action=updatetype&key="+key+"&type="+type, function (date) {
                    if (date == "0") {
                        window.location.reload();
                        showTipsMsg('操作成功！', '2500', '4');
                    } else if (date == "1") {
                        showTipsMsg('操作失败！', '5000', '5');
                    } else if (date == "2") {
                        showTipsMsg('题目为空！', '5000', '5');
                    } else {
                        showTipsMsg('重新登录重试！', '5000', '5');
                    }
                });               
            }
        }
        function th() {
            $("#queshow img").each(function (i) {
                var imgsrc = $(this).attr("src");
                if (imgsrc.indexOf("image") < 0 && imgsrc.indexOf("/Resources/SharesFiles") < 0 && imgsrc.indexOf("/Resources/ExamImportWord") < 0) {
                    $(this).attr("src", "/Resources/ExamImportWord/" + imgsrc);
                    $(this).attr("width", "50px");
                    imgsrc = "/Resources/ExamImportWord/" + imgsrc;
                }
            });
        }
    </script>
</body>
</html>
