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

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_title")%></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
    <link href="/Training/Exam/Themes/Css/ExamGlobal.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/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <link href="/Training/Exam/Themes/Css/ExaminationCss.css" rel="stylesheet" type="text/css" />    
    <link type="text/css" href="/Themes/Styles/mobile_index.css" rel="stylesheet" />    
    <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="/Themes/Scripts/artDialog/skins/opera.css" rel="stylesheet" type="text/css" />
    
    

    <style type="text/css">
    .exam_result li{ padding-left:5px; }
    #examItem{padding:0 10px;}
    #page_timu{ padding:0 0 5px 15px; }
   #page_timu label{ display:block; padding:5px;  }
    </style>
</head>

<body>


<div style="margin:50px 0 auto;">
	<div class="pb60" style="width:100%; margin:0 auto;">
    	<div class="mid_head_tit" id="head_tit" style="margin-top:60px;">
            <a class="fl tit_a on tc white" href="javascript:history.back();"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Chapter_back")%></a>
            <h3 class="h3 tc fs14  cor1">[<%=titleStr %>]</h3>
        </div>
        <div class="clear" ></div>
        <div class="tilu_pumping mt10 background1 clear pb5">
            <div id="examItem" class="examContext clear "> 
                <div id="ei_Container"  >        
                    <%=QuestionHtml.ToString() %>     
                </div>
            </div>

            <% if (SumCount != 0){ %>
            <div id="page_timu" >
            <label><input type="checkbox" value="0" id="showAnser" /> <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_xsda")%></label>
            <label style="display:none;"><input type="checkbox" value="0"  id="nextQue"/> <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_zdxyt")%></label><br />
                <a href="#" style=" padding:8px 10px;"  id="upQuestion" class="background5">
                &nbsp;<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_syt")%>&nbsp;</a>
            	<a href="#" style=" padding:8px 10px;" id="nextQuesion" class="background5">
                &nbsp;<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_xyt")%>&nbsp;</a>
            </div>
        <%} %>

         <% if (SumCount != 0){%>
         
            <p class="m5 p10 moni"><span class="cor6" style="font-size:14px;">* </span><span class="cor4" style="font-size:14px;"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_tsdjxxjkdtxzdah")%><br />
  				<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("Examination_djsytxytan")%></span></p>                
                <% }  %>

              <% if (SumCount != 0 && Request["action"] == "chapter"){ %>
        <div class="pb-wrapper"style="padding:0 10px;border:0;background-color:#fff; display:none;">
            <div class="pb-container" style="margin:0px;border:0;border-bottom:1px #ccc solid;  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"></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" class="cor6 fwb" >12%</b>　</div>
                
                
                <div class="pb-value" style="width:0%;"></div>
            </div>
        </div>
    <% } if ((Request["action"] == "cishu" || Request["action"] == "znct") && SumCount!=0){%>
        <div class="pb-wrapper"style="padding:0 10px; 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>
    </div>
</div>
<a href="javascript:void(0)" style="display:none;"  id="submitExam" resultkey="<%=resultKey %>">&nbsp;</a>


<script type="text/javascript">
var resultKey = $("#submitExam").attr("resultKey"); //路径
var $list = $(".ques_Context"); //题目对象
    $(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) {
                showFaceMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_mysyt")%>');
            } else {
                $tempObj.removeClass("activeQuetion").prev().addClass("activeQuetion");
            }
        });

        $("#nextQuesion").click(function () {//下一题
            //  triggerText();
            
            var $tempObj = $(".activeQuetion");
            if ($tempObj.next().length < 1) {
                showFaceMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_myxyt")%>');
            } else {
                $tempObj.removeClass("activeQuetion").next().addClass("activeQuetion");
            }
        });

        $(".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 anser= $("#a_"+(currIndex+1)+"_"+itemindex+"").html();//正确答案  
             var data=$(this).attr("data");
            if(anser!=undefined &&  anser!="" && data!=null && data!=""){     
                daanStr=data;
                $("#a1_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//隐藏选择结果
                $("#a2_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");
                if(data=="Y"){data="对";}else if(data=="N"){data="错";}
                if(showAns==true){           
                    if(anser.toUpperCase()==data.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 (numcount % 2 == 0) {
                if ($(this).prop("checked")) {
                    $(this).prop("checked", false);
                } else {
                    $(this).prop("checked", true);
                }
            }
            numcount++;
            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(anser!=undefined &&  anser!="" && data!=null && data!=""){
                daanStr=anser;
                $("#a1_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//隐藏选择结果
                $("#a2_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");
                if(anser=="Y"){anser="对";}else if(anser=="N"){anser="错";}
                if(showAns==true){           
                    if(anser.toUpperCase()==anser.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) {
            daanStr=itemKey;
           var anser= $("#a_"+(currIndex+1)+"").html();//正确答案           
           $("#a1_"+(currIndex+1)+"").removeClass("block");//隐藏选择结果
           $("#a2_"+(currIndex+1)+"").removeClass("block");
           $("#a4_"+(currIndex+1)+"").removeClass("block");           
           if(itemKey=="Y"){itemKey="对";}else if(itemKey=="N"){itemKey="错";}
           if(showAns==true){
              var anser2= $("#a_"+(currIndex+1)+"_"+itemindex+"").html();//正确答案
              if(anser2==undefined){
                $("#a4_"+(currIndex+1)+"").addClass("block");//显示选择结果
                if(anser.toUpperCase()==itemKey.toUpperCase()){           
                    $("#a1_"+(currIndex+1)+"").addClass("block");//显示选择结果
                }else{
                    $("#a2_"+(currIndex+1)+"").addClass("block");//显示选择结果
                }
              }else{
                $("#a4_"+(currIndex+1)+"_"+itemindex+"").addClass("block");//显示选择结果        
                
                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");//显示选择结果
                    }
                   }
                 }
              }
           }
           
            $(objList).attr("disabled", "disabled"); //锁住选项
            $.ajax({
                url: "/Training/Exam/ReplyQuesion.ashx",
                type: "post",
                data: {"action":"chapte","replay": itemKey, "queKey": questionKey,ansNum:currIndex, "chapteid": resultKey,r:Math.random()},
                dataType: "text",
                success: function (data) {                
                    if (data) {                       
                        if (parseInt(data) < 0) {
                            showWarningMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_sjtjyc")%>');
                        } 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 {
               //         showWarningMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>');
                    }
                    $(objList).removeAttr("disabled"); //释放选项
                },
                error: function () {
                    showWarningMsg('<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>');
                    $(objList).removeAttr("disabled");
                }
            });
        }
        var showAns=false;
        //是否显示正确答案
        $("#showAnser").click(function () {
        var currIndex=$(".activeQuetion").index();
            if ($("#showAnser").attr("checked") == "checked") {            
//                var data = "";
//                $(".activeQuetion").find("input:checked").each(function () {
//                    data += $(this).attr("data");
//                });
                var anser= $("#a_"+(currIndex+1)+"").html();//正确答案 
                if(anser!=undefined &&anser!=""){
                $("#a4_"+(currIndex+1)+"").addClass("block");//显示选择结果
                if(anser.toUpperCase()==daanStr.toUpperCase()){           
                    $("#a1_"+(currIndex+1)+"").addClass("block");//显示选择结果
                }else{
                    $("#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");//显示选择结果
                            }
                        }
                    }
                 }
                showAns=true;
                nextBool=false;                
            } else {
                $("#a4_"+(currIndex+1)+"").removeClass("block");//显示选择结果
                $("#a1_"+(currIndex+1)+"").removeClass("block");//显示选择结果
                $("#a2_"+(currIndex+1)+"").removeClass("block");//显示选择结果
                $("#a4_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//显示选择结果
                $("#a1_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//显示选择结果
                $("#a2_"+(currIndex+1)+"_"+itemindex+"").removeClass("block");//显示选择结果
                showAns=false;                
            }
        });

        var nextBool = false;
        //自动下一题
        $("#nextQue").click(function () {
            if ($("#nextQue").attr("checked") == "checked") {                
                nextBool = true;
            } else {
                nextBool = false;
            }
        });
        
        <% if(Request["action"] == "chapter"){ %>
            questionNum();
            
        <%}else{ %>
            $list.first().addClass("activeQuetion");            
        <%} %>
    });
    var bool=false;
    //查询答题数和正确率
    function questionNum(){    
     $.get("/Training/Chapter/ChapterList_mobile.aspx", { action: "anslv", resultKey: resultKey ,r:Math.random()}, function (data) {
    // alert(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");                    
                }
            }
        });
    }

         $(document).ready(function(){
         cxxx();
        if (window.location.href.indexOf("frame.aspx") < 0) {       $("#head_tit").hide();   }

           var i = 0;
            $("annex").each(function () {
                $(this).attr("id", "aa" + i);
                var fileUrl = $(this).text();
                window.path2html("aa" + i, fileUrl);
                i++;
            });   
});

//清理章节答题记录
function cxxx(){
    $.get("/Training/Chapter/ChapterList_mobile.aspx", { action: "clear", resultKey:<%="resultKey" %>  },function (data2) {
              
            });}

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