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

<!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("ChapterList_title")%></title>
    <link href="../Exam/Themes/Css/ExamGlobal.css" rel="stylesheet" type="text/css" />
    <script src="../../Themes/Scripts/jquery-1.8.2.min.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/Validator/JValidator.js" type="text/javascript"></script>
    <script src="../../Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <link href="../Exam/Themes/Css/ExaminationCss.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/Training/Learn/m/ckplayer/ckplayer.js" charset="utf-8"></script>
    <script src="/Live/swfobject.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/jQuery.path2html.js" type="text/javascript"></script>
    <link href="/Template/free/assets/bootstrap/font-awesome/css/font-awesome.min.css" rel="stylesheet"
        type="text/css" media="screen" />
    <style type="text/css">
        body
        {
            margin: 0px;
            padding: 0px;
            font-family: 微软雅黑, 宋体, Arial, Helvetica, Verdana, sans-serif;
            color: #000000;
        }
        html, body
        {
            margin: 0px auto;
            padding: 0px;
            height: 100%;
        }
        .pb-wrapper
        {
            border: 1px solid gray;
            border-style: solid none;
            position: relative;
            background: #f4f4f4;
            text-align: left;
        }
        .pb-container
        {
            border: 1px solid gray;
            border-style: none solid;
            height: 14px;
            position: relative;
            left: -5px;
            margin-right: -5px;
            font: 1px/0 arial;
            padding: 2px;
        }
        .pb-text
        {
            width: 100%;
            position: absolute;
            left: 0;
            top: 0;
            text-align: center;
            color: gray;
            font: 12px/14px arial;
            padding-right: 10px;
        }
        .pb-value
        {
            height: 100%;
            width: 50%;
            background: #ffde00;
            text-align: left;
        }
        
        h1
        {
            font-size: 18px;
            color: Blue;
        }
        h2
        {
            font-size: 16px;
        }
        .pb-text b
        {
            color: Red;
        }
        #upQuestion
        {
            margin-left: 15px;
        }
        .answer
        {
            padding: 10px;
            background: #229ccc;
            color: White;
            display: none;
        }
        .answer1
        {
            padding: 10px;
            background: #ff8c05;
            color: White;
            display: none;
        }
        .answer2
        {
            padding: 10px;
            background: #229ccc;
            color: White;
            display: none;
        }
        .ansImg
        {
            float: left;
            margin: 10px;
        }
        
        .none
        {
            display: none;
        }
        .block
        {
            display: block;
        }
        .exam_result li
        {
            padding-left: 5px;
        }
        .activeQuetion .exam_result li
        {
            overflow: hidden;
        }
        #shoucang
        {
            font-size:16px;
            
            cursor: pointer;
            float:right;
            margin-right: 55px;
        }
        /*.activeQuetion .exam_result .ques_Context{ display:block;}*/
    </style>
