<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Testing.aspx.cs" Inherits="Testing" %>
<!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">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <title>在线答题</title>
    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#labitem").html('1');
            $("#endimg").css("display", "none");
            next();
          
        });
        function next() {
            $.ajax({
                type: 'post',
                url: 'ashx/readitem.ashx',
                data: { cptype: $("#Hidtype").val(), item: $("#labitem").html() },
                success: function (msg) {
                    var res = msg.split('|');
                    $("#txt_Title").val(res[0]);
                    $("#txt_QuesA").val(res[1]);
                    $("#txt_QuesB").val(res[2]);
                    $("#txt_QuesC").val(res[3]);
                    $("#txt_QuesD").val(res[4]);
                    $("#Hidanswer").val(res[5]);
                    if (res[6] == "" || res[6] == null) {
                        $("#Subimg").css("display", "none");
                    } else {
                        $("#Subimg").css("display", "block");
                        $("#Subimg").attr("src", res[6]);
                    }
                }
            });
        }
        function nextItem() {
             var score = $("#Hidscore").val();
            var cusanswer='';
            $('input[type="checkbox"][name="checkoption"]:checked').each(
                function () {
                    $(this).attr("checked","");
                    cusanswer += $(this).next("span").html();
                });
                if (cusanswer == $("#Hidanswer").val()) {
                    score = score * 1;
                    score = score + 10;
                    $("#Hidscore").val(score);
            }
                else { score = score * 1;}
            var itemindex = $("#labitem").html();
            itemindex++;
            $("#labitem").html(itemindex);
            if (itemindex == 10) {
                $("#imgnext").css("display","none");
                $("#endimg").css("display", "block");
            }
            next();
        }
    </script>
   <style>
       body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(images/bg.gif);
	background-repeat: repeat-x;
}

</style>
<script type="text/javascript">
    var maxtime = 300;
    function countdown() {
        if (maxtime > 0) {
            minutes = Math.floor(maxtime / 60);
            seconds = Math.floor(maxtime % 60);
            msg = "距离结束还有" + minutes + "分" + seconds + "秒";
            document.all["timer"].innerHTML = msg;
            --maxtime;
        }
        else {
            clearInterval(endtime);
            alert("时间到,请点击结束作答");
            $("#imgnext").css("display", "none");
            $("#endimg").css("display", "block");
        }   
    }
    endtime= setInterval("countdown()", 1000); 
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div  >
    <table bgcolor="#73CDFF" border="1" align="center" >
    <tr> <td colspan="4"  style="background:url(images/test.jpg); height:91px;"></td></tr>
            <tr>
                <td  colspan="2" style=" border:0px; text-indent:10px;">
             第<label  id="labitem"><%=Item %></label>
                    <input id="Hidtype" type="hidden" value='<%=Cptype %>' />  题
                </td>
                <td  colspan="2"  style=" border:0px;" align="center">    <div id="timer" style="color:red; font-size:16px;"></div>   
                </td>
            </tr>
            <tr>
                <td align="center"  colspan="4" style=" width:832px;">
                    <textarea id="txt_Title" cols="20" rows="3" style="margin-left: 0px; height:73px; width:832px;  font-size:20px; "></textarea>
                </td>
            </tr>
            <tr><td colspan="4" style=" background-color:White;"  align="center">
            <img   id="Subimg" style=" display:none;"/>
              </td></tr>
            <tr>
                <td align="right" class="style4" style=" width:50px;">
                 <label id="labA"> <input id="CheckA" type="checkbox"  name="checkoption"/><span>A</span></label>  
                </td>
                <td colspan="3" class="style5" style=" width:782px;">
                    <textarea id="txt_QuesA" cols="20" rows="3" style=" height:46px; width:782px; font-size:16px;"></textarea>
               </td>
            </tr>
            <tr>
                <td align="right" class="style6" style=" width:50px;">
                      <label> <input id="CheckB" type="checkbox"  name="checkoption"/><span>B</span></label>  
                </td>
                <td colspan="3">
                    <textarea id="txt_QuesB" cols="20" rows="2" style=" height:46px; width:782px;font-size:16px;"></textarea>
                </td>
            </tr>
            <tr>
                <td align="right" class="style6" style=" width:50px;">
                      <label> <input id="CheckC" type="checkbox"  name="checkoption"/><span>C</span></label>  
                </td>
                <td colspan="3">
                    <textarea id="txt_QuesC" cols="20" rows="3"  style=" height:46px; width:782px; font-size:16px;"></textarea>
                </td>
            </tr>
            <tr>
                <td align="right" class="style6"  style=" width:50px;">
                      <label> <input id="CheckD" type="checkbox" name="checkoption"/><span>D</span></label>  
                </td>
                <td colspan="3">
                    <textarea id="txt_QuesD" cols="20" rows="2" style=" height:46px; width:782px; font-size:16px;"></textarea>
                </td>
            </tr>
            <tr >
                <td class="style6" style=" border:0px;">
                    &nbsp;</td>
                <td align="right" class="style8" style=" border:0px;">
                    <input id="Hidanswer" type="hidden"  value="<%=Answer %>"/>
                    &nbsp;</td>
                <td align="center" class="style7" style=" border:0px;">
                      <img  src="images/nextitem.gif" id="imgnext" alt="下一题" onclick="nextItem();" style="cursor:pointer;" />
                    <input id="Hidscore" type="hidden"  value="0"  name="Hidscore"/>    
                </td>
                <td align="center" style=" border:0px;">
                <div id="endimg" style="  display:none;">
                    <asp:ImageButton ID="btnend" runat="server"  ImageUrl="~/images/endscore.gif" OnClientClick="nextItem();" onclick="btnend_Click" />
            
                     </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
