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

<!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("CorrectExam_Title")%></title>
   
    <link href="Themes/Css/ExamGlobal.css" rel="stylesheet" type="text/css" />
    <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/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="Themes/Css/ExaminationCss.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .activeQuetion .ques_Context{ display:block;}
    </style>
    <script type="text/javascript">
        //验证是否是数字
        function isInteger(obj) {
            reg = /^[-+]?\d+$/;
            if (!reg.test(obj)) {
                return false;
            } else {
                return true;
            }
        }
        $(function () {
            $(".exam_result>li,.exam_result>li>label,.exam_result>li>input").hover(function () { $(this).css("cursor", "default"); }, function () { });
            $(".exam_result>li>input[type=checkbox],.exam_result>li>input[type=text],.exam_result>li>input[type=radio],.exam_result>li>textarea").attr("disabled", "disabled"); //把答题锁住
            function resizeimg(objImg, maxWidth, maxHeight) {
                ///	<summary>
                ///     根据图片对象和指定的参数按比例缩放图片
                ///     &#10;1: resizeimg(obj, maxW, maxH) - 根据图片对象和指定的参数按比例缩放图片
                ///	</summary>
                ///	<param name="obj" type="ImageObject">图片对象</param>
                ///	<param name="maxW" type="int">最大宽度</param>
                ///	<param name="maxH" type="int">最大高度</param>
                ///	<returns type="string" />
                var img = new Image();
                img.src = objImg.src;
                var hRatio;
                var wRatio;
                var Ratio = 1;
                var w = img.width;
                var h = img.height;
                wRatio = maxWidth / w;
                hRatio = maxHeight / h;
                if (maxWidth == 0 && maxHeight == 0) {
                    Ratio = 1;
                } else if (maxWidth == 0) {//
                    if (hRatio < 1) Ratio = hRatio;
                } else if (maxHeight == 0) {
                    if (wRatio < 1) Ratio = wRatio;
                } else if (wRatio < 1 || hRatio < 1) {
                    Ratio = (wRatio <= hRatio ? wRatio : hRatio);
                }
                if (Ratio < 1) {
                    w = w * Ratio;
                    h = h * Ratio;
                }
                objImg.height = h;
                objImg.width = w;
            }
            if ($.browser.msie) {
                var imgList = $("#examItem img");
                for (var i = 0; i < imgList.length; i++) {
                    resizeimg(imgList.get(i), 600, 500);
                }
            } else {
                $("#examItem img").load(function () {
                    resizeimg(this, 600, 500);
                });
            }
            //把经常变换的对象预留出来
            var $currQueCount = $("#currQueCount"); //答题情况
            var $exam_Num = $("#exam_Num"); //题目编号
            var $list = $(".ques_Context"); //题目对象
            var $linkList = $(".curr_State>li>a"); //右侧题目编号列表
            var $pageBody = $("body"); //body对象
            var $examItem = $("#examItem"); //左侧题目对象
            if (!$list || $list.length < 1 || !$linkList || $linkList.length < 1) {//页面有错误
                return;
            }
            $list.first().addClass("activeQuetion");
            $linkList.first().addClass("currLinkNum");

            //自适应宽高
            function changePageWindow() {
                if ($pageBody.height() < $("#toolBar").height()) //右侧工具栏自适应高度
                    $("#toolBar").css("overflow", "scroll");
                else
                    $("#toolBar").css("overflow", "auto");
                $("#toolBar").height($pageBody.height());
                $examItem.width($pageBody.width() - 290); //左侧题目自适应高度
                changePageHeight();
            }
            //每次题目改变根据题目的高度自适应高度
            function changePageHeight() {
                if ($examItem.height() > $pageBody.height()) {
                    $examItem.css("overflow", "scroll");
                } else {
                    $examItem.css("overflow", "auto");
                }
                $examItem.height($pageBody.height());
            }
            changePageWindow();
            $(window).resize(changePageWindow); //绑定系统宽高改变事件
            $("#upQuestion").click(function () {//上一题
                var $tempObj = $(".activeQuetion");
                var $tempNumObj = $(".currLinkNum");
                if ($tempObj.prev().length < 1) {
                    showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_mysyt")%>", 2000, 3);
                } else {
                    $tempObj.removeClass("activeQuetion").prev().addClass("activeQuetion");
                    $tempNumObj.removeClass("currLinkNum").prev().addClass("currLinkNum");
                }
            });
            $("#nextQuesion").click(function () {//下一题
                var $tempObj = $(".activeQuetion");
                var $tempNumObj = $(".currLinkNum");
                if ($tempObj.next().length < 1) {
                    showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_myxyt")%>", 2000, 3);
                } else {
                    $tempObj.removeClass("activeQuetion").next().addClass("activeQuetion");
                    $tempNumObj.removeClass("currLinkNum").next().addClass("currLinkNum");
                }
            });
            $linkList.click(function () { //右侧题目列表
                $(".activeQuetion").removeClass("activeQuetion");
                $(".currLinkNum").removeClass("currLinkNum");
                $(this).addClass("currLinkNum");
                $list.eq(parseInt($(this).text()) - 1).addClass("activeQuetion");
            });
            $(".quesionOprater>input[type=radio]").change(function () {
                postBack($(this).attr("data"), $(this).val(), $(this));
            });
            $(".quesionOprater>input[type=text]").blur(function () {
                if (!isInteger($(this).val())) {
                    showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_znsrsz")%>", 2000, 3);
                    return;
                }
                if (parseInt($(this).val()) < 0) {
                    showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_bndytmyddzgf")%>", 2000, 3);
                    return;
                }
                postBack($(this).attr("data"), $(this).val(), $(this));
            });
            function postBack(questionKey, score, obj) {

                //批改方法：题目ID，分数，当前对象（需要根据对象值判定右侧链接的显示）
                $("#handleIcon").fadeIn(100);
                $.ajax({
                    url: "CorrectExamHandle.ashx",
                    type: "post",
                    data: { "HashKey": QueryString("HashKey"), "quesionKey": questionKey, "score": score },
                    dataType: "text",
                    success: function (data) {
                        if (data) {
                            if (parseInt(data) < 0) {
                                showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_ymxxbzq")%>", 2000, 5);
                            } else {//题目批改成功
                                var currIndex = $(".activeQuetion").index();
                                if (currIndex >= 0) {
                                    if (parseInt($(obj).val()) > 0) {
                                        $linkList.eq(currIndex).removeAttr("style");
                                    } else {
                                        $linkList.eq(currIndex).attr("style", "background-color: #008000; color: White;");
                                    }
                                    showTipsMsg("批改成功", 1000, 4);
                                }
                            }
                        } else {
                            showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>", 2000, 5);
                        }
                        $("#handleIcon").fadeOut(100);
                    },
                    error: function () {
                        showTipsMsg("<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("ChapterList_wlljyc")%>", 2000, 5);
                        $("#handleIcon").fadeOut(100);
                    }
                });
            }

            $("#endCurrect").click(function () { //查看答卷事件
                window.parent.parent.openDialog("/Training/Exam/Report.aspx?action=pigai&key=" + QueryString("HashKey"), 'ReportInfo', '<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_sjtj")%> - <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_dtbg")%>', 550, 220, 50, 50);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div runat="server" id="ExaminationPaperTitle">
        </div>
    </div>
    <div id="container">
        <div id="examItem">
            <div id="ei_Container">
                <div class="examContext">
                    <%=QuestionHtml.ToString() %>
                </div>
            </div>
            <div id="btnContainer">
                <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("CorrectExam_pgwc")%>" id="endCurrect" />

            </div>
            <div class="promptContext">
            </div>
        </div>
        <div id="toolBar">
            <div id="currStateInfo">
                <div class="ans_State">
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_CountExam")%></div>
                <div id="ans_State" style=" display:none;">
                    <label id="sumQueCount">
                        <%=SumCount %></label></div>
                <ul class="curr_State">
                    <li>
                        <%=LinkStateHtml.ToString() %>
                    </li>
                </ul>
                <div class="promptContext">
                
                    <label class="asterisk">
                        *
                    </label>
                    <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_zcxyhddxxxs")%> <span style="background-color: #FBD8D8;"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_Lightred")%> </span>
                    <br />
                     <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_ycxyhdcwdtxhxs")%> ：<span style="background-color: #008000; color: White;"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_red")%> </span>
                    <br />
               <a title="<%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CS_List_drbdspdszfs")%>" href="http://tks.1039.cn/Training/Learn/LearnPC.aspx?Key=797b4301-92ff-4653-93ba-c4a993212455" target="_blank" class="button green"><%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CoursewareType_Form_spbz")%></a>
               </div>
            </div>
        </div>
        <div class="clear">
        </div>
        <div id="handleIcon">
            <%=RM.Common.DotNetConfig.LanguageHelper.GetKey("CorrectExam_loading")%>...</div>
    </div>
    </form>
</body>
</html>