</head>
<body style="background: White;" onpaste="return false" oncopy="return false;" oncontextmenu="window.event.returnValue=false">
    <div id="container" style="height: 780px; overflow-x: hidden; overflow-y: scroll;">
        <% if (SumCount != 0 && Request["action"] == "chapter")
           { %>
        <div class="pb-wrapper" style="border: 0;">
            <div class="pb-container" style="margin: 0px; border: 0; border-bottom: 1px #ccc solid;
                background-color: White; height: 25px; line-height: 25px;">
                <div class="pb-text" style="display: block; height: 25px; line-height: 25px; text-align: right;
                    margin-right: 20px; padding-right: 20px;">
                    <!--<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_yz")%>-->
                    <span id="yizuo" style="display: none;"></span>
                    <!--<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_ti")%> /-->
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_gy")%>
                    <%=SumCount %>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_ti")%>
                    <!--<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_dqzql")%>-->
                    <b id="zql" style="display: none;">12%</b>&nbsp;</div>
                <div class="pb-value" style="width: 0%;">
                </div>
            </div>
        </div>
        <% } if (Request["action"] == "cishu" || Request["action"] == "znct")
           {%>
        <div class="pb-wrapper" style="border: 0;">
            <div class="pb-container" style="margin: 0px; border: 0; border-bottom: 1px #ccc solid;
                background-color: White; height: 25px; line-height: 25px;">
                <div class="pb-text" style="display: block; height: 25px; line-height: 25px; text-align: right;">
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_gy")%>
                    <%=SumCount %>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_ti")%>&nbsp;</div>
            </div>
        </div>
        <%} %>
        <div id="examItem" class="examContext">
            <div id="ei_Container">
                <%=QuestionHtml.ToString() %>
            </div>
        </div>
        <div class="clear">
        </div>
        <% if (SumCount != 0)
           { %>
        <div style="margin: 10px; margin-left: 45px;">
            <input type="checkbox" value="0" id="showAnser" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_xsda")%>
           <%-- <input type="checkbox" value="0" id="nextQue" /><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_zdxyt")%>--%>
            <input type="button" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_syt")%>　　"
                id="upQuestion" />
            <input type="button" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_xyt")%>　　"
                id="nextQuesion" />
            <%--<input type="button" value="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_fhml")%>　　" id="retmulu" />--%>
        </div>
        <%} %>
        <a href="javascript:void(0)" style="display: none;" id="submitExam" resultkey="<%=resultKey %>">
            &nbsp;</a>
        <div id="mathquill" style="width: 600px; position: relative; height: 300px; left: 45px;
            bottom: 95px; background-color: White; display: none; z-index: 9999;">
            <iframe src="/Training/TrainingTest/gs/mathdialog.html" width="600" height="300"
                scrolling="no" frameborder="0" style="padding: 0;"></iframe>
        </div>
    </div>
    <script type="text/javascript">


