<%@ Page Language="C#" enableEventValidation="false" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebExam.Admin.Exam.Admin_SJXTZJ" Title="试题库" Codebehind="KS.SJXTZJ.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
<style type="text/css">
		 .page a{margin:5px 4px 0 0; color:#2E2828;background:#fff; display:inline-table; border:1px solid #efefef; float:left; text-align:center;height:20px;line-height:20px;min-width:20px;}
        .page a.curr{color:brown;}
		.ta{color:#888;margin-bottom:20px;margin-top:10px;}
		.anstext{border:0px;border-bottom:1px solid #000;width:100px;padding-left:10px;}
		</style>  
   
 <asp:Panel ID="PanStep1" runat="server">
      <!--<KS:TopNav ID="TopNav1" runat="server" Text="选择分类并搜索试题" />-->
      <div class="clear blank20"></div>
      <div class="content-area">     
      	<div class="myTitle">手工选卷组题</div>  
        <script>
            var ClassID = 0;
            var key = '';
            var tmtype = '0';
            var TmZDYType = '0';
            var Difficulty = '';
            var KnowledgeId = '0';
            function check() {
                ClassID = jQuery("#<%=this.DrpClassID.ClientID %>").val();
                SJtypeClassId = jQuery("#<%=this.drpSJtypeClass.ClientID %>").val();
              
                Difficulty = jQuery("#<%=this.DrpDifficulty.ClientID%>").val();
                tmtype = '0';
                jQuery("input[name=TmType]:checked").each(function(n) {
                        if (n==0) {
                            tmtype = jQuery(this).val();
                        } else {
                            tmtype += ',' + jQuery(this).val();
                        }
                });

                TmZDYType = '0';
                jQuery("input[name=TmZDYType]:checked").each(function (n) {
                    if (n == 0) {
                        TmZDYType = jQuery(this).val();
                    } else {
                        TmZDYType += ',' + jQuery(this).val();
                    }
                });


                 jQuery("#<%=this.LstKnowledgeID.ClientID %> option:selected").each(function(n) {
                    if (n == 0) {
                        KnowledgeId = jQuery(this).val();
                    } else {
                        KnowledgeId += "," + jQuery(this).val();
                    }
                });
                show(1);
            }
            function show(p) {
                jQuery("#showresult").html('loading...');
                jQuery.get("KS.SJXTZJ.Aspx", { action: "getsearchsjtk", KnowledgeId: KnowledgeId, p: p, Difficulty: Difficulty, tmtype: tmtype, TmZDYType: TmZDYType, classid: ClassID, SJtypeClassId: SJtypeClassId }, function (v) {
                  jQuery('#showresult').html(unescape(v));
                  if (selids != '') {
                    var ss = "," + selids;
                    jQuery("input[name=selt]").each(function() {
                        if (ss.indexOf("," + jQuery(this).val()) != -1) {
                            jQuery(this)[0].checked = true;
                        }
                    });
                }
                });
            
               

            }
            var selids = '';
            function selectst(obj) {
                var v = obj.value;
                if (obj.checked) {
                    selids += ',' + v;
                } else {
                    selids = selids.replace("," + v, '');
                }
                seltips();
            }
            function seltips() {
                var num = (selids.split(",").length - 1);
                if (num > 0) {
                    //jQuery.dialog.tips('<div style="font-size:14px;padding-left:10px">已选择了 <font color=red>' + num + '</font> 题!</div><br/><input type="button" onclick="top.frames[\'main\'].location.href=\'exam/KS.SJXTZJ.Aspx?action=step2&ids=' + selids.substr(1, selids.length) + '\';" value="完成选题，创建试卷" class="button"/>', 300000000000, 'success.gif', function () { });
 jQuery.dialog.tips('<form name="myform" id="myform"  action="<%=KSCMS.GetInstallDir() + MyCache.GetCacheConfig(4)%>/Exam/KS.SJXTZJ.Aspx?action=step2" method="post" target="main"><input type="hidden" name="ids" value="'+selids.substr(1, selids.length)+'"/><div style="font-size:14px;padding-left:10px">已选择了 <font color=red>' + num + '</font> 题!</div><br/><input type="submit"  value="完成选题，创建试卷" class="button"/></form>', 300000000000, 'success.gif', function () { });


                } else {
                    jQuery.dialog.tips('没有选择试题!', 1, 'success.gif', function () { });
                }
            }
            function getKnowLedge(classid, SJtypeClassId) {
                classid = jQuery("#<%=this.DrpClassID.ClientID %>").val();
                jQuery.get("KS.SjAjax.ashx", { action: "getknowledge", showtm: 1, classid: classid, SJtypeClassId: SJtypeClassId }, function (v) {               
                jQuery("#<%=this.LstKnowledgeID.ClientID %>").empty().append(v);
            });
            KnowledgeId = '0';
            }
            function cancelSelectKnowledge() {
                jQuery("#<%=this.LstKnowledgeID.ClientID %> option:selected").each(function(n) {
                    jQuery(this).attr("selected", false);
                });
                KnowledgeId = '0';
            }
            function CheckInputBox(v) {
                if (v == 1) {
                    $("#showresult").find("input[type='checkbox']").attr("checked", true);
                    $("#showresult").find("input[type='checkbox']").each(function () {
                        selids += ',' + $(this).val();
                    });
                } else if (v == 2) {
                    $("#showresult").find("input[type='checkbox']").each(function () {
                        if ($(this).prop("checked") == true) {
                            $(this).attr("checked", false);
                            selids = selids.replace("," + $(this).val(), '');
                        } else {
                            $(this).attr("checked", true);
                            selids += ',' + $(this).val();
                        }
                    });
                } else {
                    $("#showresult").find("input[type='checkbox']").each(function () {
                        $(this).attr("checked", false);
                        selids = selids.replace("," + $(this).val(), '');
                    });
                }
                seltips();
            }

            function getKS(v) {
                jQuery.ajax({
                    url: "KS.SJ.aspx?action=select&theclassid=" + v, success: function (d) {
                  jQuery("#<%=this.drpSJtypeClass.ClientID %>").empty();
                  jQuery("#<%=this.drpSJtypeClass.ClientID %>").append(d);
              }
          });
      }


		</script>

        <table width="99%" align="center" border="0" cellpadding="1" cellspacing="1" class="CTable"> 
          <tbody id="searchform">
          <tr>
            <td class="lefttd" height="30" align="right"><b>题库分类：</b></td>
            <td class="righttd">
                &nbsp;<asp:DropDownList ID="DrpClassID" runat="server" onclick="getKS(this.value);">
             <asp:ListItem Value="0">--试题分类不限-</asp:ListItem>
             </asp:DropDownList> 
             <span class="tips">Tips：建议选择最后一级分类 </span>
            </td>
         </tr>

           <tr>
                     <td align="right" class="lefttd" height="30" style="width: 102px"><b>所属章节：</b></td>
                    <td class="righttd">
                        &nbsp;<asp:DropDownList ID="drpSJtypeClass" runat="server"  onclick="getKnowLedge(0,this.value);" >
                        <asp:ListItem Value="0">-选择题目属性-</asp:ListItem>
                        </asp:DropDownList>                                     
                       </td>
                </tr>         
          <tr style='display:<%=MyCache.GetSJCacheConfig(2)=="1"?"":"none"%>'>
            <td class="lefttd" height="30" align="right"><b>所属知识点：</b></td>
            <td class="righttd"> <asp:ListBox ID="LstKnowledgeID" SelectionMode="Multiple" Width="230px" Height="130px" runat="server">
                </asp:ListBox><br />
                <input type="button" value="取消选择" class="button" onclick="cancelSelectKnowledge();"/>
                <span class="tips">Tips：可以按Ctrl多选，也可以不选。</span>
            </td>
         </tr>
         
         
         <tr>
                <td align="right" class="lefttd" height="30">
                    <strong>题目难易：</strong></td>
                <td class="righttd">
                    &nbsp;<asp:DropDownList ID="DrpDifficulty" runat="server">
                    <asp:ListItem Value="-1">--不限--</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:Label ID="LabTmType" runat="server"></asp:Label>
                </td>
            </tr>
          <tr>
                <td align="right" class="lefttd" height="30" >
                    <strong>题目自定义类型：</strong></td>
                <td class="righttd">
                    &nbsp;<asp:Label ID="LabTmZDYType" runat="server"></asp:Label>
                </td>
            </tr>
            </tbody>
            <tr>
                <td align="right" class="lefttd" height="30" ></td>
                <td  class="righttd" height="30"  style="text-align:left">
                    <input type="button"  onclick='return(check())' value="搜索试题" class="button"/>
                    <input type="button"  onclick="jQuery('#searchform').toggle('fast')" value="显示/隐藏搜索框" class="button"/>


                     <span style="float:right">
                        <input type="button" class="button" value="全选" onclick="CheckInputBox(1)"/>
                        <input type="button" class="button" value="反选" onclick="CheckInputBox(2)"/>
                        <input type="button" class="button" value="不选" onclick="CheckInputBox(0)"/>
                      </span>
                </td>
            </tr>
        </table>
        
      

        <div id="showresult"></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>


<asp:Panel ID="PanStep2" runat="server" Visible="false">
        <KS:TopNav ID="TopNav2" runat="server" Text="第二步 选择试题组卷预览" />

<script type="text/javascript">
    function del(id) {
        if (confirm('确定删除该小题吗？')) {
           jQuery("#xt" + id).remove();
        }
    }
    function deldt(id) {
        if (confirm('确定删除整个大题吗?')) {
            jQuery("." + id).remove();
            /*
            var righttmtype = ',' + jQuery("#righttmtype").val();
            righttmtype = righttmtype.replace(',' + id, '').substr(1, righttmtype.length);
            jQuery("#righttmtype").val(righttmtype);

            jQuery("#dt" + id).empty().hide();
            jQuery("#dd" + id).empty().hide();
            */
        }
    }
    function check() {
        if (jQuery("#righttmtype").val() == '') {
            if (confirm('没有试题了，现在重新随机组卷吗?')) {
                location.reload();
            } else {
                return false;
            }
        }
        return true;
    }
			</script>
			<div style='padding:10px;text-align:center'>
			<input type='button' class='button' value=' 返回重新选题组卷 ' onclick='history.back(-1);'/>
                <asp:Button CssClass="button" ID="Button1" runat="server" 
                    OnClientClick="return(check());" Text=" 下一步：填写试卷信息并写入数据库 " 
                    onclick="Button1_Click" />
</div>
 <asp:Label ID="LabStep2" runat="server"></asp:Label>
 
 <script type="text/javascript">
     showtips('<span class="state"><strong>操作说明：</strong><br /></span>对于筛选出来的不需要的试题您可以点击删除掉;<br/>如果需要对选题组卷还想添加自己的题目，则您可以在组卷后在试卷管理里进行添加试题操作; ');
		</script>
 
</asp:Panel>
</div>
</asp:Content>
