<%@ Control Language="C#" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Course" %>
<%@ Import Namespace="Kesion.Components" %>
<script runat="server" type="text/C#">
	dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
	private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
	bool isLoadPage = true;  //定义页面是否加载
	public int tmId = 0;
	private int typeId = 0;
	private int classId = 0;
	private int rndId = 0;
	private int SJtypeClass = 0; //属性ID
	public static int tmtype = 0;
	public DataRow drp = null;
	public StringBuilder sb = new StringBuilder();
	public string TxtOrderID = "0";
	public string TxtTMFS = "0";
	protected void Page_Load(object sender, EventArgs e)
	{
		tmId = Utils.StrToInt(KSCMS.S("tmid"));
		typeId = Utils.StrToInt(KSCMS.S("typeid"));
		classId = Utils.StrToInt(KSCMS.S("classid"));
		rndId = Utils.StrToInt(KSCMS.S("rndid"));

		if (KSCMS.S("do") == "DelSubTM")
		{
			DelSubTM();
		}
		if (KSCMS.S("action").Equals("save"))
		{
			SaveChange();
		}
		TxtOrderID = Convert.ToString(Convert.ToInt16(DataFactory.GetOnlyValue("select max(orderid) from [KS_SJType]")) + 1);

			if (KSCMS.S("do").Equals("add") || KSCMS.S("from") == "tk")
			{
				initialAdd();
			}
			else
			{
				initialModify();
			}
		
	}
	protected void SaveChange()
	{
		float totalFS = 0;
		SJTKInfo __info = new SJTKInfo();
		__info.TmId = tmId;
        string appAnswer = string.Empty;
        string apptmnr = string.Empty;
        
		if (tmtype != 0 || KSCMS.S("from") == "tk") //分析题
		{
			if (KSCMS.S("from") == "tk")
			{
				__info.TmType = Utils.StrToInt(KSCMS.S("DrpTMType"));
			}
			else
			{
				__info.TmType = tmtype;
			}
			tmtype = __info.TmType;
			int xtnum = Utils.StrToInt(KSCMS.S("xtnum" + tmtype));
			if (tmtype == 6 || tmtype == 7) //阅读分析 操作题库副表
			{
				Hashtable ht = new Hashtable();
				for (int i = 1; i <= xtnum; i++)
				{
					if ((!string.IsNullOrEmpty(KSCMS.S("qus" + i)) && tmtype == 6) || (tmtype == 7 && (!string.IsNullOrEmpty(KSCMS.S("ans" + i + "11")) || !string.IsNullOrEmpty(KSCMS.S("tm" + i + "1")))))
					{
						int subTmid = Utils.StrToInt(KSCMS.S("tmid" + i));
						totalFS += Utils.StrToFloat(KSCMS.S("fs" + i));
						ht.Clear();
						if (tmtype == 6)
						{
							//ht.Add("tmnr", KSCMS.S("qus" + i));
							ht.Add("answer", KSCMS.S("ans" + i));
							ht.Add("tmtype", Utils.StrToInt(KSCMS.S("tmt" + i)));
							ht.Add("optionnum", Utils.StrToInt(KSCMS.S("optionnum" + i)));
							ht.Add("dajs", KSCMS.S("dajs" + i));
                            
                            #region APP考题部份
                            appAnswer = string.Empty;
                            apptmnr = string.Empty;
                            for (int j = 1; j <= Utils.StrToInt(KSCMS.S("optionnum" + i), 2); j++)
                            {

                                int asciiCode = 64;
                                System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                                byte[] byteArray = new byte[] { (byte)(asciiCode + j) };
                                string strCharacter = asciiEncoding.GetString(byteArray);

                                if (!string.IsNullOrEmpty(KSCMS.S("appans" + i + j)))
                                {
                                    apptmnr += strCharacter + "." + KSCMS.S("appans" + i + j) + "<br />";
                                    appAnswer += Utils.ChkSQL(KSCMS.S("appans" + i + j)) + "$$$$";
                                }
                            }

                            if (!string.IsNullOrEmpty(Utils.ClearHtml(KSCMS.S("qus" + i))))
                            {
                                ht.Add("tmnr", KSCMS.S("qus" + i));
                            }
                            else
                            {
                                ht.Add("tmnr", apptmnr);
                            }
                            ht.Add("appanswer", appAnswer);
                            #endregion
						}
						else
						{
							#region 分录题
							ht.Add("tmtype", 7);
							int numi = Utils.StrToInt(KSCMS.S("num" + i));
							if (Utils.StrToInt(KSCMS.S("isjst" + i)) == 1)
							{
								#region 分录题里的计算题
								string ans = string.Empty;
								string tm = string.Empty;
								for (int ii = 1; ii <= numi; ii++)
								{
									string tms = KSCMS.S("tm" + i + "" + ii);
									if (!string.IsNullOrEmpty(tms))
									{
										if (string.IsNullOrEmpty(tm))
										{
											tm = tms;
											ans = KSCMS.S("ans" + i + "" + ii);
										}
										else
										{
											tm += "§" + tms;
											ans += "§" + KSCMS.S("ans" + i + "" + ii);
										}
									}
								}
								ht.Add("tmnr", tm);
								ht.Add("answer", ans);
								#endregion
							}
							else
							{
								string ans = string.Empty;
								for (int ii = 1; ii <= numi; ii++)
								{
									string qans = KSCMS.S("ans" + i + "" + ii + "1");
									if (!string.IsNullOrEmpty(qans))
									{
										if (string.IsNullOrEmpty(ans))
										{
											ans = KSCMS.S("ans" + i + "" + ii + "1") + "№" + KSCMS.S("ans" + i + "" + ii + "2") + "№" + KSCMS.S("ans" + i + "" + ii + "3");
										}
										else
										{
											ans += "§" + KSCMS.S("ans" + i + "" + ii + "1") + "№" + KSCMS.S("ans" + i + "" + ii + "2") + "№" + KSCMS.S("ans" + i + "" + ii + "3");
										}
									}
								}
								ht.Add("tmnr", string.Empty);
								ht.Add("answer", ans);
							}
							#endregion
						}
						ht.Add("TMfs", Utils.StrToFloat(KSCMS.S("fs" + i)));
						ht.Add("parentTmID", tmId);

						if (subTmid == 0)
						{
							//增加小题
							ht.Add("orderid", i);
							CommonData.Insert("KS_SJTKSub", ht);
						}
						else
						{
							//编辑小题
							CommonData.Update("KS_SJTKSub", ht, "where tmid=" + subTmid);
						}
					}
				}
			}
			else
			{
				__info.TmType = Utils.StrToInt(KSCMS.S("DrpTMType"));
			}
		}
		else
		{
			__info.TmType = Utils.StrToInt(KSCMS.S("DrpTMType"));
		}

		__info.Difficulty = Utils.StrToInt(KSCMS.S("DrpDifficulty"));
		if (totalFS != 0)
		{
			__info.Tmfs = totalFS;
		}
		else
		{
			__info.Tmfs = Utils.StrToFloat(KSCMS.S("TxtTMFS"));
		}
		__info.IsRnd = Utils.StrToInt(KSCMS.S("ChkIsRnd"));
		__info.IsMedia =Utils.StrToInt(KSCMS.S("ChkIsMedia"));
		__info.MediaTxt = KSCMS.S("TxtMediaTxt");
		__info.MediaUrl = KSCMS.S("TxtMediaUrl");
		//__info.Title = KSCMS.S("TxtTitle");
        __info.Tmnr = KSCMS.S("TxtTmnr") + KSCMS.S("TxtTitle");
		__info.Answer = KSCMS.S("answer1");
		__info.KeyWords = KSCMS.S("keywords1");

		__info.OptionNum = Utils.StrToInt(KSCMS.S("optionnum1"), 2);
		__info.DaJS = KSCMS.S("TxtDAJS");
		__info.DajsMedia = KSCMS.S("TxtDAJSMedia");
		__info.OrderID = Utils.StrToInt(KSCMS.S("TxtOrderID"));
		__info.KnowledgeId = Utils.StrToInt(KSCMS.S("KnowledgeID"));

		__info.ClassId = Utils.StrToInt(KSCMS.S("DrpClassID"));

		__info.TypeId = typeId;

        #region APP考题部份
        if (tmtype != 6 || tmtype != 7)
        {
            // apptmnr = string.Empty;
            appAnswer = string.Empty;
            for (int i = 1; i <= Utils.StrToInt(KSCMS.S("optionnum1"), 2); i++)
            {
                int asciiCode = 64;
                System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                byte[] byteArray = new byte[] { (byte)(asciiCode + i) };
                string strCharacter = asciiEncoding.GetString(byteArray);

                if (!string.IsNullOrEmpty(KSCMS.S("appans1" + i)))
                {
                    // apptmnr += strCharacter + "." + KSCMS.S("appans1" + i) + "<br />";
                    appAnswer += Utils.ChkSQL(KSCMS.S("appans1" + i)) + "$$$$";
                }
            }
        }
        #endregion
        
        
		if (KSCMS.S("do").Equals("add") || KSCMS.S("from") == "tk")
		{
			if (SJManage.InsertSJTK(__info) == "success")
			{
				string stId = DataFactory.GetOnlyValue("select max(tmid) from KS_SJTK");
                DataFactory.ExecuteNonQuery("update ks_sjtk  set inputer='" + new TemporaryVar().UserName + "', userid=" + new TemporaryVar().UserID + ", SchoolID=" + new TemporaryVar().SchoolID + " where tmid=" + stId);

				#region 阅读分析题更新parentTmid
				DataFactory.ExecuteNonQuery("Update KS_SJTKSub Set parentTmid=" + stId + " Where parentTmid=0");
				#endregion

				#region 随机组卷的，做处理
				if (rndId != 0)
				{
					using (DataTable dt = DataFactory.GetDataTable("select top 1 * from KS_SJRndZJ where id=" + rndId))
					{
						if (dt.Rows.Count > 0)
						{
							string newTmIds = string.Empty;
							string tmIds = dt.Rows[0]["tmids"].ToString();
							if (string.IsNullOrEmpty(tmIds) || tmIds == "0")
							{
								newTmIds = stId;
							}
							else
							{
								newTmIds = tmIds + "," + stId;
							}
							DataFactory.ExecuteNonQuery("UpDate KS_SJRndZJ Set Tmids='" + newTmIds + "' Where ID=" + rndId);
						}
					}
				}
                DataFactory.ExecuteNonQuery("Update KS_SJTK Set SchoolID=" + new TemporaryVar().SchoolID + ", appanswer='" + appAnswer + "' Where tmid=" + Utils.StrToInt(stId));
				#endregion
				//string url=BasicField.GetUserUrl("sj/TcsjEditeST","from-" + KSCMS.S("from") + ",rndid-"+rndId+",typeid-" + typeId + "");
				Msg.AlertDoFun("试题添加成功！", "top.location.reload();");
				isLoadPage=false;
				return;
			}
		}
		else if (SJManage.ModifySJTK(__info, tmId) == "success")
		{
            DataFactory.ExecuteNonQuery("Update KS_SJTK Set appanswer='" + appAnswer + "' Where tmid=" + Utils.StrToInt(tmId));

			Msg.AlertDoFun("试题修改成功！", "top.location.reload();");
			isLoadPage = false;
			return;
		}
	}
	private void DelSubTM()
	{
		DataFactory.ExecuteNonQuery("Delete From KS_SJTKSub Where tmid=" + tmId);
		Msg.Alert("删除成功");
		isLoadPage = false;
		return;
	}
	private void initialAdd()
	{
		tmtype = 0;

		if (KSCMS.S("from") == "tk")   //从题库添加
		{
		}
		else  //为大题添加小题
		{
		
			if (rndId != 0)
			{
				using (DataTable dt = DataFactory.GetDataTable("select top 1 * from KS_SJRndZJ Where ID=" + rndId))
				{
					if (dt.Rows.Count > 0)
					{
						DataRow dr = dt.Rows[0];
						tmtype= Utils.StrToInt(dr["tmtype"].ToString());
						int maxOrderId = dr["tmids"].ToString().Split(',').Length + 1;
						TxtOrderID = maxOrderId.ToString();
					}
				}
			}
			else
			{
				using (DataTable dt = DataFactory.GetDataTable("select top 1 * From KS_SJTMType Where typeid=" + typeId))
				{
					if (dt.Rows.Count > 0)
					{
						DataRow dr = dt.Rows[0];
					tmtype=Utils.StrToInt(dr["tmtype"].ToString());
						int maxOrderId = Utils.StrToInt(DataFactory.GetOnlyValue("select max(orderid) FROM KS_SJTK Where TypeID=" + typeId)) + 1;
						TxtOrderID = maxOrderId.ToString();
					}
				}
			}
		}
		TxtTMFS = "1";
		//   this.ChkIsRnd.Checked = true;
	//	this.Button1.Text = "确定添加(0)";

	}
	private void initialModify()
	{
		using (DataTable dt = DataFactory.GetDataTable("Select top 1 * From KS_SJTK Where TmId=" + tmId))
		{
			if (dt.Rows.Count > 0)
			{
				drp = dt.Rows[0];
				TxtOrderID = drp["orderid"].ToString();
				TxtTMFS = drp["TMFS"].ToString();
                classId =Utils.StrToInt( drp["classid"].ToString());
				tmtype = Utils.StrToInt(drp["tmtype"].ToString());
			}
		}
	}
    private static string getAnswer(int tmtype, int optionnum, string answer, string keywords, string appContent)
	{
		answer = answer.Trim();
		string str = string.Empty;  
        string style = " style='width:480px;height:80px' ";
       
        appContent = string.Concat(appContent, "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
        string[] appanswer = System.Text.RegularExpressions.Regex.Split(appContent, @"[$]{4}");
        
		StringBuilder sb = new StringBuilder();
		switch (tmtype)
		{
			case 1:
				str = string.Format(@"<strong>参考答案：</strong><br/><textarea ID='answer1' name='answer1' cols='60' style=""height:120px;width:100%"" rows='3'>{0}</textarea>
                    <br/><strong>关键字：</strong><br/><textarea name=""keywords1"" cols='60' rows='3'>{1}</textarea><br/>Tips:主观题将根据设置的关键词估分
                     ", answer, keywords);
				str += Kesion.APPCode.EditorAPI.EchoEditor("editoranswer1", "answer1", "Basic", 0, false, false, false, false, true);
				break;
			case 2:
				sb.Append("选项个数：<select onchange='showansweroption(this.value);' name='optionnum1'>");
				sb.AppendFormat(@"<option value='2'{0}>2个</option>", (optionnum == 2 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='3'{0}>3个</option>", (optionnum == 3 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='4'{0}>4个</option>", (optionnum == 4 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='5'{0}>5个</option>", (optionnum == 5 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='6'{0}>6个</option>", (optionnum == 6 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='7'{0}>7个</option>", (optionnum == 7 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='8'{0}>8个</option>", (optionnum == 8 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='9'{0}>9个</option>", (optionnum == 9 ? " selected" : string.Empty));
				sb.Append("</select><br/>");
				 sb.AppendFormat(@" <label id='l11'><input type='radio' value='A' name='answer1'{0}/>(A)</label>", answer.ToLower() == "a" ? " checked" : string.Empty);
                    sb.AppendFormat(@"<span id='a111' ><textarea  {1}  name='appans11'>{0} </textarea><br /></spans>", appanswer[0], style);
                    sb.AppendFormat(@"<label id='l12'><input type='radio' value='B' name='answer1'{0}/>(B)</label>", answer.ToLower() == "b" ? " checked" : string.Empty);
                    sb.AppendFormat(@"<span id='a112'> <textarea  {1}   name='appans12'>{0} </textarea><br /> </span>", appanswer[1], style);
                    sb.AppendFormat(@"<label id='l13'{1}><input type='radio' value='C' name='answer1'{0}/>(C)</label>", answer.ToLower() == "c" ? " checked" : string.Empty, optionnum < 3 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a113' {2}> <textarea  {1}  name='appans13'>{0} </textarea><br /></span>", appanswer[2], style, optionnum < 3 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l14'{1}><input type='radio' value='D' name='answer1'{0}/>(D)</label>", answer.ToLower() == "d" ? " checked" : string.Empty, optionnum < 4 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a114' {2}> <textarea  {1}  name='appans14'>{0} </textarea><br /></span>", appanswer[3], style, optionnum < 4 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l15'{1}><input type='radio' value='E' name='answer1'{0}/>(E)</label>", answer.ToLower() == "e" ? " checked" : string.Empty, optionnum < 5 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a115' {2}> <textarea  {1}  name='appans15'>{0} </textarea><br /></span>", appanswer[4], style, optionnum < 5 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l16'{1}><input type='radio' value='F' name='answer1'{0}/>(F)</label></span>", answer.ToLower() == "f" ? " checked" : string.Empty, optionnum < 6 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a116' {2}> <textarea  {1}  name='appans16'>{0} </textarea><br /></span>", appanswer[5], style, optionnum < 6 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l17'{1}><input type='radio' value='G' name='answer1'{0}/>(G)</label>", answer.ToLower() == "g" ? " checked" : string.Empty, optionnum < 7 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a117' {2}> <textarea  {1}  name='appans17'>{0} </textarea><br /></span>", appanswer[6], style, optionnum < 7 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l18'{1}><input type='radio' value='H' name='answer1'{0}/>(H)</label>", answer.ToLower() == "h" ? " checked" : string.Empty, optionnum < 8 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a118' {2}> <textarea  {1}  name='appans18'>{0} </textarea><br /></span>", appanswer[7], style, optionnum < 8 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l19'{1}><input type='radio' value='I' name='answer1'{0}/>(I)</label>", answer.ToLower() == "i" ? " checked" : string.Empty, optionnum < 9 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a119' {2}> <textarea  {1}  name='appans19'>{0} </textarea><br /></span>", appanswer[8], style, optionnum < 9 ? " style='display:none'" : string.Empty);
                   str = sb.ToString();
				break;
			case 3:
				sb.Append("选项个数：<select onchange='showansweroption(this.value);' name='optionnum1'>");
				sb.AppendFormat(@"<option value='2'{0}>2个</option>", (optionnum == 2 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='3'{0}>3个</option>", (optionnum == 3 ? " selectedd" : string.Empty));
				sb.AppendFormat(@"<option value='4'{0}>4个</option>", (optionnum == 4 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='5'{0}>5个</option>", (optionnum == 5 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='6'{0}>6个</option>", (optionnum == 6 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='7'{0}>7个</option>", (optionnum == 7 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='8'{0}>8个</option>", (optionnum == 8 ? " selected" : string.Empty));
				sb.AppendFormat(@"<option value='9'{0}>9个</option>", (optionnum == 9 ? " selected" : string.Empty));
				sb.Append("</select><br/>");
				 sb.AppendFormat(@"<label><input type='checkbox' value='A' name='answer1'{0}/>(A)</label>", answer.ToLower().IndexOf('a') != -1 ? " checked" : string.Empty);
                    sb.AppendFormat(@"<textarea  {1}  name='appans11'>{0} </textarea><br />", appanswer[0], style);
                    sb.AppendFormat(@"<label id='l12'><input type='checkbox' value='B' name='answer1'{0}/>(B)</label>", answer.ToLower().IndexOf('b') != -1 ? " checked" : string.Empty);
                    sb.AppendFormat(@"<textarea  {1}  name='appans12'>{0} </textarea><br />", appanswer[1], style);
                    sb.AppendFormat(@"<label id='l13'{1}><input type='checkbox' value='C' name='answer1'{0}/>(C)</label>", answer.ToLower().IndexOf('c') != -1 ? " checked" : string.Empty, optionnum < 3 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a113' {2}> <textarea  {1}  name='appans13'>{0} </textarea><br /></span>", appanswer[2], style, optionnum < 3 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<label id='l14'{1}><input type='checkbox' value='D' name='answer1'{0}/>(D)</label>", answer.ToLower().IndexOf('d') != -1 ? " checked" : string.Empty, optionnum < 4 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a114' {2}><textarea  {1}  name='appans14'>{0} </textarea><br /></span>", appanswer[3], style, optionnum < 4 ? " style='display:none'" : string.Empty);                  
                    sb.AppendFormat(@"<label id='l15'{1}><input type='checkbox' value='E' name='answer1'{0}/>(E)</label>", answer.ToLower().IndexOf('e') != -1 ? " checked" : string.Empty, optionnum < 5 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a115' {2}><textarea  {1}  name='appans15'>{0} </textarea><br /></span>", appanswer[4], style, optionnum < 5 ? " style='display:none'" : string.Empty);  
                    sb.AppendFormat(@"<label id='l16'{1}><input type='checkbox' value='F' name='answer1'{0}/>(F)</label>", answer.ToLower().IndexOf('f') != -1 ? " checked" : string.Empty, optionnum < 6 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a116' {2}><textarea  {1}  name='appans16'>{0} </textarea><br /></span>", appanswer[5], style, optionnum < 6 ? " style='display:none'" : string.Empty);  
                    sb.AppendFormat(@"<label id='l17'{1}><input type='checkbox' value='G' name='answer1'{0}/>(G)</label>", answer.ToLower().IndexOf('g') != -1 ? " checked" : string.Empty, optionnum < 7 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a117' {2}><textarea  {1}  name='appans17'>{0} </textarea><br /></span>", appanswer[6], style, optionnum < 7 ? " style='display:none'" : string.Empty);  
                    sb.AppendFormat(@"<label id='l18'{1}><input type='checkbox' value='H' name='answer1'{0}/>(H)</label>", answer.ToLower().IndexOf('h') != -1 ? " checked" : string.Empty, optionnum < 8 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a118' {2}><textarea  {1}  name='appans18'>{0} </textarea><br /></span>", appanswer[7], style, optionnum < 8 ? " style='display:none'" : string.Empty);  
                    sb.AppendFormat(@"<label id='l19'{1}><input type='checkbox' value='I' name='answer1'{0}/>(I)</label>", answer.ToLower().IndexOf('i') != -1 ? " checked" : string.Empty, optionnum < 9 ? " style='display:none'" : string.Empty);
                    sb.AppendFormat(@"<span id='a119' {2}><textarea  {1}  name='appans19'>{0} </textarea><br /></span>", appanswer[8], style, optionnum < 9 ? " style='display:none'" : string.Empty);  
                    str = sb.ToString();
				break;
			case 4:
                   sb.AppendFormat(@"<label><input type='radio' value='1' name='answer1'{0}/>正确</label>", answer == "1" ? " checked" : string.Empty);
                   //  sb.AppendFormat(@"<textarea  {1}  name='appans1'>{0} </textarea><br />", appanswer[0], style);
                     sb.AppendFormat(@"<label><input type='radio' value='0' name='answer1'{1}/>错误</label>", answer == "1" ? " checked" : string.Empty, answer == "0" ? " checked" : string.Empty);
                   //  sb.AppendFormat(@"<textarea  {1}  name='appans2'>{0} </textarea><br />", appanswer[1], style);
                    str = sb.ToString();
             
			//	str = string.Format(@"<label><input type='radio' value='1' name='answer1'{0}/>正确</label>&nbsp;<label><input type='radio' value='0' name='answer1'{1}/>错误</label>", answer == "1" ? " checked" : string.Empty, answer == "0" ? " checked" : string.Empty);
				break;
			case 5:
				str = string.Format(@"<textarea ID='answer1' name='answer1' cols='60' rows='3'>{0}</textarea><br/>Tips：填空题如果有多个空格，各个空格的参考答案之间用※隔开,一个空有多个答案的，再用|线隔开。
<br/>如1|2※2※3
<br/>表示有三个空格，第一个空格的答案可以是1或是2,第二个空格的答案是2,第三个空格的答案是3 ", answer);

				break;
		}
		return str;
	}
	public string GetParam(string Fields)
	{
		string result = string.Empty;
		if (drp != null)
		{
			result = drp[Fields].ToString();
		}
		return result;
	}
</script>
<%
    if (!isLoadPage) return;
	Kesion.APPCode.EditorAPI.EchoHead();
%>
  <div id="manage_top" class="toptitle menu_top_fixed shid" ><%=(KSCMS.S("do").Equals("add")?"添加试题":"修改试题") %> </div><div class="menu_top_fixed_height"></div> 
    <script>
    	function checkform() {
    		if (editorTxtTmnr.hasContents() == false) {
    		    KesionJS.Alert('题内容两者必填一项!', 'jQuery("#TxtTmnr").focus();');
    			return false;
    		}
    		var tmType = jQuery("#DrpTMType option:selected").val();

    		if (tmType == '0') {
    			KesionJS.Alert('请选择试题类型!', '');
    			return false;
    		}
    		if (tmType == '6') {
    			if (i < 1) {
    				KesionJS.Alert('请添加小题!', '');
    				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;
    			}
    		}
    		    var tnum = 1;

    		    for (var i = 1; i <= tnum; i++) {
    		   
    		        var tmtype = jQuery("#tmtype" + i).val();

    		        if (tmtype == 2 || tmtype == 3) {
    		            var opnet = jQuery("#optionnum" + i).val();
    		            var latter = '';
    		            for (var j = 1; j <= opnet; j++) {
    		                if (jQuery("#appans" + i + j).val() == '' || jQuery("#appans" + i + j).val() == undefined) {
    		                    alert("第" + i + "题答案内容不能为空");
    		                    jQuery("#appans" + i + j).focus();
    		                    return false;
    		                }

    		            }
    		            if ($("input[name='answer" + i + "']:checked").val() == '' || $("input[name='answer" + i + "']:checked").val() == undefined) {
    		                alert("第" + i + "题标准答必须选择!");
    		                return false;
    		            }
    		        }

    		    }


    	

    		return true;
    	}
    	function showmedia() {
    		if (jQuery("#ChkIsMedia")[0].checked) {
    			jQuery("#media").show();
    		} else {
    			jQuery("#media").hide();
    		}
    	}
    	function showansweroption(v) {
    		for (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 (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();
    			addTM();
    			addTM();
    		} else if (v == 7) {
    			jQuery("#tm7").show();
    			jQuery("#tm6").hide();
    			jQuery("#commomtm").hide();
    			addFLTM();
    			addFLTM();
    		} else {
    			jQuery("#tm6").hide();
    			jQuery("#tm7").hide();
    			jQuery("#commomtm").show();
    			jQuery.get("/plus/exam/TcSjAjax.ashx", { action: "getanswer", "rnd": Math.random(), tmtype: v }, function (v) {
    				jQuery('#showanswer').html(unescape(v));
    			});
    		
    		}
    	}
    	var isKnowledge = 0;
    	function loadKnowledge() {
    		var classid = 0;
    		if (jQuery("#DrpClassID")[0] != undefined) {
    			classid = jQuery("#DrpClassID option:selected").val();
    		} else {
    			classid = jQuery("#HidClassID").val();
    		}
    		if (classid == '' || classid == 0) {
    			alert('请选择栏目试题分类!');
    			return false;
    		}
    		showKnowledge(classid);
    		isKnowledge = 1;
    		jQuery("#KnowledgeBtn").hide();
    	}
    	function changeKnowledge(classid) {
    		if (isKnowledge == 1) {
    			showKnowledge(classid);
    		}
    	}
    	function showKnowledge(classid) {
    		var str = '<select name="KnowledgeID" id="KnowledgeID"><option value="0">===选择知识点===</option></select>';
    		jQuery("#showKnowledge").html(str);
    		jQuery.get("TcSjAjax.ashx", { action: "getknowledge", classid: classid }, function (v) {
    			jQuery("#KnowledgeID").append(v);
    		});
    	}
    	jQuery(function () {
			<%if(KSCMS.S("do").Equals("add")){%>
    		settmtype(jQuery("#DrpTMType option:selected").val());
			<%}%>
    	});
    </script>
    <style>
    	table.examTable tr td{ white-space:normal !important;}
    </style>
	<div class="blank10"></div>
	 <form name="myform" action="<%=BasicField.GetUserUrl("SJ/TcSjEditeSt","do-"+KSCMS.S("do")) %>" method="post" id="myform" >
	 <input type="hidden" value="save" name="action" />
	 <input type="hidden" value="<%=KSCMS.S("tmid")%>" name="tmid" />
	 <input type="hidden" value="<%=KSCMS.S("typeId")%>" name="typeId" />
     <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="border examTable" style="table-layout:fixed"> 
         <tbody id="classidarea" style="display:<%=KSCMS.S("from").Equals("tk")?"":"none1"%>">
              <tr>
                <td class="lefttd" height="30" align="right" >试题分类：</td>
                <td class="tag_left">
                    &nbsp;<select name="DrpClassID" id="DrpClassID" onchange="changeKnowledge(this.value);">
                                <option value="0">-选择试题分类-</option>
                                    <%
                                   string str=Teacher.getExamClassList(classId.ToString());
                               
                                    KSCMS.W(str);
                                      
                                 %>
                          </select>
                            Tips:试题分类建议选择最终级分类。
                   </td>
            </tr>
         </tbody>
          <tr>
            <td class="lefttd" height="30" align="right" width="150">题目类型：</td>
            <td class="tag_left">
                <select name="DrpTMType" id="DrpTMType" onchange="settmtype(this.value);">
                    <option value="0">-选择题目类型-</option>
                	<%
                    sb.Clear();
                    int i = 1;
                    foreach (string s in Kesion.Exam.Function.TMTypeArr)
                    {
                        string selected = "";
                        if (tmtype.ToString() == i.ToString())
                        {
                            selected = "selected";
                        }
                        sb.AppendFormat("<option value=\"{0}\" {2}>{1}</option>", i.ToString(), s, selected);
                            
                        i++;
                    }
                    KSCMS.W(sb.ToString());
                  	%>
            
                </select>
                题目难度：
                <select name="DrpDifficulty" id="DrpDifficulty">
                <%
                    sb.Clear(); 
					 i = 0;
					foreach (string s in Kesion.Exam.Function.DifficultyArr)
					{
				
						string selected = "";
						if (GetParam("difficulty").ToString() == i.ToString())
						{
							selected = "selected";
						}
						sb.AppendFormat("<option value=\"{0}\" {2}>{1}</option>", i.ToString(), s, selected);
				
						i++;
					
					}
					KSCMS.W(sb.ToString());
                %>
                </select>
                分值：<input name="TxtTMFS" type="text" value="<%=TxtTMFS %>" id="TxtTMFS" class="textbox" style="width:30px;text-align:center; padding-left:0;" />
				<span class="checkbox_box"><input id="ChkIsRnd" type="checkbox" <%=GetParam("isrnd")=="1"?"Checked":"" %> name="ChkIsRnd" /><label for="ChkIsRnd">随机题</label></span>
                <span class="checkbox_box"><input id="ChkIsMedia" type="checkbox" <%=GetParam("ismedia")=="1"?"Checked":"" %> name="ChkIsMedia" onclick="showmedia();" /><label for="ChkIsMedia">听力题</label></span>
               </td>
        </tr>
        <tbody id="media" style="display:none">
            <tr>
                <td align="right" class="lefttd" height="30" >
                    音频地址：</td>
                <td class="tag_left">
                    <input name="TxtMediaUrl" type="text" value="<%=GetParam("mediaurl") %>" id="TxtMediaUrl" class="textbox" />
                    <div class="blank10"></div>
                    <%=Kesion.APPCode.UploadAPI.EchoUpload("courseUserFile","TxtMediaUrl") %></td>
            </tr>
            <tr>
                <td align="tag_left" class="lefttd" height="30" >
                    听力原文：</td>
                <td class="righttd"><textarea name="TxtMediaTxt" rows="2" cols="20" id="TxtMediaTxt" style="height:120px;width:100%"><%=GetParam("mediatxt") %></textarea>
                      <%Kesion.APPCode.EditorAPI.EchoEditor("editorTxtMediaTxt", "TxtMediaTxt", "Basic"); %> 
                   </td>
            </tr>
        </tbody>
        <tr>
            <td align="right" class="lefttd" height="30">
                题目内容：<br>
				<font color=red>
				如选择题填写具体的选项,填空题在需要用户作答的地方放{#answer}标签,使用编辑器时按shift+Enter分段</font></td>
            <td class="tag_left">
                <textarea name="TxtTmnr" rows="2" cols="20" id="TxtTmnr" style="height:120px;width:100%"><%=Utils.replaceBR(GetParam("tmnr"))+(GetParam("title")) %> </textarea>
                  <% Kesion.APPCode.EditorAPI.EchoEditor("editorTxtTmnr", "TxtTmnr", "Basic", 0, false, true, true, false);%> 
			</td>
        </tr>

        <tr id="tm6"<%=(tmtype==6)?"":" style='display:none'" %>>
            <td align="right" class="lefttd" height="30" >
             	小题目：
              	<br /><br /> 
              	<input type="button" class="button" value="增加小题" onclick="addTM()"/></td>
            	<td class="tag_left">
                      <table width='100%'>
                     <tbody id='xts'>
               <%

              StringBuilder sb6 = new StringBuilder();
              int ii = 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)
                          {

                              ii++;
                              int xttype = Utils.StrToInt(dr["tmtype"].ToString());
                              sb6.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}'/>", ii, dr["tmnr"].ToString(), dr["tmid"].ToString()));

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

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

                              sb6.AppendLine(@"<span id='sa" + ii + "'>");

                              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:
                                      sb6.AppendLine(@"选项个数：<select onchange='showansweroption1(this.value,"+xttype+","+ii+");' name='optionnum"+ii+"' id='optionnum"+ii+"'>");
                                      for (int nn=2;nn<=9;nn++){
                                         sb6.Append("<option value='"+nn+"'");
                                           if (defaultoptionnum==nn) sb6.Append(" selected");
                                           sb6.Append(">"+nn+"个</option>");
                                       }
                                      sb6.Append("</select><br >");
                                      
                                      sb6.AppendLine(string.Format(@"<input type='radio' name='ans{0}' value='A'{1}/>A", ii, answer == "A" ? " checked" : string.Empty));
                                      sb6.AppendFormat(@"<textarea  {1}  name='appans"+ii+"1'>{0} </textarea><br />", appanswer[0], style);
                                      sb6.AppendLine(string.Format(@"<input type='radio' name='ans{0}' value='B'{1}/>B", ii, answer == "B" ? " checked" : string.Empty));
                                      sb6.AppendFormat(@"<textarea  {1}  name='appans" + ii + "2'>{0} </textarea><br /></span>", appanswer[1], style);
                                      sb6.Append("<label id='l2"+ii+"3'");
                                      if (defaultoptionnum<3) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='C'{1}/>C</label>", ii, answer == "C" ? " checked" : string.Empty));
                                      sb6.Append("<span id='a12" + ii + "3'");
                                      if (defaultoptionnum < 3) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "3'>{0} </textarea><br /></span>", appanswer[2], style);
                                      sb6.Append("<label id='l2"+ii+"4'");
                                      if (defaultoptionnum<4) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='D'{1}/>D</label>", ii, answer == "D" ? " checked" : string.Empty));
                                      sb6.Append("<span id='a12" + ii + "4'");
                                      if (defaultoptionnum < 4) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "4'>{0} </textarea><br /></span>", appanswer[3], style);
                                                                       
                                      sb6.Append("<label id='l2"+ii+"5'");
                                      if (defaultoptionnum<5) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='E'{1}/>E</label>", ii, answer == "E" ? " checked" : string.Empty));
                                        sb6.Append("<span id='a12" + ii + "5'");
                                      if (defaultoptionnum < 5) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "5'>{0} </textarea><br /></span>", appanswer[4], style);
                                                                           
                                                                           
                                      sb6.Append("<label id='l2"+ii+"6'");
                                      if (defaultoptionnum<6) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='F'{1}/>F</label>", ii, answer == "F" ? " checked" : string.Empty));
                                      sb6.Append("<span id='a12" + ii + "6'");
                                      if (defaultoptionnum < 6) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + i + "6'>{0} </textarea><br /></span>", appanswer[5], style);
                                                                           
                                      sb6.Append("<label id='l2"+ii+"7'");
                                      if (defaultoptionnum<7) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='G'{1}/>G</label>", ii, answer == "G" ? " checked" : string.Empty));
                                         sb6.Append("<span id='a12" + ii + "7'");
                                      if (defaultoptionnum < 7) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "7'>{0} </textarea><br /></span>", appanswer[6], style);
                                       
                                      
                                      sb6.Append("<label id='l2"+ii+"8'");
                                      if (defaultoptionnum<8) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='H'{1}/>H</label>", ii, answer == "H" ? " checked" : string.Empty));
                                        sb6.Append("<span id='a12" + ii + "8'");
                                      if (defaultoptionnum < 8) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "8'>{0} </textarea><br /></span>", appanswer[7], style);
                                       
                                      
                                      sb6.Append("<label id='l2"+ii+"9'");
                                      if (defaultoptionnum<9) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='radio' name='ans{0}' value='I'{1}/>I</label>", ii, answer == "I" ? " checked" : string.Empty));
                                      sb6.Append("<span id='a12" + ii + "9'");
                                      if (defaultoptionnum < 9) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "9'>{0} </textarea><br /></span>", appanswer[8], style);
                                       
                                      break;
                                  case 3:
                                      sb6.AppendLine(@"选项个数：<select onchange='showansweroption1(this.value,"+xttype+","+ii+");' name='optionnum"+ii+"' id='optionnum"+ii+"'>");
                                      for (int nn=2;nn<=9;nn++){
                                         sb6.Append("<option value='"+nn+"'");
                                           if (defaultoptionnum==nn) sb6.Append(" selected");
                                           sb6.Append(">"+nn+"个</option>");
                                       }
                                      sb6.Append("</select> <br >");
                                      sb6.AppendLine(string.Format(@"<input type='checkbox' name='ans{0}' value='A'{1}/>A", ii, answer.IndexOf("A") != -1 ? " checked" : string.Empty));
                                      sb6.AppendFormat(@"<textarea  {1}  name='appans" + ii + "1'>{0} </textarea><br />", appanswer[0], style);
                                      sb6.AppendLine(string.Format(@"<input type='checkbox' name='ans{0}' value='B'{1}/>B", ii, answer.IndexOf("B") != -1 ? " checked" : string.Empty));
                                      sb6.AppendFormat(@"<textarea  {1}  name='appans" + ii + "2'>{0} </textarea><br />", appanswer[1], style);
                                      sb6.Append("<label id='l3"+ii+"3'");
                                      if (defaultoptionnum<3) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='C'{1}/>C</label>", ii, answer.IndexOf("C") != -1 ? " checked" : string.Empty));
                                        sb6.Append("<span id='a13"+ii+"3'");
                                      if (defaultoptionnum<3) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "3'>{0} </textarea><br /></span>", appanswer[2], style);
                                      
                                      sb6.Append("<label id='l3"+ii+"4'");
                                      if (defaultoptionnum<4) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='D'{1}/>D</label>", ii, answer.IndexOf("D") != -1 ? " checked" : string.Empty));
                                        sb6.Append("<span id='a13"+ii+"4'");
                                      if (defaultoptionnum<4) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "4'>{0} </textarea><br /></span>", appanswer[3], style);
                                      
                                      sb6.Append("<label id='l3"+ii+"5'");
                                      if (defaultoptionnum<5) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='E'{1}/>E</label>", ii, answer.IndexOf("E") != -1 ? " checked" : string.Empty));
                                        sb6.Append("<span id='a13"+ii+"5'");
                                      if (defaultoptionnum<5) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "5'>{0} </textarea><br /></span>", appanswer[4], style);
                                      
                                      sb6.Append("<label id='l3"+ii+"6'");
                                      if (defaultoptionnum<6) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='F'{1}/>F</label>", ii, answer.IndexOf("F") != -1 ? " checked" : string.Empty));
                                        sb6.Append("<span id='a13"+ii+"3'");
                                      if (defaultoptionnum<6) sb.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "6'>{0} </textarea><br /></span>", appanswer[5], style);
                                      
                                      sb6.Append("<label id='l3"+ii+"7'");
                                      if (defaultoptionnum<7) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='G'{1}/>G</label>", ii, answer.IndexOf("G") != -1 ? " checked" : string.Empty));
                                        sb6.Append("<span id='a13"+ii+"7'");
                                      if (defaultoptionnum<7) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "7'>{0} </textarea><br /></span>", appanswer[6], style);
                                    
                                      sb6.Append("<label id='l3"+ii+"8'");
                                      if (defaultoptionnum<8) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='H'{1}/>H</label>",ii, answer.IndexOf("H") != -1 ? " checked" : string.Empty));
                                       sb6.Append("<span id='a13"+ii+"8'");
                                      if (defaultoptionnum<3) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "8'>{0} </textarea><br /></span>", appanswer[7], style);
                                      
                                      sb6.Append("<label id='l3"+ii+"9'");
                                      if (defaultoptionnum<9) sb6.Append(" style='display:none'");
                                      sb6.AppendLine(string.Format(@"><input type='checkbox' name='ans{0}' value='I'{1}/>I</label>", ii, answer.IndexOf("I") != -1 ? " checked" : string.Empty));
                                      sb6.Append("<span id='a13"+ii+"9'");
                                      if (defaultoptionnum<9) sb6.Append(" style='display:none'");
                                      sb6.AppendFormat(@"><textarea  {1}  name='appans" + ii + "9'>{0} </textarea><br /></span>", appanswer[8], style);
                                      break;
                                  case 4:
                                      sb6.AppendLine(string.Format(@"<input type='radio' name='ans{0}' value='1'{1}/>对", ii, answer == "1" ? " checked" : string.Empty));
                                      sb6.AppendLine(string.Format(@"<input type='radio' name='ans{0}' value='0'{1}/>错", ii, answer == "0" ? " checked" : string.Empty));
                                      break;
                                  case 5:
                                      sb6.AppendLine(string.Format(@"<input type='text' name='ans{0}' value='{1}' class='textbox'/>", ii, answer));
                                      break;
                                  case 1:
                                      sb6.AppendLine(string.Format(@"<textarea name='ans{0}' id='ans{0}' style='width:480px;height:80px'>{1}</textarea>", ii, answer));
                                      sb6.Append(Kesion.APPCode.EditorAPI.EchoEditor("editorans" + ii, "ans" + ii, "Basic", 0, false, false, false, false,true));    
                                      break;
                              }

                              sb6.AppendLine("</span>");
                              sb6.AppendLine(@"<br/><span id='ztkoufs" + ii + "'>");
                              switch (xttype)
                              {
                                  case 3:
                                      sb6.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>", ii, dr["KouFS"].ToString()));
                                      break;
                                  case 4:
                                      sb6.AppendLine(string.Format(@"&nbsp;&nbsp;答错扣:<input type='text' id='ztpdtkoufs{0}' name='ztpdtkoufs{0}' class='textbox' value='{1}' style='text-align:center;width:30px'/>分 ", ii, dr["KouFS"].ToString()));
                                      sb6.AppendLine(string.Format(@"&nbsp;不答是否扣分:<input type='radio' name='iskoufs{0}' value='0'{1}/>否", ii, Utils.StrToInt(dr["IsKouFS"].ToString()) ==0? " checked" : string.Empty));
                                      sb6.AppendLine(string.Format(@"<input type='radio' name='iskoufs{0}' value='1'{1}/>是", ii, Utils.StrToInt(dr["IsKouFS"].ToString()) ==1 ? " checked" : string.Empty));
                                      break;
                              }
                              sb6.AppendLine("</span>");
                              
                              sb6.AppendLine("<br/>答案解释：<br/><textarea  style='width:480px;height:80px' name='dajs" + ii + "' id='dajs" + ii + "'/>"+dr["DAJS"].ToString()+"</textarea>");
                              sb6.Append(Kesion.APPCode.EditorAPI.EchoEditor("editordajs" + ii, "dajs" + ii, "Basic", 0, false, false, false, false,true));    


                              sb6.AppendLine("</td><td align='left'>分数:<input type='text' name='fs" + ii + "' class='textbox' value='" + dr["TMfs"].ToString() + "' style='text-align:center;width:30px'/>分</td><td style='text-align:center'><a href='javascript:;' onclick='removeTr(" + ii + "," + dr["tmid"].ToString() + ");return false;'>删</a></td></tr>");
                              sb6.AppendLine("<tr><td colspan=10 style='height:1px;border-bottom:1px solid #999'></td></tr>");
                          }
                      }
                  }
                  Response.Write(sb6.ToString());
              }
         %>    <tbody>
             </table>
                <input type="hidden" name="xtnum6" id="xtnum6" value="<%=ii%>" />
                <script>
                	function replaceEditor(id) {
                		editor1 = UE.getEditor(id, { toolbars: [['fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', '|', 'insertimage', 'wordimage', 'emotion']], initialFrameWidth: 580, initialFrameHeight: 80, wordCount: false, autoHeightEnabled: false, minFrameHeight: 80, elementPathEnabled: false });
                	}
                	function setAns(v, i) {
                		jQuery("#sa" + i).html(GetAns(v, i));
                		if (v == 1) {
                			replaceEditor('ans' + i);
                		}
                	}
                	var i = 0;
                	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 + "'>" + GetAns(xttype, i) + "</span>";
                		str += "<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='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);
                	}
                	function removeTr(i, tmid) {
                		if (tmid == 0) {
                			jQuery("#t" + i).remove();
                		} else {
                			jQuery.ajax({
                				type: "POST",
                				url: "TcSjEditeST.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>"
                	            str += "<br ><input type='radio' name='ans" + i + "' value='A'/>A";
                	            str += "<textarea  name='appans" + i + "1'  style='width:480px;height:80px'></textarea><br >";
                	            str += "<input type='radio' name='ans" + i + "' value='B'/>B";
                	            str += "<textarea  name='appans" + i + "2'  style='width:480px;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'  style='width:480px;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'  style='width:480px;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'  style='width:480px;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'  style='width:480px;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'  style='width:480px;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'  style='width:480px;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'  style='width:480px;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'  style='width:480px;height:80px'></textarea><br >";
                	            str += "<input type='checkbox' name='ans" + i + "' value='B'/>B";
                	            str += "<textarea  name='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'  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'  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'  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'  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'  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'  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'  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;
                	}

                	function GetAns00(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>"

                				str += "<input type='radio' name='ans" + i + "' value='A'/>A";
                				str += "<input type='radio' name='ans" + i + "' value='B'/>B";
                				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 += "<label id='l2" + i + "4'";
                				if (defaultoptionnum < 4) str += " style='display:none'";
                				str += "><input type='radio' name='ans" + i + "' value='D'/>D</label>";
                				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 += "<label id='l2" + i + "6'";
                				if (defaultoptionnum < 6) str += " style='display:none'";
                				str += "><input type='radio' name='ans" + i + "' value='F'/>F</label>";
                				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 += "<label id='l2" + i + "8'";
                				if (defaultoptionnum < 8) str += " style='display:none'";
                				str += "><input type='radio' name='ans" + i + "' value='H'/>H</label>";
                				str += "<label id='l2" + i + "9'";
                				if (defaultoptionnum < 9) str += " style='display:none'";
                				str += "><input type='radio' name='ans" + i + "' value='I'/>I</label>";
                				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 += "<input type='checkbox' name='ans" + i + "' value='A'/>A";
                				str += "<input type='checkbox' name='ans" + i + "' value='B'/>B";
                				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 += "<label id='l3" + i + "4'";
                				if (defaultoptionnum < 4) str += " style='display:none'";
                				str += "><input type='checkbox' name='ans" + i + "' value='D'/>D</label>";
                				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 += "<label id='l3" + i + "6'";
                				if (defaultoptionnum < 6) str += " style='display:none'";
                				str += "><input type='checkbox' name='ans" + i + "' value='F'/>F</label>";
                				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 += "<label id='l3" + i + "8'";
                				if (defaultoptionnum < 8) str += " style='display:none'";
                				str += "><input type='checkbox' name='ans" + i + "' value='H'/>H</label>";
                				str += "<label id='l3" + i + "9'";
                				if (defaultoptionnum < 9) str += " style='display:none'";
                				str += "><input type='checkbox' name='ans" + i + "' value='I'/>I</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 + "' 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="tag_left">
                <table width='100%'>
                   <tbody id='flda'><tbody>
             	</table>
                <input type="hidden" name="xtnum7" id="xtnum7" value="0" />
                <script>

                	var i7 = 0;
                	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) {
                		var url = "<%=BasicField.GetUserUrl("sj/SelectKM","from-editst")%>";
                		url += ",fieldID-" + FieldID;
                		OpenThenSetValue(url, 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>
                <style>
                	#showanswer label,#showanswer span{ vertical-align:middle;}
					#ZSD .cz_btn{ background:none; border-top:0; padding:0;}
					#ZSD .cz_btn input{ margin-left:0;}
					#upframe{ margin-top:10px;}
                </style>
            </td>
        </tr>
        <tr id="commomtm"<%=(tmtype<=5)?"":" style='display:none'" %>>
            <td align="right" class="lefttd" height="30" >
                参考答案：</td>
            <td class="tag_left radio_box" id="showanswer">
                <span id="LabAnswer"><%= getAnswer(Utils.StrToInt(GetParam("tmtype").ToString()), Utils.StrToInt(GetParam("optionnum").ToString(), 2), GetParam("answer").ToString(), GetParam("keywords").ToString(),GetParam("appanswer").ToString()) %></span>
            </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30" >
                答案解释：</td>
            <td class="tag_left">
                <input type="hidden" name="frame" id="frame" value="0" />
                <textarea name="TxtDAJS" rows="2" cols="20" id="TxtDAJS" style="height:120px;width:100%">
                <%=GetParam("dajs").ToString().Replace("\n", "<br/>") %>
                </textarea>
                <%Kesion.APPCode.EditorAPI.EchoEditor("editorTxtDAJS", "TxtDAJS", "Basic", 0, false, true, true, false); %> 
            </td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30" >
                答案解释视频：</td>
            <td class="tag_left">
                <input name="TxtDAJSMedia" type="text" id="TxtDAJSMedia" value="<%=GetParam("dajsmedia") %>" class="textbox" style="width:350px;" />
				<div style="height:10px;"></div>
                <%=Kesion.APPCode.UploadAPI.EchoUpload("courseUserFile","TxtDAJSMedia") %>
			</td>
        </tr>
        
       	<tr style='display:<%=MyCache.GetSJCacheConfig(2)=="1"?"":"none"%>'>
            <td align="right" class="lefttd" height="30" >
                知识点：</td>
            <td id="ZSD" class="tag_left">
			<%
			sb.Clear();
			if (Utils.StrToInt(GetParam("KnowledgeID").ToString()) != 0)
			{
				sb.Append(@" <select name=""KnowledgeID"" id=""KnowledgeID""><option value=""0"">===选择知识点===</option>");
				using (DataTable dtt = DataFactory.GetDataTable("select * from KS_SJKnowLedge Where ClassID=" + Utils.StrToInt(GetParam("classid").ToString())))
				{
					if (dtt.Rows.Count > 0)
					{
						foreach (DataRow drr in dtt.Rows)
						{
							if (Utils.StrToInt(GetParam("knowledgeid").ToString()) == Utils.StrToInt(drr["id"].ToString()))
							{
								sb.AppendFormat(@"<option value=""{0}"" selected>{1}</option>", drr["id"].ToString(), drr["title"].ToString());
							}
							else
							{
								sb.AppendFormat(@"<option value=""{0}"">{1}</option>", drr["id"].ToString(), drr["title"].ToString());
							}
						}
					}
				}
				sb.Append("</select>");
				KSCMS.W(sb.ToString());
			}
			%>
		   	<div class="cz_btn nofloat">
                <span><input type="button" id='KnowledgeBtn' class="button" onclick="loadKnowledge()" value="选择知识点" /></span>
                <span id="showKnowledge"></span>
		   	</div>
		   	</td>
        </tr>
        <tr>
            <td align="right" class="lefttd" height="30" >
                题目序号：</td>
            <td class="tag_left">
                <input name="TxtOrderID" type="text" value="<%=Utils.StrToInt(GetParam("orderid")) %>" id="TxtOrderID"  class="textbox" style="width:60px;text-align:center" />&nbsp;序号越小排在越前面</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <div class="cz_btn nofloat" style="background:none; padding:0; border-top:0;">
                    <input type="hidden" name="HidClassID" id="HidClassID" value="0" />
                    <span><input type="submit" name="Button1" value="确定添加" onclick="return (checkform());" id="Button1" class="button" style=" margin-left:0;"/></span>
                    <span><input type="button" class="button" value="取消关闭" accesskey="C" onclick="jQuery.dialog.close();" /></span>
                    <br/>
                </div>
            </td>
        </tr>
      </table>
	  </form>
	  <br /><br />