var resultKey = $("#submitExam").attr("resultKey"); //路径
var $list = $(".ques_Context"); //题目对象

    //收藏
    function shoucangq(obj)
    {
        var str = $(obj).find("attr").text();
        if(str != null && str.length > 0)
        {
            var color = $(obj).css("color");
            var url = "QuestionsCollect.ashx";
            var parm = "";
            if(color == "rgb(0, 0, 0)")
            {
                parm = "action=collent&id="+str;
                getAjax(url,parm, function(rs){
                    if(rs == "1")
                    {
                        $(obj).css("color", "gold");        
                    }else
                    {
                        $(obj).css("color", "black");
                    }
                });
            }else
            {
                parm = "action=uncollent&id="+str;
                getAjax(url,parm, function(rs){
                    if(rs == "1")
                    {
                        $(obj).css("color", "black");
                    }else
                    {
                        $(obj).css("color", "gold");
                    }
                });
            }
        }
    }
    $(function () {
//        var divindex = -1;
        $("#retmulu").click(function () {
            window.location.href="/Training/Chapter/Index.aspx";
        });

        $("#upQuestion").click(function () {//上一题
            // riggerText();
            var $tempObj = $(".activeQuetion");
            if ($tempObj.prev().length < 1) {
                showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_mysyt")%>", 2000, 3);
            } else {
                $tempObj.removeClass("activeQuetion").prev().addClass("activeQuetion");
                getBoyHight();
            }
            showAns=false;        
            $("#showAnser").attr("checked",false);
           if(showAns==false){
            $("#a1_"+( $(".activeQuetion").index()+1)+"").removeClass("block");//显示选择结果                   
            $("#a2_"+( $(".activeQuetion").index()+1)+"").removeClass("block");//显示选择结果                   
           }
        });

        $("#nextQuesion").click(function () {//下一题
            //  triggerText();
            var $tempObj = $(".activeQuetion");
            if ($tempObj.next().length < 1) {
                showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_myxyt")%>", 2000, 3);
//                $("$examItem").html("<center>恭喜您，已经全部完成了本章节的全部习题学习！</center><br /> 按钮：重新学习   按钮：返回目录");

            } else {
                $tempObj.removeClass("activeQuetion").next().addClass("activeQuetion");
                getBoyHight();
            }
            showAns=false;        
            $("#showAnser").attr("checked",false);
            if(showAns==false){
             $("#a1_"+( $(".activeQuetion").index()+1)+"").removeClass("block");//显示选择结果                   
             $("#a2_"+( $(".activeQuetion").index()+1)+"").removeClass("block");//显示选择结果                   
            }
        });

        //清理章节答题记录
        function cxxx(){
            $.get("/Training/Chapter/ChapterList.aspx", { action: "clear", resultKey:<%="resultKey" %>  },                  function (data2) {
              location.href = "/Training/Chapter/ChapterList.aspx?action=chapter&resultKey="+resultKey+"&id=" + id;
            });}

        $(".exam_result>li").hover(function () {//选项的悬浮
            if ($(this).has("textarea").length > 0) return;
            if ($(this).has("input[type = text]").length > 0) return;
            $(this).addClass("hoverLi");
        }, function () {
            if ($(this).has("textarea").length > 0) return;
            if ($(this).has("input[type = text]").length > 0) return;
            $(this).removeClass("hoverLi");
        });

        //阻止事件冒泡的通用函数  
        function stopBubble(e) {
            // 如果传入了事件对象，那么就是非ie浏览器  
            if (e && e.stopPropagation) {
                //因此它支持W3C的stopPropagation()方法  
                e.stopPropagation();
            } else {
                //否则我们使用ie的方法来取消事件冒泡  
                window.event.cancelBubble = true;
            }
        }

        $(".exam_result>li>input:radio").change(function () {//radio选项的选中样式改变
            $(this).parent().parent().children("li").removeClass("checkedInput");
            $(this).parent().addClass("checkedInput");

             //当是综合题时
            itemindex=$(this).parent().parent().parent().index()+1;           
            var currIndex=$(".activeQuetion").index();            
            var itemKey=$(this).attr("data");
            var anser= $("#a_"+(currIndex+1)+"_"+itemindex+"").html();//正确答案   
            if(itemKey!=null && itemKey!=""){        
                daanStr=itemKey;
                $("#a1_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//隐藏选择结果
                $("#a2_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");
                if(itemKey=="Y"){itemKey="对";}else if(itemKey=="N"){itemKey="错";}
                if(showAns==true && anser!=undefined && anser!=null){
                    if(anser.toUpperCase()==itemKey.toUpperCase()){           
                        $("#a1_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果
                    }else{
                        $("#a2_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果
                    }
                }
            }

            postback($(this).parent().parent().children("li"), $(this).attr("name"), $(this).attr("data"), resultKey, $(".activeQuetion").index());
        });

        var numcount = 2;
        var itemindex=0;
        $(".exam_result>li>input[type=checkbox]").change(function () {//checkbox选项的选中样式改变
            //点击checkbox
           if ($(this).is(":checked")) {
                    $(this).parent().addClass("checkedInput");
                } else {
                  $(this).parent().removeClass("checkedInput");
                }
            var data = "";
            $(this).parent().parent().children("li").children("input:checked").each(function () {
                data += $(this).attr("data");
            });
            
            //当是综合题时
            itemindex=$(this).parent().parent().parent().index()+1;           
            var currIndex=$(".activeQuetion").index();            
            var itemKey=data;
            var anser= $("#a_"+(currIndex+1)+"_"+itemindex+"").html();//正确答案   
            if(data!=null && data!=""){        
                daanStr=itemKey;
                $("#a1_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//隐藏选择结果
                $("#a2_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");
                if(itemKey=="Y"){itemKey="对";}else if(itemKey=="N"){itemKey="错";}
                if(showAns==true && anser!=undefined && anser!=null){           
                    if(anser.toUpperCase()==itemKey.toUpperCase()){           
                        $("#a1_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果
                    }else{
                        $("#a2_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果
                    }
                }
            }
            postback($(this).parent().parent().children("li"), $(this).attr("name"), data, resultKey, $(".activeQuetion").index());
        });

        $(".exam_result>li>input[type=text]").blur(function () {
            var data = "";
            $(this).parent().parent().children("li").children("input:text").each(function () {
                data += $(this).val();
            });
            postback($(this).parent().parent().children("li"), $(this).attr("name"), data, resultKey, $(".activeQuetion").index());
        });

        $(".exam_Title>input[type=text]").blur(function () {
            var data = "";
            $(this).parent().children("input:text").each(function () {
                data += $(this).val() + "、";
            });
            data = data.length > 0 ? data.substring(0, data.length - 1) : "";
            postback($(this).parent().parent().children("li"), $(this).attr("name"), data, resultKey,$(".activeQuetion").index());
        });

        $(".exam_result>li>textarea").blur(function () {
            postback($(this), $(this).attr("name"), $(this).val(), resultKey, $(".activeQuetion").index() );
        });

        $("label").click(function (e) {//阻止事件冒泡，如果不阻止则单击li触发label的click()，然后label又触发li的click，冒泡无限循环了
            stopBubble(e);
        });

        /*
        $(".exam_result>li").click(function (e) {//li单击事件
            $(this).children("label").click();
        });
        */
        var daanStr="";
        function postback(objList, questionKey, itemKey, resultKey, currIndex) {               

           var anser= $("#a_"+(currIndex+1)+"").html();//正确答案
           
           if(anser!=null && anser!="")
           {
               daanStr=itemKey;
               $("#a1_"+(currIndex+1)+"").removeClass("block");//隐藏选择结果
               $("#a2_"+(currIndex+1)+"").removeClass("block");
               if(itemKey=="Y"){itemKey="对";}else if(itemKey=="N"){itemKey="错";}
               if(showAns==true){           
                   if(anser.toUpperCase()==itemKey.toUpperCase()){           
                        $("#a1_"+(currIndex+1)+"").addClass("block");//显示选择结果
                   }else{
                        $("#a2_"+(currIndex+1)+"").addClass("block");//显示选择结果
                   }
               }
           }

           
           
            $(objList).attr("disabled", "disabled"); //锁住选项
            $.ajax({
                url: "/Training/Exam/ReplyQuesion.ashx",
                type: "post",
                data: {"action":"chapte","replay": itemKey, "queKey": questionKey,ansNum:currIndex, "chapteid": resultKey },
                dataType: "text",
                success: function (data) {                
                    if (data) {                       
                        if (parseInt(data) < 0) {
                            showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_sjtjyc")%>", 2000, 5);
                        } else {//答题成功                                
//                            currIndex = divindex;
                            if (parseInt(data) == 0) {//取消回答
                                //$linkList.eq(currIndex).removeAttr("style");
                                //$currQueCount.text(parseInt($currQueCount.text()) - 1);
                            } else if (parseInt(data) == 100) {//回答成功
                                bool=true;                                
                                <% if(Request["action"] == "chapter"){ %>questionNum();<%} %>
                                if (nextBool == true) {                                    
                                    $("#nextQuesion").trigger("click");
                                }
                            }
                        }
                    } else {
                        showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>", 2000, 5);
                    }
                    $(objList).removeAttr("disabled"); //释放选项
                },
                error: function () {
                    showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>", 2000, 5);
                    $(objList).removeAttr("disabled");
                }
            });
        }

        var showAns=false;
        //是否显示正确答案
        $("#showAnser").click(function () {
            var currIndex= $(".activeQuetion").index();
            if ($("#showAnser").attr("checked") == "checked") {
                showAns=true;
         
                var anser= $("#a_"+(currIndex+1)+"").html();//正确答案
                    if(anser.toUpperCase()==daanStr.toUpperCase()){
                    
                        if(anser!=null && anser!=""){           
                            $("#a1_"+(currIndex+1)+"").addClass("block");//显示选择结果
                        }
                    }else{
                        if(anser!=null && anser!=""){
                            $("#a2_"+(currIndex+1)+"").addClass("block");//显示选择结果
                        }
                    }

                    var anser2= $("#a_"+(currIndex+1)+"_"+itemindex+"").html();//正确答案
                    if(anser2!=undefined && anser2!=null){
                        if(anser2.toUpperCase()==daanStr.toUpperCase()){
                            if(anser2!=null && anser2!=""){           
                                $("#a1_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果
                            }
                        }else{
                            if(anser2!=null && anser2!=""){
                                $("#a2_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果
                            }
                        }       
                    }        
            }else{
                showAns=false;
//                $("#nextQue").removeAttr("disabled"); //释放选项
$("#a1_"+(currIndex+1)+"").removeClass("block");//显示选择结果
$("#a2_"+(currIndex+1)+"").removeClass("block");//显示选择结果
$("#a1_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//显示选择结果
$("#a2_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//显示选择结果
            }
        });

        var nextBool = false;
        //自动下一题
        $("#nextQue").click(function () {
            if ($("#nextQue").attr("checked") == "checked") {
//                if ($("#showAnser").attr("checked") == "checked") {
//                    $("#nextQue").removeAttr("checked");
//                    $("#nextQue").attr("disabled", "disabled"); //锁住选项
//                }
                nextBool = true;
            } else {
                nextBool = false;
            }
        });
        //<% if(Request["action"] == "chapter"){ %>             
           // questionNum();
        //<%}else{ %>        
          //  $list.first().addClass("activeQuetion");
        //<%} %>
            $list.first().addClass("activeQuetion");
    });

    var bool=false;
    //查询答题数和正确率
    function questionNum(){
     $.get("ChapterList.aspx", { action: "anslv", resultKey: resultKey,r:Math.random() }, function (data) {
            if (data.indexOf("|") >= 0) {
                var num = data.split("|");
                var SumCount= <%=SumCount %>;
                datiNum=num[0];
                $("#yizuo").html(num[0]);                
                $(".pb-value").attr("style", "width:"+(num[0]==0?"0%": ((parseFloat(num[0])/parseFloat(SumCount))*100).toFixed(1)+"%"));
                $("#zql").html(num[1]==0?"0%": ((parseFloat(num[1])/parseFloat(SumCount))*100).toFixed(1)+"%");
                
                if(datiNum!=0 &&  bool==false){
                    $(".activeQuetion").removeClass("activeQuetion");
                    $list.eq(parseInt(datiNum)).addClass("activeQuetion");    
                }else if(datiNum==0){
                    $list.first().addClass("activeQuetion");
                }
            }
        });
    }
    
            var i = 0;
            $("annex").each(function () {
                $(this).attr("id", "aa" + i);
                var fileUrl = $(this).html();
                window.path2html("aa" + i, fileUrl);
                i++;
            });   
       var j = 0;
        $("annex").each(function () {
            $(this).attr("id", "aa" + j);
            var fileUrl = $(this).text();
            window.path2html("aa" + j, fileUrl);
            j++;
        });


        $("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);
                imgsrc = "/Resources/ExamImportWord/" + imgsrc;
            }
        });
     $(document).ready(function () {getBoyHight();});
     var mathcontent = "";
        function mathshow(mathname) {
            mathcontent = mathname;
            //alert(mathcontent);
            $("#mathquill").show();
        }
    function getBoyHight(){
        if(parent.document.getElementById("main") !=undefined){     
            parent.document.getElementById("main").height=document.body.scrollHeight;        
        }  
    }

    </script>
</body>
</html>
