<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebExam.Admin_EditST" Title="修改试题" Codebehind="KS.EditST.aspx.cs" %>

<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>

<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="Server">
    <script type="text/javascript" charset="utf-8" src="/KS_Inc/ueditor/kityformula-plugin/addKityFormulaDialog.js"></script>
    <script type="text/javascript" charset="utf-8" src="/KS_Inc/ueditor/kityformula-plugin/getKfContent.js"></script>
    <script type="text/javascript" charset="utf-8" src="/KS_Inc/ueditor/kityformula-plugin/defaultFilterFix.js"></script>
    
    <asp:Panel ID="AddPanel" runat="server" Width="100%">
        <!--<KS:TopNav ID="TopNav1" runat="server" Text="修改试题" />-->
        <script>
            function checkform() {
                if (jQuery(editorTxtTmnr.hasContents() == false)) {
              //  KesionJS.Alert('题内容需要录入!','jQuery("#<%=this.TxtTmnr.ClientID%>").focus();');
                // return false;
            }
            var tmType = jQuery("#<%=this.DrpTMType.ClientID %> option:selected").val();

                if (tmType == '0') {
                    KesionJS.Alert('请选择试题类型!', '');
                    return false;
                }
                if (tmType == '6') {
                    if (i < 1) {
                        KesionJS.Alert('请添加小题!', '');
                        return false;
                    }
                    else {

                        for (var j = 1; j <= i; j++) {
                            var xttype1 = parseInt(jQuery("#tmt" + j + " option:selected").val());
                            if (xttype1 == '2' || xttype1 == '3' || xttype1 == '4') {

                                if (jQuery("input[name=ans" + j + "]:checked").val() == undefined) {
                                    KesionJS.Alert('请选择第' + j + '小题参考答案!', '');
                                    return false;
                                }
                            }
                        } 
                    }

                }
                else if (tmType == '7') {
                    if (i7 < 1) {
                        KesionJS.Alert('请添加分录题参考答案!', '');
                        return false;
                    }
                } else if (tmType == '2' || tmType == '3' || tmType == '4') {

                    if (jQuery("input[name=answer1]:checked").val() == undefined) {
                        KesionJS.Alert('请选择参考答案!', '');
                        return false;
                    }

                }

                return true;
            }
            function showmedia() {
                if (jQuery("#<%=this.ChkIsMedia.ClientID %>")[0].checked) {
                jQuery("#<%=this.media.ClientID %>").show();
            } else {
                jQuery("#<%=this.media.ClientID %>").hide();
                }
            }
            function showansweroption(v) {
                for (var i = 2; i <= 9; i++) {
                    jQuery("#l1" + i).hide();
                    jQuery("#a11" + i).hide();
                }
                for (var i = 2; i <= v; i++) {
                    jQuery("#l1" + i).show();
                    jQuery("#a11" + i).show();
                }
            }
            function showansweroption1(v, type, i) {
                for (var ii = 3; ii <= 9; ii++) {
                    jQuery("#l" + type + "" + i + "" + ii).hide();
                    jQuery("#a1" + type + "" + i + "" + ii).hide();
                }
                for (var ii = 3; ii <= v; ii++) {
                    jQuery("#l" + type + "" + i + "" + ii).show();
                    jQuery("#a1" + type + "" + i + "" + ii).show();
                }

            }
            function settmtype(v) {
                if (v == 6) {
                    jQuery("#tm6").show();
                    jQuery("#tm7").hide();
                    jQuery("#commomtm").hide();
                    jQuery("#dxkoufs").hide();
                    jQuery("#pdtwrong").hide();
                    jQuery("#pddckoufs").hide();
                    addTM();
                    addTM();
                } else if (v == 7) {
                    jQuery("#tm7").show();
                    jQuery("#tm6").hide();
                    jQuery("#commomtm").hide();
                    jQuery("#dxkoufs").hide();
                    jQuery("#pdtwrong").hide();
                    jQuery("#pddckoufs").hide();
                    addFLTM();
                    addFLTM();
                } else {

                    jQuery("#tm6").hide();
                    jQuery("#tm7").hide();
                    jQuery("#commomtm").show();
                    jQuery("#dxkoufs").hide();
                    jQuery("#pdtwrong").hide();
                    jQuery("#pddckoufs").hide();
                    jQuery.get("KS.SJAddTm.aspx", { action: "getanswer", "rnd": Math.random(), tmtype: v }, function (v) {
                        //console.log(v)
                        jQuery('#showanswer').html(unescape(v)).find('textarea').each(function () {
                            replaceEditor(this.id);
                        });

                    });
                    if (v == 3) {
                        jQuery("#dxkoufs").show();
                        jQuery("#pddckoufs").hide();
                        jQuery("#pdtwrong").hide();
                    }
                    else if (v == 4) {
                        jQuery("#pddckoufs").show();
                        jQuery("#pdtwrong").show();
                    }
                }
            }
            function replaceEditor(id) {

                UE.delEditor(id);
                <%=Kesion.APPCode.EditorAPI.EditorTag("ExamEditorTag") %>.getEditor(id, { toolbars: [<%=Kesion.APPCode.EditorAPI.EditorToolBar("Basic")%>], initialFrameWidth: 580, initialFrameHeight: 80, wordCount: false, autoHeightEnabled: false, minFrameHeight: 80, elementPathEnabled: false });
            }
            function replaceCk(obj, id) {
                var um = <%=Kesion.APPCode.EditorAPI.EditorTag("ExamEditorTag")%>.getEditor(id, { toolbars: [<%=Kesion.APPCode.EditorAPI.EditorToolBar("Basic")%>], wordCount: false, elementPathEnabled: false, initialFrameHeight: 120 });
                obj.style.display = 'none';
            }
            jQuery(function () {

           <%if (KSCMS.S("typeid") != "" || (KSCMS.S("from") == "tk"))
            { %>
            settmtype(jQuery("#<%=this.DrpTMType.ClientID %> option:selected").val());
            <%} %>


            <%if (tmId != 0 && (tmtype == 7)) //编辑题目为阅读分析题，不允许更改题目类型
            {%>
            jQuery("#<%=this.DrpTMType.ClientID%>").attr("disabled", true);
            <%}%>
            });

        </script>
        <style>
            #upframe {height: 40px !important;vertical-align: middle;}
            .CTable input[type="text"] {vertical-align: auto;}
            label {padding-right: 0;}
            textarea {vertical-align: middle;margin-top: 15px;margin-left: 10px;}
            #xts select {margin-top: 15px;}
        </style>

        <table width="99%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable no-borderTable" style="table-layout:fixed">

            <tbody id="classidarea" runat="server">
                <tr>
                    <td class="lefttd" height="30" align="right"><b>试题分类：</b></td>
                    <td class="righttd">&nbsp;<asp:DropDownList ID="DrpClassID" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DrpClassID_SelectedIndexChanged">
                        <asp:ListItem Value="0">-选择试题分类-</asp:ListItem>
                    </asp:DropDownList>
                        <asp:DropDownList ID="drpSJtypeClass" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drpSJtypeClass_SelectedIndexChanged">
                    <asp:ListItem Value="0">-选择章节属性-</asp:ListItem>
                </asp:DropDownList>
                    <span style='display: <%=MyCache.GetSJCacheConfig(2)=="1"?"":"none"%>'>
                      <asp:DropDownList ID="KnowledgeBtn" runat="server">
                    <asp:ListItem Value="0">-选择知识点-</asp:ListItem>
                    </asp:DropDownList>
                    </span>
                        <div class="tips">Tips:试题分类建议选择最终级分类。</div>
                    </td>
                </tr>
            </tbody>

         

            <tr>
                <td class="lefttd" height="30" align="right"><b>题目类型：</b></td>
                <td class="righttd">&nbsp;<asp:DropDownList ID="DrpTMType" runat="server">
                    <asp:ListItem Value="0">-选择题目类型-</asp:ListItem>
                </asp:DropDownList>
                    &nbsp;<asp:DropDownList ID="DrpTMZDYType" runat="server">
                        <asp:ListItem Value="0">-选择自定义题目类型-</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>

            <tr>
                <td align="right" class="lefttd" height="30"> <strong>其他属性：</strong></td>
                <td class="righttd" id="Td1" runat="server">题目难度：<asp:DropDownList ID="DrpDifficulty" runat="server">
                </asp:DropDownList>
                    &nbsp;
                分值：<asp:TextBox ID="TxtTMFS" CssClass="textbox" runat="server" Width="30" Style="text-align: center"></asp:TextBox>
                    <asp:CheckBox ID="ChkIspublic" Text="题目共享（教师可搜索到此题目）" runat="server" />
                    <asp:CheckBox ID="ChkIsRnd" Text="随机题" runat="server" />
                    <asp:CheckBox ID="ChkIsMedia" Text="听力题" runat="server" />
                     <asp:CheckBox ID="CheckBoxCorrection" Text="允许纠错" runat="server" />
                </td>
            </tr>


            <tbody id="media" runat="server" style="display: none">
                <tr>
                    <td align="right" class="lefttd" height="30"><strong>音频地址：</strong></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="TxtMediaUrl" runat="server"></asp:TextBox>
                        <%=Kesion.APPCode.UploadAPI.EchoUpload("courseFile",this.TxtMediaUrl.ClientID,350) %>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30"><strong>听力原文：</strong></td>
                    <td class="righttd">
                        <asp:TextBox ID="TxtMediaTxt" runat="server" TextMode="MultiLine" Style="height: 120px; width: 700px"></asp:TextBox>
                        <%
                            Kesion.APPCode.EditorAPI.EchoEditor("editorTxtMediaTxt", TxtMediaTxt.ClientID, "Basic", 0, false, true, false, false, true);
                        %> 
                    </td>
                </tr>
            </tbody>
            <tr style="display: none">
                <td align="right" class="lefttd" height="30"><strong>题目标题：</strong></td>
                <td class="righttd">
                    <asp:TextBox ID="TxtTitle" CssClass="textbox" Width="500" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right" class="lefttd" height="30"> <strong>题目内容：</strong></td>
                <td class="righttd">
                    <asp:TextBox ID="TxtTmnr" TextMode="MultiLine" Style="height: 120px; width: 98%" runat="server"></asp:TextBox>
                    <%
                        Kesion.APPCode.EditorAPI.EchoEditor("editorTxtTmnr", TxtTmnr.ClientID, "Basic", 0, false, true, false, false, true);
                    %> 
                    <span class="tips">如选择题填写具体的选项,填空题在需要用户作答的地方放{#answer}标签,使用编辑器时按shift+Enter分段</span>
                </td>
            </tr>
           
            <tr id="tm6" <%=(tmtype==6)?"":" style='display:none'" %>>
                <td align="right" class="lefttd" height="30">
                    <strong>小题目：</strong>
                    <br />
                    <br />
                    <input type="button" class="button" value="增加小题" onclick="addTM()" /></td>
                <td class="righttd">
                    <table width='100%'>
                        <tbody id='xts'>
                            <%
                                StringBuilder sb = new StringBuilder();
                                int i = 0;
                                if (tmId != 0 && tmtype == 6)
                                {
                                   
                                    using (DataTable dt = DataFactory.GetDataTable("select top 100 * From KS_SJTKSub Where ParentTmid=" + tmId))
                                    {
                                        if (dt.Rows.Count > 0)
                                        {
                                            foreach (DataRow dr in dt.Rows)
                                            {
                                                i++;
                                                int xttype = Utils.StrToInt(dr["tmtype"].ToString());
                                                sb.AppendLine(string.Format(@"<tr id='t{0}'><td width='550' valign='top'>第<font color=green><strong>{0}</strong></font>小题 <strong>题目：</strong><textarea name='qus{0}' id='qus{0}' style='width:480px;height:80px'>{1}</textarea><input type='hidden' name='tmid{0}' value='{2}'/>", i, dr["tmnr"].ToString(), dr["tmid"].ToString()));

                                                sb.Append(Kesion.APPCode.EditorAPI.EchoEditor("editorqus" + i, "qus" + i, "Basic", 0, false, false, false, false, true));

                                                sb.AppendLine(string.Format(@"题目类型：<select onchange=setAns(this.value,{0}) name='tmt{0}' id='tmt{0}'>", i));
                                                sb.AppendLine("<option value='2'");
                                                if (xttype == 2) sb.Append(" selected");
                                                sb.Append(">单选题</option><option value='4'");
                                                if (xttype == 4) sb.Append(" selected");
                                                sb.Append(">对错题</option><option value='5'");
                                                if (xttype == 5) sb.Append(" selected");
                                                sb.Append(">填空题</option><option value='3'");
                                                if (xttype == 3) sb.Append(" selected");
                                                sb.Append(">多选题</option><option value='1'");
                                                if (xttype == 1) sb.Append(" selected");
                                                sb.Append(">主观题</option></select>");
                                                if (xttype == 1)
                                                    sb.AppendLine("<br/>参考答案:");
                                                else
                                                    sb.AppendLine("&nbsp;&nbsp;参考答案:");

                                                sb.AppendLine(@"<span id='sa" + i + "'>");

                                                string answer = dr["answer"].ToString();
                                                int defaultoptionnum = Utils.StrToInt(dr["optionnum"].ToString(), 4);
                                                string appContent = string.Concat(dr["appanswer"].ToString(), "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
                                                string[] appanswer = System.Text.RegularExpressions.Regex.Split(appContent, @"[$]{4}");
                                                string style = " style='width:480px;height:80px' ";
                                                switch (xttype)
                                                {
                                                    case 2:
                                                        sb.AppendLine(@"选项个数：<select onchange='showansweroption1(this.value," + xttype + "," + i + ");' name='optionnum" + i + "' id='optionnum" + i + "'>");
                                                        for (int nn = 2; nn <= 9; nn++)
                                                        {
                                                            sb.Append("<option value='" + nn + "'");
                                                            if (defaultoptionnum == nn) sb.Append(" selected");
                                                            sb.Append(">" + nn + "个</option>");
                                                        }
                                                        sb.Append("</select><br >");

                                                        for (int j = 0; j < 9; j++)
                                                        {
                                                            //char zimu = (char)(A + j);
                                                            sb.AppendFormat(@"<label id='l2{0}{4}' {5}><input type='radio' value='{3}' name='ans{0}' {6}/>({3})</label>
                        <span id='a12{0}{4}' {5}><textarea {1} id='appans{0}{4}' name='appans{0}{4}'  >{7}</textarea>
                     {2}<br />
                      </span> ", i, " style='width:700px;height:80px' ", Kesion.APPCode.EditorAPI.EchoEditor("editorappans" + i + (j + 1), "appans" + i + (j + 1), "Basic", 0, false, false, false, false, true), Kesion.Exam.Function.NunToChar(j), j + 1, j < defaultoptionnum ? "" : " style='display:none'", answer == Kesion.Exam.Function.NunToChar(j) ? " checked" : string.Empty, appanswer[j]);
                                                        }

                                                        break;
                                                    case 3:
                                                        sb.AppendLine(@"选项个数：<select onchange='showansweroption1(this.value," + xttype + "," + i + ");' name='optionnum" + i + "' id='optionnum" + i + "'>");
                                                        for (int nn = 2; nn <= 9; nn++)
                                                        {
                                                            sb.Append("<option value='" + nn + "'");
                                                            if (defaultoptionnum == nn) sb.Append(" selected");
                                                            sb.Append(">" + nn + "个</option>");
                                                        }
                                                        sb.Append("</select> <br >");
                                                        for (int j = 0; j < 9; j++)
                                                        {
                                                            //char zimu = (char)(A + j);
                                                            sb.AppendFormat(@"<label id='l3{0}{4}' {5}><input type='checkbox' value='{3}' name='ans{0}' {6}/>({3})</label>
                        <span id='a13{0}{4}' {5}><textarea {1} id='appans{0}{4}' name='appans{0}{4}'  >{7}</textarea>
                     {2}<br />
                      </span> ", i, " style='width:700px;height:80px' ", Kesion.APPCode.EditorAPI.EchoEditor("editorappans" + i + (j + 1), "appans" + i + (j + 1), "Basic", 0, false, false, false, false, true), Kesion.Exam.Function.NunToChar(j), j + 1, j < defaultoptionnum ? "" : " style='display:none'", answer.ToLower().IndexOf(Kesion.Exam.Function.NunToChar(j).ToLower()) != -1 ? " checked" : string.Empty, appanswer[j]);
                                                        }

                                                        break;
                                                    case 4:
                                                        sb.AppendLine(string.Format(@"<input type='radio' name='ans{0}' value='1'{1}/>对", i, answer == "1" ? " checked" : string.Empty));
                                                        sb.AppendLine(string.Format(@"<input type='radio' name='ans{0}' value='0'{1}/>错", i, answer == "0" ? " checked" : string.Empty));
                                                        break;
                                                    case 5:
                                                        sb.AppendLine(string.Format(@"<input type='text' name='ans{0}' value='{1}' class='textbox'/>", i, answer));
                                                        break;
                                                    case 1:
                                                        sb.AppendLine(string.Format(@"<textarea name='ans{0}' id='ans{0}' style='width:480px;height:80px'>{1}</textarea>", i, answer));
                                                        sb.Append(Kesion.APPCode.EditorAPI.EchoEditor("editorans" + i, "ans" + i, "Basic", 0, false, false, false, false, true));
                                                        break;
                                                }

                                                sb.AppendLine("</span>");
                                                sb.AppendLine(@"<br/><span id='ztkoufs" + i + "'>");
                                                switch (xttype)
                                                {
                                                    case 3:
                                                        sb.AppendLine(string.Format(@"&nbsp;&nbsp;少选,每个选项:<input type='text' id='ztdxkoufs{0}' name='ztdxkoufs{0}' class='textbox' value='{1}' style='text-align:center;width:30px'/>分 <span class='tips'>如果是扣分,填写数,例如：1</span>", i, dr["KouFS"].ToString()));
                                                        break;
                                                    case 4:
                                                        sb.AppendLine(string.Format(@"&nbsp;&nbsp;答错扣:<input type='text' id='ztpdtkoufs{0}' name='ztpdtkoufs{0}' class='textbox' value='{1}' style='text-align:center;width:30px'/>分 ", i, dr["KouFS"].ToString()));
                                                        sb.AppendLine(string.Format(@"&nbsp;不答是否扣分:<input type='radio' name='iskoufs{0}' value='0'{1}/>否", i, Utils.StrToInt(dr["IsKouFS"].ToString()) == 0 ? " checked" : string.Empty));
                                                        sb.AppendLine(string.Format(@"<input type='radio' name='iskoufs{0}' value='1'{1}/>是", i, Utils.StrToInt(dr["IsKouFS"].ToString()) == 1 ? " checked" : string.Empty));
                                                        break;
                                                }
                                                sb.AppendLine("</span>");

                                                sb.AppendLine("答案解释：<br/><textarea  style='width:480px;height:80px' name='dajs" + i + "' id='dajs" + i + "'/>" + dr["DAJS"].ToString() + "</textarea>");
                                                sb.Append(Kesion.APPCode.EditorAPI.EchoEditor("editordajs" + i, "dajs" + i, "Basic", 0, false, false, false, false, true));


                                                sb.AppendLine("</td><td align='left'>分数:<input type='text' name='fs" + i + "' class='textbox' value='" + dr["TMfs"].ToString() + "' style='text-align:center;width:30px'/>分</td><td style='text-align:center'><a href='javascript:;' onclick='removeTr(" + i + "," + dr["tmid"].ToString() + ");return false;'>删</a></td></tr>");
                                                sb.AppendLine("<tr><td colspan=10 style='height:1px;border-bottom:1px solid #999'></td></tr>");
                                            }
                                        }
                                    }
                                   Response.Write(sb.ToString());
                                }
                            %>
                        <tbody>
                    </table>
                    <input type="hidden" name="xtnum6" id="xtnum6" value="<%=i %>" />
                    <script>

                        function GetKouFs(type, i) {
                            //多选和判断题的
                            var str = '';

                            switch (parseInt(type)) {
                                case 3:
                                    str += "&nbsp;&nbsp;少选,每个选项得:<input type='text' id='ztdxkoufs" + i + "' name='ztdxkoufs" + i + "' class='textbox' value='0' style='text-align:center;width:30px'/>分 ";
                                    break;
                                case 4:
                                    str += "&nbsp;&nbsp;答错扣:<input type='text' id='ztpdtkoufs" + i + "' name='ztpdtkoufs" + i + "' class='textbox' value='0' style='text-align:center;width:30px'/>分 "

                                    str += "&nbsp;不答是否扣分:<label><input type='radio' value='0' name='ztiskoufs" + i + "' />否</label>"
                                    str += " <label><input type='radio' value='1' name='ztiskoufs" + i + "' />是</label>";
                                    break;

                            }
                            return str;
                        }
                        function setAns(v, i) {
                            jQuery("#sa" + i).html(GetAns(v, i)).find('textarea').each(function () {
                                replaceEditor(this.id);
                            });
                            jQuery("#ztkoufs" + i).html(GetKouFs(v, i));
                            var tv = parseInt(v);

                            if (tv == 1) {
                                replaceEditor('ans' + i);
                            }
                        }

                        var i =<%=i%>;
                        function addTM() {
                            i++;
                            var str = '';
                            var xttype = 2;
                            str += "<tr id='t" + i + "'><td style='width:550px;'  valign='top'>第<font color=green><strong>" + i + "</strong>小题</font> <strong>题目：</strong><textarea name='qus" + i + "' id='qus" + i + "' style='width:480px;height:80px'></textarea>";

                            str += "题目类型：<select onchange=setAns(this.value," + i + ") name='tmt" + i + "' id='tmt" + i + "'>";

                            str += "<option value='2'";
                            if (xttype == 2) str += " selected"
                            str += ">单选题</option><option value='4'";
                            if (xttype == 4) str += " selected"
                            str += ">对错题</option><option value='5'";
                            if (xttype == 5) str += " selected"
                            str += ">填空题</option><option value='3'";
                            if (xttype == 3) str += " selected"
                            str += ">多选题</option><option value='1'";
                            if (xttype == 1) str += " selected"
                            str += ">主观题</option></select>";
                            if (xttype == 1)
                                str += "<br/>参考答案:";
                            else
                                str += "&nbsp;&nbsp;参考答案:";
                            str += "<span id='sa" + i + "'></span>";
                            //str += "<span id='labelsa"+i+"'>" +GetAns(xttype,i)+"</span>";
                            str += "答案解释：<br/><textarea  style='width:700px;height:80px' name='dajs" + i + "' id='dajs" + i + "'/></textarea>"

                            str += "</td><td align='left'>分数:<input type='text' name='fs" + i + "' class='textbox' value='1' style='text-align:center;width:30px'/>分</td><td style='text-align:center'><a href='javascript:;' onclick='removeTr(" + i + ",0);return false;'>删</a></td></tr>";
                            str += "<tr><td colspan=10 style='height:1px;border-bottom:1px solid #999'></td></tr>";
                            jQuery("#xtnum6").val(i);
                            jQuery("#xts").append(str);

                            replaceEditor('qus' + i);
                            replaceEditor('dajs' + i);

                            if (xttype == 1) replaceEditor('ans' + i);
                            if (xttype == 2 || xttype == 3) {
                                $('#sa' + i).html(GetAns(xttype, i)).find('textarea').each(function () {
                                    replaceEditor(this.id);
                                });
                            }
                        }
                        function removeTr(i, tmid) {
                            if (tmid == 0) {
                                jQuery("#t" + i).remove();
                            } else {
                                jQuery.ajax({
                                    type: "POST",
                                    url: "KS.EditST.aspx",
                                    data: "tmid=" + tmid + "&action=DelSubTM",
                                    success: function (data) {
                                        jQuery("#t" + i).remove();
                                    }
                                });

                            }
                        }
                        function GetAns(type, i) {
                            var str = '';
                            var defaultoptionnum = 4;
                            switch (parseInt(type)) {
                                case 2:
                                    str += "选项个数：<select onchange='showansweroption1(this.value," + type + "," + i + ");' name='optionnum" + i + "' id='optionnum" + i + "'>";
                                    for (var nn = 2; nn <= 9; nn++) {
                                        str += "<option value='" + nn + "'"
                                        if (defaultoptionnum == nn) str += " selected";
                                        str += ">" + nn + "个</option>";
                                    }

                                    str += "</select><br/>";
                                    str += "<input type='radio' name='ans" + i + "' value='A'/>A";
                                    str += "<textarea  name='appans" + i + "1' id='appans" + i + "1'  style='width:700px;height:80px'></textarea><br >";
                                    str += "<input type='radio' name='ans" + i + "' value='B'/>B";
                                    str += "<textarea  name='appans" + i + "2' id='appans" + i + "2'  style='width:700px;height:80px'></textarea><br >";
                                    str += "<label id='l2" + i + "3'";
                                    if (defaultoptionnum < 3) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='C'/>C</label>";

                                    str += "<span id='a12" + i + "3'";
                                    if (defaultoptionnum < 3) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "3' id='appans" + i + "3' style='width:700px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l2" + i + "4'";
                                    if (defaultoptionnum < 4) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='D'/>D</label>";
                                    str += "<span id='a12" + i + "4' ";
                                    if (defaultoptionnum < 4) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "4' id='appans" + i + "4' style='width:700px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l2" + i + "5'";
                                    if (defaultoptionnum < 5) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='E'/>E</label>";
                                    str += "<span id='a12" + i + "5'";
                                    if (defaultoptionnum < 5) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "5' id='appans" + i + "5' style='width:700px;height:80px'></textarea><br ></span>";

                                    str += "<label id='l2" + i + "6'";
                                    if (defaultoptionnum < 6) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='F'/>F</label>";
                                    str += "<span id='a12" + i + "6'";
                                    if (defaultoptionnum < 6) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "6' id='appans" + i + "6' style='width:700px;height:80px'></textarea><br ></span>";

                                    str += "<label id='l2" + i + "7'";
                                    if (defaultoptionnum < 7) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='G'/>G</label>";
                                    str += "<span id='a12" + i + "7'";
                                    if (defaultoptionnum < 7) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "7' id='appans" + i + "7' style='width:700px;height:80px'></textarea><br ></span>";

                                    str += "<label id='l2" + i + "8'";
                                    if (defaultoptionnum < 8) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='H'/>H</label>";
                                    str += "<span id='a12" + i + "8'";
                                    if (defaultoptionnum < 8) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "8' id='appans" + i + "8' style='width:700px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l2" + i + "9'";
                                    if (defaultoptionnum < 9) str += " style='display:none'";
                                    str += "><input type='radio' name='ans" + i + "' value='I'/>I</label>";
                                    str += "<span id='a12" + i + "9'";
                                    if (defaultoptionnum < 9) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "9' id='appans" + i + "9' style='width:700px;height:80px'></textarea><br ></span>";

                                    break;
                                case 3:
                                    str += "选项个数：<select onchange='showansweroption1(this.value," + type + "," + i + ");' name='optionnum" + i + "' id='optionnum" + i + "'>";
                                    for (var nn = 2; nn <= 9; nn++) {
                                        str += "<option value='" + nn + "'"
                                        if (defaultoptionnum == nn) str += " selected";
                                        str += ">" + nn + "个</option>";
                                    }
                                    str += "</select>"

                                    str += "<br ><input type='checkbox' name='ans" + i + "' value='A'/>A";
                                    str += "<textarea  name='appans" + i + "1'  id='appans" + i + "1'  style='width:480px;height:80px'></textarea><br >";
                                    str += "<input type='checkbox' name='ans" + i + "' value='B'/>B";
                                    str += "<textarea  name='appans" + i + "2' id='appans" + i + "2' style='width:480px;height:80px'></textarea><br >";
                                    str += "<label id='l3" + i + "3'";
                                    if (defaultoptionnum < 3) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='C'/>C</label>";
                                    str += "<span id='a13" + i + "3'";
                                    if (defaultoptionnum < 3) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "3' id='appans" + i + "3'  style='width:480px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l3" + i + "4'";
                                    if (defaultoptionnum < 4) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='D'/>D</label>";
                                    str += "<span id='a13" + i + "4'";
                                    if (defaultoptionnum < 4) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "4' id='appans" + i + "4' style='width:480px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l3" + i + "5'";
                                    if (defaultoptionnum < 5) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='E'/>E</label>";
                                    str += "<span id='a13" + i + "5'";
                                    if (defaultoptionnum < 5) str += " style='display:none'"
                                    str += "><textarea  name='appans" + i + "5'  id='appans" + i + "5'  style='width:480px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l3" + i + "6'";
                                    if (defaultoptionnum < 6) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='F'/>F</label>";
                                    str += "<span id='a13" + i + "6'";
                                    if (defaultoptionnum < 6) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "6' id='appans" + i + "6' style='width:480px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l3" + i + "7'";
                                    if (defaultoptionnum < 7) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='G'/>G</label>";
                                    str += "<span id='a13" + i + "7'";
                                    if (defaultoptionnum < 7) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "7' id='appans" + i + "7'  style='width:480px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l3" + i + "8'";
                                    if (defaultoptionnum < 8) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='H'/>H</label>";
                                    str += "<span id='a13" + i + "8'";
                                    if (defaultoptionnum < 8) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "8'  id='appans" + i + "8' style='width:480px;height:80px'></textarea><br ></span>";
                                    str += "<label id='l3" + i + "9'";
                                    if (defaultoptionnum < 9) str += " style='display:none'";
                                    str += "><input type='checkbox' name='ans" + i + "' value='I'/>I</label>";
                                    str += "<span id='a13" + i + "9'";
                                    if (defaultoptionnum < 9) str += " style='display:none'";
                                    str += "><textarea  name='appans" + i + "9' id='appans" + i + "9' style='width:480px;height:80px'></textarea><br ></span>";
                                    break;
                                case 4:
                                    str += "<input type='radio' name='ans" + i + "' value='1'/>对";
                                    str += "<input type='radio' name='ans" + i + "' value='0'/>错";
                                    break;
                                case 5:
                                    str += "<input type='text' name='ans" + i + "' class='textbox'/>";
                                    break;
                                case 1:
                                    str += "<textarea  style='width:480px;height:80px' name='ans" + i + "' id='ans" + i + "'/></textarea>";
                                    break;
                            }
                            return str;
                        }

                    </script>

                </td>
            </tr>
            <tr id="tm7" <%=(tmtype==7)?"":" style='display:none'" %>>
                <td align="right" class="lefttd" style="line-height: 35px;">
                    <strong>分录参考答案：</strong>
                    <br />
                    <input type="button" class="button" value="增加分录答案" onclick="addFLTM()" /><br />
                    <input type="button" class="button" value="增加计算题答案" onclick="addJsTM()" />
                </td>
                <td class="righttd">
                    <table width='100%'>
                        <tbody id='flda'>
                            <%
                                sb = new StringBuilder();
                                i = 0;
                                if (tmId != 0 && tmtype == 7)
                                {
                                    using (DataTable dt = DataFactory.GetDataTable("select * From KS_SJTKSub Where ParentTmid=" + tmId))
                                    {
                                        if (dt.Rows.Count > 0)
                                        {

                                            foreach (DataRow dr in dt.Rows)
                                            {

                                                i++;
                                                int tmnum = 0;
                                                sb.Append("<tr id='t" + i + "'><td valign='top' style='width:30px;'>(" + i + ")、</td><td valign='top' id='my" + i + "'>");
                                                if (string.IsNullOrEmpty(dr["tmnr"].ToString()))
                                                {
                                                    string[] anArr = dr["answer"].ToString().Split('§');
                                                    tmnum = anArr.Length;
                                                    for (int n = 1; n <= tmnum; n++)
                                                    {
                                                        string[] myanArr = string.Concat(anArr[n - 1], "№№№").Split('№');
                                                        sb.Append("<div id='s" + i + "" + n + "'>借贷方向：<input name='ans" + i + "" + n + "1' type='radio' value='借'");
                                                        if (myanArr[0] == "借") sb.Append(" checked");
                                                        sb.Append(">借 <input name='ans" + i + "" + n + "1' type='radio' value='贷'");
                                                        if (myanArr[0] == "贷") sb.Append(" checked");
                                                        sb.Append(">贷");
                                                        sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;会计科目：<input type='text' style='width:80px' name='ans" + i + "" + n + "2' id='ans" + i + "" + n + "2' value='" + myanArr[1] + "' class='textbox'/> <input type='button' class='button' onclick=selectKM('ans" + i + "" + n + "2') value='...'/>");
                                                        sb.Append("&nbsp;&nbsp;&nbsp;&nbsp;金额：<input type='text' style='width:50px' name='ans" + i + "" + n + "3' value='" + myanArr[2] + "' class='textbox'/>");
                                                        sb.Append("&nbsp;&nbsp; <input type='button' class='button' onclick='cloneTr(" + i + ")' value='增'/> <input class='button' type='button' class='del' onclick='removeDiv(" + n + "," + i + ");' value='删'/></div>");

                                                    }
                                                }
                                                else
                                                {
                                                    //分录计算题
                                                    sb.Append("<input name='isjst" + i + "' type='hidden' value='1'/>");
                                                    string[] tmArr = dr["tmnr"].ToString().Split('§');
                                                    string[] anArr = dr["answer"].ToString().Split('§');
                                                    tmnum = tmArr.Length;
                                                    for (int n = 1; n <= tmnum; n++)
                                                    {
                                                        sb.Append("<div id='s" + i + "" + n + "'>题目：<input type='text' class='textbox' name='tm" + i + "" + n + "' style='width:200px;' value='" + tmArr[n - 1] + "'/>&nbsp;&nbsp;");
                                                        sb.Append("参考答案：<input name='ans" + i + "" + n + "' type='text' class='textbox' style='width:50px' value='" + anArr[n - 1] + "'/>");
                                                        sb.Append("&nbsp;&nbsp; <input type='button' class='button' onclick='cloneTrJS(" + i + ")' value='增'/> <input class='button' type='button' class='del' onclick='removeDiv(" + n + "," + i + ");' value='删'/></div>");

                                                    }
                                                }
                                                sb.AppendLine("</td><td valign='top'><input type='hidden' name='tmid" + i + "' value='" + dr["tmId"].ToString() + "'/><input type='hidden' name='num" + i + "' id='num" + i + "' value='" + tmnum + "'/>分数：<input type='text' name='fs" + i + "' class='textbox' value='" + dr["tmfs"].ToString() + "' style='text-align:center;width:30px'/>分</td><td><a href='javascript:;' onclick='removeTr(" + i + "," + dr["tmid"].ToString() + ");return false;'>删</a></td></tr>");


                                            }
                                        }
                                    }
                                    Response.Write(sb.ToString());
                                }
                            %>
                        <tbody>
                    </table>
                    <input type="hidden" name="xtnum7" id="xtnum7" value="<%=i %>" />
                    <script>

                        var i7 =<%=i%>;
                        function addFLTM() {
                            i7++;
                            var str = "<tr id='t" + i7 + "'><td valign='top' style='width:30px;'>(" + i7 + ")、</td><td valign='top' id='my" + i7 + "'>";
                            str += oneDiv(i7, 1);
                            str += oneDiv(i7, 2);
                            str += "</td><td valign='top'><input type='hidden' name='num" + i7 + "' id='num" + i7 + "' value='2'/>分数：<input type='text' name='fs" + i7 + "' class='textbox' value='1' style='text-align:center;width:30px'/>分</td></tr>";

                            jQuery("#xtnum7").val(i7);
                            jQuery("#flda").append(str);
                        }

                        function selectKM(FieldID) {
                            OpenThenSetValue('/plus/exam/SelectKM.aspx?from=editst&fieldID=' + FieldID, 500, 350, window, jQuery('#' + FieldID)[0]);

                        }

                        function oneDiv(i, n) {
                            var str = "<div id='s" + i + "" + n + "'>借贷方向：<input name='ans" + i + "" + n + "1' type='radio' value='借'>借 <input name='ans" + i + "" + n + "1' type='radio' value='贷'>贷";
                            str += "&nbsp;&nbsp;&nbsp;&nbsp;会计科目：<input style='width:80px' type='text' name='ans" + i + "" + n + "2' id='ans" + i + "" + n + "2' class='textbox'/> <input type='button' class='button' onclick=selectKM('ans" + i + "" + n + "2') value='...'/>";
                            str += "&nbsp;&nbsp;&nbsp;&nbsp;金额：<input style='width:50px' type='text' name='ans" + i + "" + n + "3' class='textbox'/>";
                            str += "&nbsp;&nbsp; <input type='button' class='button' onclick='cloneTr(" + i + ")' value='增'/> <input class='button' type='button' class='del' onclick='removeDiv(" + n + "," + i + ");' value='删'/></div>";
                            return str;
                        }
                        function oneDivJST(i, n) {
                            var str = "<div id='s" + i + "" + n + "'>题目：<input type='text' class='textbox' name='tm" + i + "" + n + "' style='width:200px;' value='计算金额：{#answer}'/>&nbsp;&nbsp;参考答案：<input name='ans" + i + "" + n + "' type='text' class='textbox' style='width:50px'/>";
                            str += "&nbsp;&nbsp; <input type='button' class='button' onclick='cloneTrJS(" + i + ")' value='增'/> <input class='button' type='button' class='del' onclick='removeDiv(" + n + "," + i + ");' value='删'/></div>";
                            return str;
                        }
                        function cloneTrJS(i) {
                            var n = parseInt(jQuery("#num" + i).val()) + 1;
                            jQuery("#num" + i).val(n);
                            jQuery("#my" + i).append(oneDivJST(i, n));

                        }
                        function cloneTr(i) {
                            var n = parseInt(jQuery("#num" + i).val()) + 1;
                            jQuery("#num" + i).val(n);
                            jQuery("#my" + i).append(oneDiv(i, n));

                        }
                        function removeDiv(n, i) {
                            if (jQuery("#my" + i).find("div").length == 1) {
                                alert('不能删除了，最少需要一条记录!');
                                return;
                            } else {
                                jQuery("#s" + i + "" + n).remove();
                            }
                        }
                        //分录题里的计算题
                        function addJsTM() {
                            i7++;
                            var str = "<tr id='t" + i7 + "'><td valign='top' style='width:30px;'>(" + i7 + ")、<input type='hidden' name='isjst" + i7 + "' value='1'/></td><td valign='top' id='my" + i7 + "'>";
                            str += oneDivJST(i7, 1);
                            str += "</td><td valign='top'><input type='hidden' name='num" + i7 + "' id='num" + i7 + "' value='1'/>分数：<input type='text' name='fs" + i7 + "' class='textbox' value='1' style='text-align:center;width:30px'/>分</td></tr>";

                            jQuery("#xtnum7").val(i7);
                            jQuery("#flda").append(str);
                        }
                    </script>

                </td>
            </tr>



            <tr id="commomtm" <%=(tmtype<=5)?"":" style='display:none'" %>>
                <td align="right" class="lefttd" height="30">
                    <strong>参考答案：</strong></td>
                <td class="righttd" id="showanswer">
                    <asp:Label ID="LabAnswer" runat="server"></asp:Label>
                </td>
            </tr>

            <tr <%=(tmtype==3)?"":" style='display:none'" %> id="dxkoufs">
                <td align="right" class="lefttd" height="30">
                    <strong>少选，每个选项得：</strong></td>
                <td class="righttd">
                    <asp:TextBox CssClass="textbox" ID="TxtKouFS" runat="server" Width="50" Text="0"></asp:TextBox>
                分
                
            </tr>
            <tr <%=(tmtype==4)?"":" style='display:none'" %> id="pddckoufs">
                <td align="right" class="lefttd" height="30">
                    <strong>答错扣：</strong></td>
                <td class="righttd">

                    <asp:TextBox CssClass="textbox" ID="TxtPPdtKouFS" runat="server" Width="50" Text="0"></asp:TextBox>
                分
               
            </tr>
            <tr <%=(tmtype==4)?"":" style='display:none'" %> id="pdtwrong">
                <td align="right" class="lefttd" height="30">
                    <strong>不答是否扣分：</strong></td>
                <td class="righttd">

                    <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="horizontal">
                        <asp:ListItem Value="0" Selected>否</asp:ListItem>
                        <asp:ListItem Value="1">是</asp:ListItem>
                    </asp:RadioButtonList>
            </tr>
            <tr>
                <td align="right" class="lefttd" height="30">
                    <strong>答案解释：</strong></td>
                <td class="righttd">
                    <asp:TextBox ID="TxtDAJS" TextMode="MultiLine" Style="height: 120px; width: 700px" runat="server"></asp:TextBox>
                    <%
                        Kesion.APPCode.EditorAPI.EchoEditor("editorTxtDAJS", TxtDAJS.ClientID, "Basic", 0, false, true, false, false, true);
                    %>
            </tr>
            <tr>
                <td align="right" class="lefttd" height="30">
                    <strong>答案解释视频：</strong></td>
                <td class="righttd"><asp:TextBox CssClass="textbox" ID="TxtDAJSMedia" Width="350" runat="server"></asp:TextBox><div class="blank10"></div>
                    <%=Kesion.APPCode.UploadAPI.EchoUpload("courseFile",this.TxtDAJSMedia.ClientID,350) %>
                </td>
            </tr>


            <tr>
                <td align="right" class="lefttd" height="30">
                    <strong>题目序号：</strong></td>
                <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="TxtOrderID" runat="server" Width="60px"></asp:TextBox><span class="tips">序号越小排在越前面</span></td>
            </tr>
        </table>
        <br />
        <div class="pop-button">
            <asp:HiddenField ID="HidClassID" runat="server" Value="0" />
            <asp:Button ID="Button1" CssClass="button" runat="server" AccessKey="O" Text="确定修改(O)" OnClick="Button1_Click" />
            <input type="button" class="button" value="取消关闭(C)" accesskey="C" onclick="javascript: parent.box.close();" />
            <br />
        </div>
        <br />
    </asp:Panel>



</asp:Content>
