<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin_SJAddST" Title="为试卷添加试题" CodeBehind="KS.SJAddST.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.BLL" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
    <asp:Panel ID="ListPanel" runat="server" Width="100%">
<!--<KS:TopNav ID="TopNav2" runat="server" Text="试题管理" />-->
<div class="content-area mt20">  

    <div class="myTitle">
        <div class='fr'>
            <a href="<%=Kesion.HtmlTags.BasicField.GetExamUrl("exam","ht-1,do-ex,id-"+sjId) %>" target="_blank" class="mr20 button">预览</a>
            <%if (KSCMS.S("action") == "modifyth")
            {%>
                <asp:Button ID="BtnSaveTH" onclick="Button1_Click" Text="批量保存题号修改" runat="server" CssClass="mr20 button" />
            <%}
            else if (Repeater1.Items.Count>0)
            { %>
                <div style="display:none"><input type="button" class="mr20 button" value="批量修改题号" onclick="location.href='KS.SJAddST.Aspx?action=modifyth&sjid=<%=sjId %>';" /></div>
                <!--<input type="button" class="mr20 button" value="批量添加试题及答案" onclick="location.href='KS.SJAddST.Aspx?action=add&sjid=<%=sjId %>';" />
                <input type='button' value='检查试卷总分' onclick='checkZF(<%=sjId%>)' class='mr20 button'/>-->
                <asp:Button ID="Button3" runat="server" Text="批量试题共享" CssClass="mr20 button" OnClick="gongx_Click" />    
            <%} %>
        </div>
        试题管理
    </div>
    <script>
        function addTk(id, sjid, tmtype) {
            var s = $('#tmty' + id).val();
            if (s == '') {
               
            }
            parent.openWin('选择题库', 'exam/KS.SelectTk.aspx?action=select&tmids='+s+'&sjid=' + sjid + '&typeid='+id + '&tmtype=' + tmtype, true, 1000, 520);
        }
    
        function editSt(id) {
            parent.openWin('修改试题', 'exam/KS.EditSt.Aspx?tmid=' + id, false, 1300, 760);
        }
        function addSt(typeid) {
            parent.openWin('添加试题', 'exam/KS.EditSt.Aspx?typeid=' + typeid, false, 1300, 760);
        }
        function delDtt(typeid){
            if (confirm('删除大题，此大题下的试题将被清空，且此操作不可逆，确定执行删除操作吗？')){
                location.href='?action=deldt&sjid=<%=sjId %>&typeid='+typeid;
             }
        }
        function editDtjj(typeid) {
            parent.openWin('修改大题简介', 'exam/KS.EditDt.Aspx?typeid=' + typeid, true,800,480);
        }
        function checkZF(id) {
            parent.openWin('检查试卷总分', 'exam/KS.SJCheckZF.Aspx?id=' + id, false, 900, 520);
        }
        function showToggle(id) {
                     if (jQuery('#xt' + id).html() == '') {
                         jQuery('#xt' + id).append('<tr class="tdbg"><td height="30" align="center" colspan="4">本大题下还没有添加小题!</td></tr>');
                     }
                     var t = jQuery("#t" + id).html();
                     if (t.indexOf('展开') != -1) {
                         jQuery('#xt' + id).slideDown('fast');
                         jQuery("#t" + id).html('<img border="0" src="../../admin/images/icon_del_over.png" align="absmiddle"/>收起')
                     } else {
                     jQuery('#xt' + id).slideUp('fast');
                      jQuery("#t" + id).html('<img border="0" src="../../admin/images/icon_add_normal.png" align="absmiddle"/>展开')
                     }
                 }
                 jQuery(document).ready(function() {
                 <%if (KSCMS.S("action") == "modifyth") {%>
                     jQuery(".toggleArea").html('<img border="0" src="../../admin/images/icon_del_over.png" align="absmiddle"/>收起');
                     jQuery('.showArea').each(function(){
                       if (jQuery(this).html()==''){
                        jQuery(this).append('<tr class="tdbg"><td height="30" align="center" colspan="4">本大题下还没有添加小题!</td></tr>');
                        }
                     });
                     <%}else{ %>
                     jQuery(".toggleArea").html('<img border="0" src="../../admin/images/icon_del_over.png" align="absmiddle"/>收起');
                    // jQuery(".showArea").attr("style","display:none");
                     <%} %>
                 });
                 var currStatue=0;
             function openAll(){
               if (currStatue==1){ //展开
                    currStatue=0
                     jQuery(".toggleArea").html('<img border="0" src="../../admin/images/icon_del_over.png" align="absmiddle"/>收起');
                     jQuery('.showArea').each(function(){
                       if (jQuery(this).html()==''){
                        jQuery(this).append('<tr class="tdbg"><td height="30" align="center" colspan="4">本大题下还没有添加小题!</td></tr>');
                        }
                   });
                   jQuery('.showArea').show();
                   jQuery("#allstate").html('全部隐藏');
                }else{
                   currStatue=1;
                     jQuery(".toggleArea").html('<img border="0" src="../../admin/images/icon_add_normal.png" align="absmiddle"/>展开');
                     jQuery(".showArea").attr("style","display:none");
                     jQuery("#allstate").html('全部展开');
                }
             }
    </script>
         
    
    
       
        <asp:Repeater ID="Repeater1" runat="server"  onitemdatabound="Repeater1_ItemDataBound" >
          <HeaderTemplate>
          <table width="98%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable mytable" style="table-layout:fixed">
              <tr class="CTitle topbar">
               <td height="25" width="48" align="center"><b>序号</b></td>
               <td style="text-align:left">&nbsp;&nbsp;<b>题目内容</b>(<a href="javascript:;" onclick="openAll()" id="allstate">全部隐藏</a>)</td>
               <td align="center" nowrap width="200"><b>操作</b></td>
              </tr>
          </HeaderTemplate>
         <ItemTemplate>
         
             <TR class="tdbg sort bar">
                 <td align="center" nowrap>
                 <span style='cursor:pointer' id='t<%# Eval("typeid") %>' class="toggleArea" onclick="showToggle(<%# Eval("typeid") %>);">
                 </span></td>
				 <td style="padding-top:2px;padding-bottom:2px;padding-left:10px;">
				 
				 <strong>
				 第<%# UtilsAutoID.CapitalFigures(Container.ItemIndex)%>大题&nbsp;
				 <%#Eval("typename")%>
                     <%# (Convert.ToString(Eval("TmType"))!="6" && Convert.ToString(Eval("TmType"))!="7")?"<br/>"+Eval("intro"):"" %>
				</strong>
				
				</td>
				<td style="text-align:center;width:170px;" nowrap >
                 <a onclick='addTk(<%#Eval("typeid")%>,<%#Eval("sjid")%>,<%#Eval("TmType")%>)' class='greenFont'>选择题库</a>&nbsp;&nbsp;&nbsp;
				 <a onclick='addSt(<%#Eval("typeid") %>)' class='greenFont'/>添加</a>&nbsp;&nbsp;&nbsp;
				 <a onclick='editDtjj(<%#Eval("typeid") %>,0)' class='greenFont'/>修改</a>&nbsp;&nbsp;&nbsp;
                 <a onclick='delDtt(<%# Eval("typeid") %>);' class="greenFont"/>删除</a>
                 <input type="hidden" name="tmty<%#Eval("typeid")%>" id="tmty<%#Eval("typeid")%>" value="<%#Eval("tmids")%>"  />   

                </td>
			</TR>
			 <tbody id="xt<%# Eval("typeid") %>" class="showArea">
             <asp:Repeater ID="Repeater2" runat="server">
               <ItemTemplate>
               <tr class="tdbg"> 
                  <td style="text-align:center" width="48"> 
                  <%if (KSCMS.S("action") == "modifyth")
                    {%>
                    <input type='hidden' name='th' value='<%# Eval("tmid") %>'/>
		            <input class='textbox' type='text' style='text-align:center;width:36px' name='orderid<%# Eval("tmid") %>' value='<%# DataBinder.Eval(Container.DataItem,"OrderID") %>' size='2'/>
		          <%}
                    else
                    { %>
		           <font color=red>
		           <strong><%# Container.ItemIndex + 1%>.</strong>
		          </font>
		          <%}

		          %>
		          <br/>
		          <span class="tips">(<%# DataBinder.Eval(Container.DataItem,"TMFS") %>分)</span>
		          </td>
		          <td style="padding:10px;word-break:break-all; width:70%">
		            <strong><%# Eval("title") %></strong><%# Utils.StrToInt( Eval("ispublic"))==1 ?"<font color=green>(题目共享)</font>":string.Empty %><br />
		            <%# Kesion.Exam.Function.ReplaceTKTTags(Utils.replaceBR(Convert.ToString(DataBinder.Eval(Container.DataItem, "TMNR"))),1,1)%>
		            
		            <div style='height:5px;border-bottom:1px dashed #cccccc;overflow:hidden'></div>
			        <span class="datips">
		           <%# (Utils.StrToInt(Eval("tmtype"))!=6 && Utils.StrToInt(Eval("tmtype"))!=7)?"<div><div class='dabt'>参考答案：</div>"+Kesion.Exam.Function.GetCKDA(Utils.StrToInt(Eval("tmtype")),Convert.ToString(Eval("answer"))):"</div>"%>
		           <%# string.IsNullOrEmpty(Convert.ToString(Eval("dajs"))) ? "" : "<br/>答案解释：" + Utils.replaceBR(Convert.ToString(DataBinder.Eval(Container.DataItem, "dajs")))%>
			        </span>
			          </div></td>
               
                  <td style="text-align:center;width:170px;padding-top:2px;" nowrap valign="top"> 
		          <a href="javascript:;" onClick="editSt(<%# Eval("tmid") %>);" style="color:#808080">编辑</a> 
                    <a href="?action=delst&tmid=<%# Eval("tmid") %>" onClick="return confirm('您确定进行删除操作吗？')" style="color:#808080">删除</a> 

                      <br /><br /> 
                      <input type="checkbox" name="ids" value='<%# Eval("tmid") %>' />

                  </td>
                </tr>
               </ItemTemplate>
             </asp:Repeater>
             
         </tbody>  
  
         </ItemTemplate>
          <FooterTemplate>
           <tr class="tdbg" style="display:<%# bool.Parse((Repeater1.Items.Count==0).ToString())?"":"none"%>">
                <td class="Ctd" style="text-align:center" colspan="3">
                  <a href="KS.SJAddST.Aspx?action=add&sjid=<%=sjId %>">还没有添加任何试题，点此添加&raquo;</a>
                </td>
               </tr> 
           </table>
          </FooterTemplate>
        </asp:Repeater>
    <div class="listedit">
        <% if (Repeater1.Items.Count > 0){ %>
        <input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);"/><label for="chkall">全选</label>
        <asp:Button ID="BtnDel" runat="server" Text="删除选中的试题" CssClass="button" OnClick="BtnDel_Click" />
        
        <%}
        if (KSCMS.S("action") == "modifyth")
        {%>
        <asp:Button ID="Button1" onclick="Button1_Click" Text="批量保存题号修改" runat="server" CssClass="button" />
        <%}
        else if (Repeater1.Items.Count>0)
        { %>
        <input type="button" class="button" value="批量修改题号" onclick="location.href='KS.SJAddST.Aspx?action=modifyth&sjid=<%=sjId %>';" style="display:none" />
        <%} %>
        <input type="button" class="button" value="批量添加试题及答案" onclick="location.href='KS.SJAddST.Aspx?action=add&sjid=<%=sjId %>';" />
        <% if (Repeater1.Items.Count > 0){ %>
        <input type='button' value='检查试卷总分' onclick='checkZF(<%=sjId%>)' class='button'/>
        <%} %>
    </div>
	<div class="footer_page"></div>
    <asp:Panel ID="Panel1" runat="server" Height="30px" Width="100%">
        <script type="text/javascript">
            showtips('<span class="state"><strong>操作说明：</strong><br /></span>在此页面您可以给试卷增加，修改或是删除试题。');
        </script>
    </asp:Panel>
