<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="jbExamination.aspx.cs" Inherits="RM.Web.jiabi.jbExamination" %>

<!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 runat="server">
    <title>反假币实操题考试</title>
    <link href="../Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Training/Learn/m/json2.js" type="text/javascript"></script>    
    <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/FunctionJS.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" />
    <link href="../Themes/Scripts/artDialog/skins/opera.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">

        /*
        *@Discription : 倒计时
        */
        var minute; //剩余分钟
        var second = 0; //剩余秒钟
        var interValObj; //计时方法

        window.onload = function () {
         /*
         alert(decodeURIComponent(getCookie("kstime"))+"1");
        deleteCookie("kstime");
        alert(decodeURIComponent(getCookie("kstime"))+"2");
        */
            addCurProp("addwzb","1");
            addCurProp("addbzb","2");
            addCurProp("addbzbprop","3");

            $kstime = $("#kstime");
            second = $("#kstime").text().split(":")[1];
            interValObj = window.setInterval(setRemainTime, 1000);

            if (window.name == "main"||window.name.indexOf("@")>=0) {
                deleteCookie("kstime");
                minute = <%=examtime %>; //parseInt($("#kstime").text());
                addCookie("kstime", "0<%=examtime %>:00");
                window.name = "blueidea";
            } else {
                minute = parseInt(decodeURIComponent(getCookie("kstime")).split(":")[0]);
                second = parseInt(decodeURIComponent(getCookie("kstime")).split(":")[1]);
            }            
        }

        var zdexam = false;
        function setRemainTime() { //倒计时方法
            if (minute == 0 && second == 0) {
                window.clearInterval(interValObj);
                $kstime.text("00:00");
                deleteCookie("kstime");
                zdexam = true;
                saveque2();
                alert("考试时间已到,系统自动交卷！");
                window.location.href = "/Frame/Login2.aspx";
            } else {     
            if(isNaN(minute)){minute = <%=examtime %>;}
            if(isNaN(second)){second = 0;}
                second -= 1;
                if (second < 0) {
                    second = 59;
                    minute -= 1;
                }
                //$kstime.text((minute.toString().length == 1 ? "0" + minute : minute) + ":" + (second.toString().length == 1 ? "0" + second : second));
                if (getCookie("kstime") != null && getCookie("kstime") != "") {
                    $kstime.text(decodeURIComponent(getCookie("kstime")));
                }
                addCookie("kstime", (minute.toString().length == 1 ? "0" + minute : minute) + ":" + (second.toString().length == 1 ? "0" + second : second));
            }
        }
        

        //假币的特征和方式
        function addCurProp(actionStr,typeid){
            $.ajax({
                url: "/jiabi/AddQuestions.aspx",
                type: "post",
                data: { action: actionStr,tid:typeid , a: Math.random() },
                dataType: "json",
                success: function (data) {
                    var qjson = data;
                    if (qjson != "" && qjson != undefined && qjson != null && qjson != '[]') {
                    if(typeid=="1"){jsontohtml(eval(qjson),"quehtml");}
                    if(typeid=="2"){jsontohtml2(eval(qjson));}
                    if(typeid=="3"){jsontohtml(eval(qjson),"quehtml3");}
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("网络异常" + XMLHttpRequest.status.toString());
                }
            });
        }



        var queNum = 0;
        //将JSON转成html
        function jsontohtml(data,htmlstr) {
            if (data.length > 0) {
                var quehtml = "";
                if(htmlstr=="quehtml"){quehtml = "<strong>伪造币特征</strong><font color=\"red\">(选5项,前2项必选<%=wzbDesc %>)</font><br/>";}
                if(htmlstr=="quehtml3"){quehtml = "<strong>变造币特征</strong><font color=\"red\">(选2项<%=bzbDesc %>)</font><br/>";}

                for (var i = 0; i < data.length; i++) {
                    quehtml += "<ul data=\"" + data[i].feat_id + "\" >" + data[i].feat_Name;
                    if (data[i].option.length > 0) {
                        for (var j = 0; j < data[i].option.length; j++) {
                            quehtml += "<li><input type=\"checkbox\" data=\"" + data[i].option[j] + "\" onclick=\"checkBox(this);\" name=\"option_" + queNum + "\"/>" + data[i].option[j] + "</li>";
                        }
                        queNum++;
                    }
                    quehtml += "</ul>";
                }
                quehtml += "</div>";
                $("#"+htmlstr).html(quehtml); //append
            }
        }

        function jsontohtml2(data) {
            if (data.length > 0) {
                var quehtml ="<strong>变造方式选项</strong><font color=\"red\">(选1项)</font><br/>";
                for (var i = 0; i < data.length; i++) {
                    quehtml += "<ul data=\"" + data[i].feat_id + "\">";// + data[i].feat_Name
                    if (data[i].option.length > 0) {
                        var strque = "";
                        for (var j = 0; j < data[i].option.length; j++) {
                            quehtml += "<li><input type=\"checkbox\" data=\"" + data[i].option[j] + "\" onclick=\"checkBox(this);\" name=\"op_" + queNum + "\"/>" + data[i].option[j] + "</li>";
                        }
                        queNum++;
                    }
                    quehtml += "</ul>";
                }
                quehtml += "</div>";
                $("#quehtml2").html(quehtml);//append                
            }
        }

        


        //保存用户答题记录
        function saveque() {
        if(CheckDataValid('#form1')){
            var zbNum = $("#txtzbNum").val();
            if (zbNum.length <= 0) { ZENG.msgbox.show("真币张数不能为空！");$("#txtzbNum").focus(); return; }
            var jbnum = $("#txtjbNum2").val();
            if (jbnum.length <= 0) { ZENG.msgbox.show("真币张数不能为空！");$("#txtjbNum2").focus(); return; }
            var jbstr = $("#txtjbNum").val();
            if (jbstr.length <= 0) { ZENG.msgbox.show("假币冠字号码不能为空！");$("#txtjbNum").focus();  return; }
            var wzstr = $("#txtwzNum").val();
            if (wzstr.length <= 0) { ZENG.msgbox.show("伪造币冠字号码不能为空！");$("#txtwzNum").focus(); return; }
            var bzstr = $("#txtbzNum").val();
            if (bzstr.length <= 0) { ZENG.msgbox.show("变造币冠字号码不能为空！"); $("#txtbzNum").focus(); return; }
            var examNum= $("#txtexamNum").val();
            if (bzstr.length <= 0) { ZENG.msgbox.show("学员编号不能为空！"); $("#txtexamNum").focus(); return; }
            var queues = [];

            //伪造币特征
            if (wzstr.length > 0) {
                var obj = {};
                obj.option = [];
                obj.qid = [];
                obj.cid = "1";
                obj.info_num = wzstr;
                $("#quehtml").find("ul").each(function (j) {
                    obj.qid.push($(this).attr("data"));
                    var flag = false;

                    $(this).children("li").children("input:checked").each(function () {
                        flag = true;
                        //alert($(this).attr("data"));
                        obj.option.push($(this).attr("data"));
                    });
                    if (flag == false) {
                        obj.option.push(""); //无选项时
                    }
                });
                queues.push(obj);
            }

            var vzbtz=0;
            for(var i=0;i<queues[0].option.length;i++){
                if(queues[0].option[i]!=""){
                    vzbtz++;
                }                
            }

            if(vzbtz>5){
                alert("伪造币特征只能选择5项");
                return;
            }

            
             //变造币特征
            if (wzstr.length > 0) {
                var obj = {};
                obj.option = [];
                obj.qid = [];
                obj.cid = "3";
                obj.info_num = bzstr;
                $("#quehtml3").find("ul").each(function (j) {
                    obj.qid.push($(this).attr("data"));
                    var flag = false;

                    $(this).children("li").children("input:checked").each(function () {
                        flag = true;
                        //alert($(this).attr("data"));
                        obj.option.push($(this).attr("data"));
                    });
                    if (flag == false) {
                        obj.option.push(""); //无选项时
                    }
                });
                queues.push(obj);
            }

            var bzbtz=0;
            for(var i=0;i<queues[1].option.length;i++){
                if(queues[1].option[i]!=""){
                    bzbtz++;
                }                
            }

            if(bzbtz>2){
                alert("变造币特征只能选择2项");
                return;
            }

            //变造币方式
            if (bzstr.length > 0) {
                var obj = {};
                obj.option = [];
                obj.qid = [];
                obj.cid = "2";
                obj.info_num = bzstr;
                $("#quehtml2").find("ul").each(function (j) {
                    obj.qid.push($(this).attr("data"));
                    var flag = false;

                    $(this).children("li").children("input:checked").each(function () {
                        flag = true;
                        //alert($(this).attr("data"));
                        obj.option.push($(this).attr("data"));
                    });
                    if (flag == false) {
                        obj.option.push(""); //无选项时
                    }
                });
                queues.push(obj);
            }

            var json = JSON.stringify(queues);
            //alert(json); showConfirmMsg
            showConfirmMsg("确定要提交试卷！",function() {
                $.ajax({
                    url: "/jiabi/jbExamination.aspx",
                    type: "post",
                    data: { "action": "saveque",jbnum:jbnum, zbnum: zbNum, jbstr: jbstr, array: json,examNum:examNum, a: Math.random() },
                    dataType: "json",
                    success: function (data) {
                        var qjson = data;
                        //alert(qjson);
//                        if (qjson >= 0) {
deleteCookie("kstime");
                            alert("试卷提交成功！");
                            window.location.href = "/Frame/Login2.aspx";
//                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert("网络异常" + XMLHttpRequest.status.toString());
                        window.location.href = "/Frame/Login2.aspx";
                        //ZENG.msgbox.show("网络异常" + XMLHttpRequest.status.toString(), 3000, 5);
                    }
                });
            }
        );
        }
        }
         //保存用户答题记录
        function saveque2() {
            var zbNum = $("#txtzbNum").val();
            var jbNum = $("#txtjbNum2").val();
            var jbstr = $("#txtjbNum").val();
            var wzstr = $("#txtwzNum").val();            
            var bzstr = $("#txtbzNum").val();            
            var examNum= $("#txtexamNum").val();
            var queues = [];

           
             //伪造币特征
            if (wzstr.length > 0) {
                var obj = {};
                obj.option = [];
                obj.qid = [];
                obj.cid = "1";
                obj.info_num = wzstr;
                $("#quehtml").find("ul").each(function (j) {
                    obj.qid.push($(this).attr("data"));
                    var flag = false;

                    $(this).children("li").children("input:checked").each(function () {
                        flag = true;
                        //alert($(this).attr("data"));
                        obj.option.push($(this).attr("data"));
                    });
                    if (flag == false) {
                        obj.option.push(""); //无选项时
                    }
                });
                queues.push(obj);
            }


             //变造币特征
            if (wzstr.length > 0) {
                var obj = {};
                obj.option = [];
                obj.qid = [];
                obj.cid = "3";
                obj.info_num = bzstr;
                $("#quehtml3").find("ul").each(function (j) {
                    obj.qid.push($(this).attr("data"));
                    var flag = false;

                    $(this).children("li").children("input:checked").each(function () {
                        flag = true;
                        //alert($(this).attr("data"));
                        obj.option.push($(this).attr("data"));
                    });
                    if (flag == false) {
                        obj.option.push(""); //无选项时
                    }
                });
                queues.push(obj);
            }

            //变造币方式
            if (bzstr.length > 0) {
                var obj = {};
                obj.option = [];
                obj.qid = [];
                obj.cid = "2";
                obj.info_num = bzstr;
                $("#quehtml2").find("ul").each(function (j) {
                    obj.qid.push($(this).attr("data"));
                    var flag = false;

                    $(this).children("li").children("input:checked").each(function () {
                        flag = true;
                        //alert($(this).attr("data"));
                        obj.option.push($(this).attr("data"));
                    });
                    if (flag == false) {
                        obj.option.push(""); //无选项时
                    }
                });
                queues.push(obj);
            }

            var json = JSON.stringify(queues);
            //alert(json);
            if (zdexam == true) {
                $.ajax({
                    url: "/jiabi/jbExamination.aspx",
                    type: "post",
                    data: { "action": "saveque",jbnum:jbNum, zbnum: zbNum, jbstr: jbstr, array: json,examNum:examNum,a: Math.random() },
                    dataType: "json",
                    success: function (data) {
                        var qjson = data;
                        //alert(qjson);
//                        if (qjson >= 0) {     
deleteCookie("kstime");                       
                            window.location.href = "/Frame/Login2.aspx";
//                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert("网络异常" + XMLHttpRequest.status.toString());
                        window.location.href = "/Frame/Login2.aspx";
                        //ZENG.msgbox.show("网络异常" + XMLHttpRequest.status.toString(), 3000, 5);
                    }
                });
            }
        }
        //保存coocike
        function addCookie(name, value) {
            var expiresMinute = <%=examtime %>;
            var cookieString = name + "=" + escape(value);
            //判断是否设置过期时间 
            if (expiresMinute > 0) {
                var date2 = new Date();
                var date3 = new Date();
                date2.setTime(date3.getTime()+expiresMinute * 60 * 1000);
                cookieString = cookieString + "; expires=" + date2;
            }
            document.cookie = cookieString;
        }
        //获取coocike
        function getCookie(name) {
            var strCookie = document.cookie;
            var arrCookie = strCookie.split("; ");
            for (var i = 0; i < arrCookie.length; i++) {
                var arr = arrCookie[i].split("=");
                if (arr[0] == name) return arr[1];
            }
            return "";
        }

        //删除coocike
        function deleteCookie(name){
            var expiresMinute = <%=examtime %>;        
            var mydate=new Date();
            var date3 = new Date();
            mydate.setDate(date3.getTime()-expiresMinute * 60 * 1000);         
            document.cookie=name+"=;expires="+mydate;  
        } 


    function checkBox(obj) {
        //只有当选中的时候才会去掉其他已经勾选的checkbox，所以这里只判断选中的情况 
        if ($(obj).is(":checked")) {
            // 先把所有的checkbox 都设置为不选种
            $(obj).parent().parent().find("input").each(function (j) {            
                $(this).prop('checked', false);
            });
            // 把自己设置为选中
            $(obj).prop('checked', true); 
        }
    }
        /*
          $(function () { 
            $("input[type=radio]").change(function(){
                alert($(this));
                $(this).attr("checked",false);
            });
        });*/
    </script>
    
    <style type="text/css">        
        *{ font-size:12px; }
    li{ list-style: none; padding-left:10px; }
    .tab{border-top:1px solid #ccc;border-left:1px solid #ccc;}
    .tab td{ border-bottom: 1px solid #ccc; border-right: 1px solid #ccc;padding:5px; }
    .txt_hid{ overflow:hidden; }
    .txt{ width:180px;  }
    </style>

</head>
<body style="overflow:scroll;" >
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div>
            反假币实操题考试
        </div>
    </div>

    <div style="width:70%; padding:5px;" >

    <div style="width:100%; padding:5px 5px 15px 5px; text-align:center; font-size:18px ; font-weight:bold; ">反假货币实操考试
    <div style="float:right; font-size:10px; padding-top:10px;  padding-right:20px; " id="">考试时间：<span id="kstime" style="color:Red;">0<%=examtime %>:00</span></div>
    </div>

    <table class="tab" style="width:100%;" cellpadding="0" cellspacing="0" >
    <tr  style="text-align:center;" >
        <td style="width:11%;">姓名</td>
        <td style="width:13%;"><label><%=RM.Common.DotNetBean.RequestSession.GetSessionUser().UserName.ToString() %></label></td>
        <td style="width:10%;">身份证号码</td>
        <td style="width:33%;"><label id="lblcarno" runat="server" >&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;</label></td>
        <td style="width:16%;">单位名称</td>
        <td style="width:16%;"><label id="lbldwmc" runat="server">&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;　&nbsp;</label></td>
    </tr>
    <tr >
    <td style="text-align:center;">考试编号</td><td colspan="2"><input class="txt" type="text" id="txtexamNum"/></td>

    
    <td rowspan="3" style="text-align:center;">假币冠字号码</td><td colspan="2" rowspan="3">
        <asp:TextBox ID="txtjbNum" runat="server" TextMode="MultiLine" Height="100px" 
            Width="180px" CssClas="txt_hid" Columns="10" Rows="5" ></asp:TextBox>
            <br /> <font color="red" size="2" >多张假币冠字号码需换行</font>
    </td>
    </tr>

     <tr>
    <td style="text-align:center;">假币张数</td><td colspan="2"><input class="txt" type="text" id="txtjbNum2" maxlength="2" datacol="yes" err="假币张数" checkexpession="Num" /></td>
    </tr>
    
    <tr>
    <td style="text-align:center;">真币张数</td><td colspan="2"><input type="text" id="txtzbNum" maxlength="3" datacol="yes" err="真币张数" checkexpession="Num" class="txt" /></td>
    </tr>

    <tr>
    <td style="text-align:center;">伪造币冠字号码</td><td colspan="2"><input type="text" id="txtwzNum" runat="server" maxlength="10" class="txt" />
    <br /><font color="red" size="2" >从挑出的假币中任意挑选一张<br/>伪造币号码填写</font>
    </td>    
    <td style="text-align:center;">变造币冠字号码</td><td colspan="2"><input type="text" id="txtbzNum" runat="server" maxlength="10" class="txt"/>
    <br /><font color="red" size="2" >从挑出的假币中任意挑选一张<br/>变造币号码填写</font>
    </td>
    </tr>

    <tr >
    <td colspan="3" id="quehtml" valign="top"  style="padding-left:20px;" ></td>
    <td  id="quehtml3" valign="top"  style="padding-left:10px;" ></td>
    <td colspan="2" id="quehtml2" valign="top" style="padding-left:20px;" ></td>
    </tr>
    <tr> <td colspan="6" style="text-align:center;"><input type="button" class="button"  value="提交试卷" onclick="saveque()" /></td> </tr>
    </table>
    </div>
    </form>
</body>
</html>
