<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin_SJRndST" Title="为随机组卷试题管理" Codebehind="KS.SJRndST.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
    <asp:Panel ID="ListPanel" runat="server" Width="100%">
   <script src="http://cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML"></script> <!--数学公式-->
<KS:TopNav ID="TopNav2" runat="server" Text="试题管理" />
<div class="content-area">
<script>
    function editSt(id) {
        parent.openWin('修改试题', 'exam/KS.EditSt.Aspx?tmid=' + id, true,1300, 760);
    }
    function addSt(typeid) {
        parent.openWin('添加试题', 'exam/KS.EditSt.Aspx?rndid='+typeid+'&classid=<%=classId%>&typeid=1', true,1300, 760);
    }
    function editDtjj(id) {
        parent.openWin('修改大题简介', 'exam/KS.EditRndDt.Aspx?id=' + id, true,900,580);
    }
    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_add_normal.png" align="absmiddle"/>打开');
                 jQuery(".showArea").attr("style","display:none");
                 <%} %>
         });
         var currStatue=1;
         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>
         <div style="margin:10px">
                 <span style="float:right">
                 <a href="<%=Kesion.HtmlTags.BasicField.GetExamUrl("exam","do-ex,ht-1,id-"+sjId) %>" style="color:green;font-weight:bold" target="_blank">预览</a>
            </span>
         <%if (KSCMS.S("action") == "modifyth")
           {%>
           <asp:Button ID="BtnSaveTH" onclick="Button1_Click" Text="批量保存题号修改" runat="server" CssClass="button" />
          <%}
           else
           { %>
          <input type="button" class="button" value="批量修改大题题号" onclick="location.href='<%=KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4)%>/Exam/KS.SJRndST.Aspx?action=modifyth&sjid=<%=sjId %>';" />
          <%} %>
          <input type="button" class="button" value="批量添加试题及答案" onclick="location.href='<%=KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4)%>/Exam/KS.SJAddST.Aspx?action=add&isrndsj=1&sjid=<%=sjId %>';" />
         <input type='button' value='检查试卷总分' onclick='checkZF(<%=sjId%>)' class='button'/>
         </div>
        <asp:Repeater ID="Repeater1" runat="server" 
            onitemdatabound="Repeater1_ItemDataBound" >
          <HeaderTemplate>
          <table width="99%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable">
              <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="170"><b>操作</b></td>
              </tr>
          </HeaderTemplate>
         <ItemTemplate>
         
             <TR class="tdbg sort bar">
              <td align="center" nowrap>
                 <span style='cursor:pointer' id='t<%# Eval("id") %>' class="toggleArea" onclick="showToggle(<%# Eval("id") %>);">
                 </span>
                 </td>
				 <td style="padding-top:2px;padding-bottom:2px;padding-left:10px;" valign="top">
				 <strong>
				 第
				 <%if (KSCMS.S("action") == "modifyth")
       {%>
          <input type='hidden' name='th' value='<%# Eval("id") %>'/>
		  <input class='textbox' type='text' style='width:50px;text-align:center' name='orderid<%# Eval("id") %>' value='<%# DataBinder.Eval(Container.DataItem,"OrderID") %>' size='2'/>
		          <%}
       else
       { %>
				 <%# UtilsAutoID.CapitalFigures(Utils.StrToInt(Convert.ToString(Eval("orderid")), 1)-1)%>
				 
				 <%} %>大题&nbsp;
				 <%#Eval("title")%>&nbsp;<span class="tips">(每小题<%# Eval("fs") %>分)</span>
				 <br/>
				 <%# Eval("intro") %>
				</strong>
				
				</td>
				<td style="text-align:center" width="200">
				 <input type='button' value='添加' onclick='addSt(<%#Eval("id") %>)' class='button'/>
				 <input type='button' value='修改' onclick='editDtjj(<%#Eval("id") %>,0)' class='button'/>
                 <input type="button" value="删除" class="button" onClick="if (confirm('删除大题，此大题下的试题将被清空，且此操作不可逆，确定执行删除操作吗？')){location.href='?action=deldt&sjid=<%=sjId %>&dtid=<%# Eval("id") %>';}"/>
                </td>
			</TR>
			<tbody id="xt<%# Eval("id") %>" class="showArea">
             <asp:Repeater ID="Repeater2" runat="server">
               <ItemTemplate>
               
               <tr class="tdbg"> 
                  <td style="text-align:center" width="48"> 
		           <font color=red>
		           <strong><%# Container.ItemIndex + 1%>.</strong>
		          </font>

		          <br/>
		          <span class="tips">(<%# DataBinder.Eval(Container.DataItem,"TMFS") %>分)</span>
		          </td>
		          <td style="padding:10px">
		            <strong><%# Eval("title") %></strong><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="tips">
		           <%# (Utils.StrToInt(Eval("tmtype"))!=6 && Utils.StrToInt(Eval("tmtype"))!=7)?"<div>参考答案："+Kesion.Exam.Function.GetCKDA(Utils.StrToInt(Eval("tmtype")),Convert.ToString(Eval("answer"))):"</div>"%>
		           <%# string.IsNullOrEmpty(Convert.ToString(Eval("dajs"))) ? "" : "答案解释：" + Utils.replaceBR(Convert.ToString(DataBinder.Eval(Container.DataItem, "dajs")))%>
			        </span>
			   
			       </td>
                  <td style="text-align:center" width="170">
		          <a href="javascript:;" onClick="editSt(<%# Eval("tmid") %>);">编辑</a> 
                    <a href="?action=delst&dtid=<%# Eval("dtId") %>&tmid=<%# Eval("tmid") %>" onClick="return confirm('您确定进行删除操作吗？')">删除</a> </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="height:40px;line-height:40px;text-align:center" colspan="4">
                  还没有添加任何试题!
                  
                </td>
               </tr> 
           </table>
          </FooterTemplate>
        </asp:Repeater>
<div style="margin:10px">
         <%if (KSCMS.S("action") == "modifyth")
           {%>
           <asp:Button ID="Button1" onclick="Button1_Click" Text="批量保存题号修改" runat="server" CssClass="button" />
          <%}
           else
           { %>
          <input type="button" class="button" value="批量修改大题题号" onclick="location.href='<%=KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4) %>/Exam/KS.SJRNDST.Aspx?action=modifyth&sjid=<%=sjId %>';" />
          <%} %>
          <input type="button" class="button" value="批量添加试题及答案" onclick="location.href='<%=KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4) %>/Exam/KS.SJAddST.Aspx?action=add&isrndsj=1&sjid=<%=sjId %>';" />
         </div>

                <asp:Panel ID="Panel1" runat="server" Height="30px" Width="100%">
                <br />
        <script type="text/javascript">
		showtips('<span class="state"><strong>操作说明：</strong><br /></span>在此页面您可以给试卷增加，修改或是删除试题。');
		</script>

            </asp:Panel>
</asp:Panel>

</div>
    

</asp:Content>