</asp:Panel>
</div>

     
 <asp:Panel ID="AddPanel" runat="server"  Width="100%" Visible="false">
 <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>

    <KS:TopNav ID="TopNav1" runat="server" Text="添加试题" />
 <div class="content-area">   
    <script>
       
        function gettmType(s) {
            s=parseInt(s);
            switch (s) {
                case 1: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "主观题"; break;
                case 5: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "填空题"; break;
                case 2: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "单选题"; break;
                case 3: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "多选题"; break;
                case 4: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "判断题"; break;
                case 6: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "阅读分析"; break;
                case 7: document.getElementById("<%=this.TxtTypeName.ClientID%>").value = "会计分录题"; break;
            }
            if (s==6||s==7){
                currnum=1;
                jQuery("#kjfl").empty();
                jQuery("#ydlj").empty();
                if (s==6){
                    jQuery("#ydt").show();
                    jQuery("#kjflt").hide();
                    jQuery("#kjfl").hide();
                }else{
                    jQuery("#kjflt").show();
                    jQuery("#ydt").hide();
                    jQuery("#ydlj").hide();
                }
                jQuery("#showdajs").show();
                jQuery("#showtmnr").show();
                jQuery("#showth").hide();
                jQuery("#dxkoufs").hide();
                jQuery("#pdtkoufs").hide();
                 jQuery("#showxttype").hide();
            }else{
              
                jQuery("#ydt").hide();
                jQuery("#kjflt").hide();
                jQuery("#showdajs").hide();
                <%if (KSCMS.S("Isrndsj") == "1")
                { %>
                jQuery("#showtmnr").hide();
                jQuery("#showth").hide();
                <%}else{%>
                jQuery("#showth").show();
                <%}%>
                jQuery("#dxkoufs").hide();
                jQuery("#pdtkoufs").hide();
                if (s == 3) {

                    jQuery("#dxkoufs").show();

                }
                else if (s == 4) {
                    jQuery("#pdtkoufs").show();
                } else if (s == 8) {
                    jQuery("#showxttype").hide();
                }
                else {
                      jQuery("#showxttype").show();
                }

            }
        }
        function CheckForm() {
       
         if (jQuery("#<%=this.DrpTmType.ClientID %> option:selected").val()=='0'){
          KesionJS.Alert( '请选择试卷类型！', "");
          return false;
         }
         if (jQuery("#<%=this.TxtTypeName.ClientID %>").val()==''){
          KesionJS.Alert( '请输入类型名称！', "jQuery('#<%=this.TxtTypeName.ClientID %>').focus();");
          return false;
         }
            if (jQuery("#<%=this.DrpTmType.ClientID %> option:selected").val() == '6' || jQuery("#<%=this.DrpTmType.ClientID %> option:selected").val() == '7') {

                if (editor.hasContents() == false) {

                    KesionJS.Alert("请输入题目内容！", "editor.focus();");
                    return false;
                }
                if (currnum <= 1) {
                    KesionJS.Alert('请添加小题！', "");
                    return false;
                }
                else {
                  
                    for (var i=1; i <= currnum; i++) {
                        var xttype1 = parseInt(jQuery("#tmt"+i+" option:selected").val());
                        if (xttype1 == '2' || xttype1 == '3' || xttype1 == '4') {
                         
                            if (jQuery("input[name=ans"+i+"]:checked").val() == undefined) {
                                KesionJS.Alert('请选择第'+i+'小题参考答案!', '');
                                return false;
                            }
                        }
                    }


                }
            }


        }
        function replaceEditor(id) {
             UE.delEditor(id);
          <%=Kesion.APPCode.EditorAPI.EditorTag("ExamEditorTag") %>.getEditor(id,{toolbars:[<%=Kesion.APPCode.EditorAPI.EditorToolBar("Basic")%>],initialFrameWidth:700,initialFrameHeight:80,wordCount:false,autoHeightEnabled:false,minFrameHeight:80,elementPathEnabled:false });
         }
        var currnum = 1;
        function addxt() {
           var num = jQuery("#<%=this.TxtNum.ClientID %>").val();
           var fs = jQuery("#<%=this.TxtScore.ClientID %>").val();
           var defaultTm = jQuery("#defaultTm").val();
           var xttype = parseInt(jQuery("#xttype option:selected").val());
           var str = "";
           var denum=currnum;
           for (var i = currnum; i <= num; i++) {
               str += "<tr id='t"+i+"'><td valign='top' width='750'>第 <font color=green><strong>" + i + "</strong></font> 小题  <strong>题目内容：</strong><textarea name='qus" + i + "' id='qus" + i + "' style='width:700px;height:80px;margin-bottom:10px;'>" + defaultTm + "</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+"'>" +GetAns(xttype,i)+"</span>";
               str += "<span id='sa" + i + "'></span>";
               str += "<span id='ztkoufs"+i+"'>" +GetKouFs(xttype,i)+"</span>";
               
               str +="<br/>答案解释：<input type='button' class='button' value='使用编辑器' onclick=\"replaceEditor('dajs" + i + "');\"/><br/><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='" + fs + "' style='text-align:center;width:50px'/>分</td><td style='text-align:center'><a href='javascript:;' onclick='removeTr("+i+");return false;'>删除</a></td></tr>";
               //str +="<tr><td colspan=10 style='height:1px;border-bottom:1px solid #999'></td></tr>";
               currnum++;
           }
           if (str != '') {
               jQuery("#ydlj").show().append("<tr><td align='right' class='lefttd'><strong>小题：</strong><br/><br/><span class='tips'>如果是选择题在题目内容填写具体的选项,填空题在需要用户作答的地方放{#answer}标签。</span></td><td class='righttd'><table width='95%'>" + str + "</table></td></tr>");
               for (var i=denum;i<=num;i++){
                   replaceEditor('qus' + 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 showansweroption(v,type,i) {
            for (ii = 3; ii <= 9; ii++) {
                jQuery("#l"+type+""+i+"" + ii).hide();
            }
            for (var ii = 3; ii <= v; ii++) {
                jQuery("#l"+type+""+i+"" + ii).show();
            }
        }
       function GetAns(type,i) {
           var str ='';
           var defaultoptionnum=jQuery("#defaultoptionnum option:selected").val();
           switch (parseInt(type)) {
               case 2:
                   str += "选项个数：<select onchange='showansweroption(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 style='width:480px;height:80px'   id='appans"+i+"1' name='appans"+i+"1'></textarea><br />";

                   str += "<input type='radio' name='ans" + i + "' value='B'/>B";
                   str += " <textarea style='width:480px;height:80px'   id='appans"+i+"2' name='appans"+i+"2'></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<textarea style='width:480px;height:80px'   id='appans"+i+"3' name='appans"+i+"3'></textarea><br /></label>";
                

                   str += "<label id='l2"+i+"4'";
                   if (defaultoptionnum<4) str+=" style='display:none'";
                   str += "><input type='radio' name='ans" + i + "' value='D'/>D<textarea style='width:480px;height:80px'   id='appans"+i+"4' name='appans"+i+"4'></textarea><br /></label>";
                  
                   str += "<label id='l2"+i+"5'";
                   if (defaultoptionnum<5) str+=" style='display:none'";
                   str += "><input type='radio' name='ans" + i + "' value='E'/>E<textarea style='width:480px;height:80px'   id='appans"+i+"5' name='appans"+i+"5'></textarea><br /></label>";
                 
                   str += "<label id='l2"+i+"6'";
                   if (defaultoptionnum<6) str+=" style='display:none'";
                   str += "><input type='radio' name='ans" + i + "' value='F'/>F<textarea style='width:480px;height:80px'   id='appans"+i+"6' name='appans"+i+"6'></textarea><br /></label>";
             
                   str += "<label id='l2"+i+"7'";
                   if (defaultoptionnum<7) str+=" style='display:none'";
                   str += "><input type='radio' name='ans" + i + "' value='G'/>G<textarea style='width:480px;height:80px'   id='appans"+i+"7' name='appans"+i+"7'></textarea><br /></label>";
                
                   str += "<label id='l2"+i+"8'";
                   if (defaultoptionnum<8) str+=" style='display:none'";
                   str += "><input type='radio' name='ans" + i + "' value='H'/>H<textarea style='width:480px;height:80px'   id='appans"+i+"8' name='appans"+i+"8'></textarea><br /></label>";
                 
                   str += "<label id='l2"+i+"9'";
                   if (defaultoptionnum<9) str+=" style='display:none'";
                   str += "><input type='radio' name='ans" + i + "' value='I'/>I<textarea style='width:480px;height:80px'   id='appans"+i+"9' name='appans"+i+"9'></textarea><br /></label>";
                 
                   break;
               case 3:
                   str += "选项个数：<select onchange='showansweroption(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='checkbox' name='ans" + i + "' value='A'/>A";
                   str += " <textarea style='width:480px;height:80px'   id='appans"+i+"1' name='appans"+i+"1'></textarea><br />";

                   str += "<input type='checkbox' name='ans" + i + "' value='B'/>B";
                   str += " <textarea style='width:480px;height:80px'   id='appans"+i+"2' name='appans"+i+"2'></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<textarea style='width:480px;height:80px'   id='appans"+i+"3' name='appans"+i+"3'></textarea><br /></label>";
                   str += "<label id='l3"+i+"4'";
                   if (defaultoptionnum<4) str+=" style='display:none'";
                   str +="><input type='checkbox' name='ans" + i + "' value='D'/>D<textarea style='width:480px;height:80px'   id='appans"+i+"4' name='appans"+i+"4'></textarea><br /></label>";
                   str += "<label id='l3"+i+"5'";
                   if (defaultoptionnum<5) str+=" style='display:none'";
                   str +="><input type='checkbox' name='ans" + i + "' value='E'/>E<textarea style='width:480px;height:80px'   id='appans"+i+"5' name='appans"+i+"5'></textarea><br /></label>";
                   str += "<label id='l3"+i+"6'";
                   if (defaultoptionnum<6) str+=" style='display:none'";
                   str +="><input type='checkbox' name='ans" + i + "' value='F'/>F<textarea style='width:480px;height:80px'   id='appans"+i+"6' name='appans"+i+"6'></textarea><br /></label>";
                   str += "<label id='l3"+i+"7'";
                   if (defaultoptionnum<7) str+=" style='display:none'";
                   str +="><input type='checkbox' name='ans" + i + "' value='G'/>G<textarea style='width:480px;height:80px'   id='appans"+i+"7' name='appans"+i+"7'></textarea><br /></label>";
                   str += "<label id='l3"+i+"8'";
                   if (defaultoptionnum<8) str+=" style='display:none'";
                   str +="><input type='checkbox' name='ans" + i + "' value='H'/>H<textarea style='width:480px;height:80px'   id='appans"+i+"8' name='appans"+i+"8'></textarea><br /></label>";
                   str += "<label id='l3"+i+"9'";
                   if (defaultoptionnum<9) str+=" style='display:none'";
                   str +="><input type='checkbox' name='ans" + i + "' value='I'/>I<textarea style='width:480px;height:80px'   id='appans"+i+"9' name='appans"+i+"9'></textarea><br /></label>";
                   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 + "' id='ans" + i + "' class='textbox'/>";
                   break;
               case 1:
                   str += "<textarea  style='width:700px;height:80px' name='ans" + i + "' id='ans" + i + "'/></textarea>";
                   break;
           }
           return str;
       }
       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='1' style='text-align:center;width:30px'/>分"  
                       
                        +"&nbsp;不答是否要扣分:<label><input type='radio' value='0' name='ztiskoufs"+i+"' />否</label>"
                       +" <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));
          
           if (v==1){
               replaceEditor('ans' + i);
             
           }
          

       }
       function removeTr(i){
           jQuery("#t"+i).remove();
       }
       //添加分录答案
       function addflt(){
           var num = jQuery("#<%=this.TxtNum.ClientID %>").val();
           var fs = jQuery("#<%=this.TxtScore.ClientID %>").val();
           var str = "";
           for (var i = currnum; i <= num; i++) {
               str += "<tr id='t"+i+"'><td valign='top' style='width:30px;'>(" + i + ")、</td><td valign='top' id='my"+i+"'>";
               str += oneDiv(i,1);
               str += oneDiv(i,2);
               str +="</td><td valign='top' style='white-space: nowrap;'><input type='hidden' name='num"+i+"' id='num"+i+"' value='2'/>分数：<input type='text' name='fs" + i + "' class='textbox' value='" + fs + "' style='text-align:center;width:30px'/>分</td></tr>";
               currnum++;
           }
           if (str != '') {
               jQuery("#kjfl").show().append("<tr><td align='right' class='lefttd' style='white-space: nowrap;'><strong>分录题参考答案：</strong><br/><br/></td><td class='righttd'><table width='100%'>" + str + "</table></td></tr>");
           }
       }
        //给分录题增加计算题
        function addJst(){
            var fs = jQuery("#<%=this.TxtScore.ClientID %>").val();
            var str = "";
            i = currnum
            jQuery("#<%=this.TxtNum.ClientID %>").val(i);
            // alert(i);
            str += "<tr id='t"+i+"'><td valign='top' style='width:30px;'>(" + i + ")、<input type='hidden' name='isjst"+i+"' value='1'/></td><td valign='top' id='my"+i+"'>";
                str += oneDivJST(i,1);
                str +="</td><td valign='top'><input type='hidden' name='num"+i+"' id='num"+i+"' value='1'/>分数：<input type='text' name='fs" + i + "' class='textbox' value='" + fs + "' style='text-align:center;width:30px'/>分</td></tr>";
                currnum++;
            if (str != '') {
                jQuery("#kjfl").show().append("<tr><td align='right' class='lefttd'><strong>计算题：</strong><br/><br/></td><td class='righttd'><table width='90%'>" + str + "</table></td></tr>");
            }
        }

        function oneDivJST(i,n){
            var str="<div id='s"+i+""+n+"'>题目：<input type='text' class='textbox' name='tm" + i + ""+n+"' style='width:300px;' value='计算金额：{#answer}'/>&nbsp;&nbsp;参考答案：<input name='ans" + i + ""+n+"' type='text' class='textbox' width='100px'/>";
            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 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 += "<br>会计科目：<input type='text' name='ans" + i + ""+n+"2' id='ans" + i + ""+n+"2' class='textbox'/> <input type='button' onclick=selectKM('ans" + i + ""+n+"2') class='button' value='...'/>";
            str += "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;金额：<input 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><br>";
            return str;
        }
        function selectKM(FieldID) {

            parent.openWin('选择科目','/plus/exam/SelectKM.aspx?from=admin&fieldID='+FieldID,false,350,380);
           
        }
        function cloneTr(i){
            var n=parseInt(jQuery("#num"+i).val())+1;
            jQuery("#num"+i).val(n);
            jQuery("#my"+i).append(oneDiv(i,n));

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

        }
        function removeDiv(n,i){
            if (jQuery("#my"+i).find("div").length==1){
                alert('不能删除了，最少需要一条记录!');
                return;
            }else{
                jQuery("#s"+i+""+n).remove();
            }
        }
        function chanageoption(v){
            if (v==2 || v==3){
                jQuery("#showoptionnum").show();
            }else{
                jQuery("#showoptionnum").hide();
            }
        }


	 </script>
	 <style>
	     .addtips{text-align:center;font-size:16px;margin:5px;}
	 </style>
	<asp:Label ID="LabTips" runat="server"></asp:Label>
    <table width="99%" align="center" border="0" cellpadding="0" cellspacing="0" class="CTable no-borderTable"> 
          <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> <span class="tips">Tips:除主观题不支持自动计分外，其它题型均支持自动计分。</span>
            </td>
        </tr>
       <tr>
            <td align="right" class="lefttd" height="30">
                <strong>类型名称：</strong></td>
            <td class="righttd">
                &nbsp;<asp:TextBox ID="TxtTypeName" CssClass="textbox" runat="server" Text=""></asp:TextBox><span class="tips">如判断题、简答时、论述题、单选题,填空题等</span></td>
        </tr>
        <%if (KSCMS.S("Isrndsj") == "1")
          { %>
       <tr style="display:none" id="showtmnr">
       <%}
          else
          { %>
          <tr id="showtmnr">
       <%} %>
            <td align="right" class="lefttd" height="30">
                <strong>题目简介：</strong></td>
            <td class="righttd" valign="top">
                <asp:TextBox ID="TxtTmIntro" TextMode="MultiLine" style="width:800px;height:140px;" Columns="40" Rows="2" runat="server" Text=""></asp:TextBox>
                <% Kesion.APPCode.EditorAPI.EchoEditor("editor", this.TxtTmIntro.ClientID, "Basic",0,false,true,false,false,true);%>
               
            </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30">
                <strong>此大题总共有：</strong></td>
            <td class="righttd">
               
                <div style="margin-bottom:10px;"> &nbsp;<asp:TextBox Width="50"  CssClass="textbox" ID="TxtNum" runat="server" Text="2"></asp:TextBox>道小题 &nbsp;&nbsp;默认每小题 &nbsp;<asp:TextBox  CssClass="textbox" ID="TxtScore" runat="server" Width="50" Text="1"></asp:TextBox>分&nbsp;&nbsp; </div>
              
                <span id="ydt" style="display:none;">
                 默认小题内容：<input type="text" class="textbox" value="" name="defaultTm" id="defaultTm" />
                 默认小题题型：<select name="xttype" onchange="chanageoption(this.value)" id="xttype"><option value="2"  selected="selected">单选题</option><option value="3">多选题</option><option value="4">对错题</option><option value="5">填空题</option><option value="1">主观题</option></select>
                <span id="showoptionnum">默认选项<select name="defaultoptionnum" id="defaultoptionnum">
                    <option value="2">2个</option>
                    <option value="3">3个</option>
                    <option value="4" selected="selected">4个</option>
                    <option value="5">5个</option>
                    <option value="6">6个</option>
                    <option value="7">7个</option>
                    <option value="8">8个</option>
                    <option value="9">9个</option>
                    </select></span>
                 <input type="button" class="button button_on" value="添加小题"  onclick="addxt()"/>
                </span>

                <span id="kjflt" style="display:none">
                 <input type="button" class="button" value="添加分录答案"  onclick="addflt()"/>
                 <input type="button" class="button" value="添加计算题"  onclick="addJst()"/>
                </span>
        
                <span id="dxkoufs" style="display:none">
                 少选，每个选项得<asp:TextBox  CssClass="textbox" ID="TxtKouFS" runat="server" Width="50" Text="0"></asp:TextBox>分
                </span>
 
                <span id="pdtkoufs" style="display:none">
                  <span class="fl">答错扣:<asp:TextBox  CssClass="textbox" ID="TxtPPdtKouFS" runat="server" Width="50" Text="0"></asp:TextBox>分</span>
				  <span class="fl" style="margin-left:20px;">
                    <span class="fl" style="line-height:34px;margin-left: 10px;">&nbsp;不答是否扣分</span>                    
                    <asp:RadioButtonList ID="RadioButtonList1" runat="server"  RepeatDirection="horizontal" CssClass="fl" Height="34" style="margin-top: 5px;margin-left: 5px;">
                        <asp:ListItem Value="0"  Selected>否</asp:ListItem>
                        <asp:ListItem Value="1">是</asp:ListItem>
                    </asp:RadioButtonList> 
					<div class="clear"></div> 
				  </span>
				  <div class="clear"></div> 
                </span>

                <span style="line-height:34px;"> &nbsp;<asp:CheckBox ID="CkbAddRnd" Checked="true" runat="server" Text="此大题下的小题允许加入随机题库" /></span>
              </td>
        </tr>
        <%if (KSCMS.S("Isrndsj") == "1")
          { %>
       <tr style="display:none" id="showth">
       <%}
          else
          { %>
          <tr id="showth">
       <%} %>
            <td align="right" class="lefttd" height="30" >
                <strong>小题开始题号：</strong></td>
            <td class="righttd"> &nbsp;
            <asp:Label ID="LabXiHao" runat="server"></asp:Label>
              
              <span class="tips">Tips：建议按默认方式添加。</span>
                </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30">
                <strong>序号：</strong></td>
            <td class="righttd">&nbsp;
                <asp:TextBox Width="50"  CssClass="textbox" ID="TxtOrderID" runat="server" Text="1" style="text-align:center"></asp:TextBox> 
                <span class="tips">Tips:数据越小排在越前面</span></td>
        </tr>
        <tbody id="ydlj"></tbody>
        <tbody id="kjfl"></tbody>


        <tr style="display:none" id="showdajs">
            <td align="right" class="lefttd" height="30">
                <strong>答案解释：</strong></td>
            <td class="righttd" valign="top"><asp:TextBox ID="TxtDAJS" TextMode="MultiLine" style="width:700px;height:120px" Columns="40" Rows="2" runat="server" Text=""></asp:TextBox>
             <% Kesion.APPCode.EditorAPI.EchoEditor("editor1", this.TxtDAJS.ClientID, "Basic", 0, false, true, false, false,true);%>

            </td>
        </tr>


         <%if (Utils.StrToInt(KSCMS.S("Isrndsj"))!=1)
             { %>
          <tr id="showxttype" >
            <td align="right" class="lefttd" height="30">
                <strong>选择添加题方式：</strong></td>
            <td class="righttd">

           <asp:RadioButtonList ID="RadioButtonList2" runat="server"  RepeatDirection="horizontal" CssClass="fl" Height="34" style="margin-top: 5px;margin-left: 5px;">
                        <asp:ListItem Value="0"  Selected>手工添加</asp:ListItem>
                        <asp:ListItem Value="1">选题添加</asp:ListItem>
                    </asp:RadioButtonList> 
                <span class="tips">如果选择是选题添加的话，题目分数是直接以选题的试题分数为主</span>
           </td>
              </tr>
        <%} %>
      </table>
      <asp:TextBox ID="TxtClassID" style="display:none" runat="server" />
        <KS:Foot ID="Foot1" runat="server" OnSubmit="Foot1_Submit" />
      
    </asp:Panel>
    
 </div>   

</asp:Content>