public void SetQuestion(int x) { proID = x; choice = ClientControl.GetChoice(proID); this.Question.Text = choice.problem; this.OptionA.InText = choice.optionA; this.OptionB.InText = choice.optionB; this.OptionC.InText = choice.optionC; this.OptionD.InText = choice.optionD; radioButtonA.Checked = choice.stuAns == "A"; radioButtonB.Checked = choice.stuAns == "B"; radioButtonC.Checked = choice.stuAns == "C"; radioButtonD.Checked = choice.stuAns == "D"; if (!string.IsNullOrEmpty(choice.stuAns)) { ClientControl.SetDone(choice.problemId); } }
public static void AddChoice(Choice choice) { paper.Add(choice); }
/// <summary> /// DataSet装换为泛型集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="p_DataSet">DataSet</param> /// <param name="p_TableIndex">待转换数据表索引</param> /// <returns></returns> //private List<Problem> DataSetToList(DataSet p_DataSet) //{ // DataTable p_Data = p_DataSet.Tables[0]; // // 返回值初始化 // List<Problem> result = new List<Problem>(); // for (int j = 0; j < p_Data.Rows.Count; j++) // { // Problem problem = new Problem(); // for (int i = 0; i < p_Data.Columns.Count; i++) // { // // 数据库NULL值单独处理 // if (p_Data.Columns[i].ToString() == "Id") // problem.problemId = Convert.ToInt32(p_Data.Rows[j][i]); // if (p_Data.Columns[i].ToString() == "Problem_Content") // problem.problem = (string)p_Data.Rows[j][i]; // } // result.Add(problem); // } // return result; //} //private List<String> DataSetPaperToList(DataSet p_DataSet) //{ // DataTable p_Data = p_DataSet.Tables[0]; // // 返回值初始化 // List<String> result = new List<String>(); // for (int j = 0; j < p_Data.Rows.Count; j++) // { // string str = ""; // for (int i = 0; i < p_Data.Columns.Count; i++) // { // // 数据库NULL值单独处理 // if (p_Data.Columns[i].ToString() == "Title") // str = (String)p_Data.Rows[j][i]; // } // result.Add(str); // } // return result; //} /// <summary> /// DataSet装换为泛型集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="p_DataSet">DataSet</param> /// <param name="p_TableIndex">待转换数据表索引</param> /// <returns></returns> private List<Choice> DataSetToListChoice(DataSet p_DataSet) { DataTable p_Data = p_DataSet.Tables[0]; // 返回值初始化 List<Choice> result = new List<Choice>(); for (int j = 0; j < p_Data.Rows.Count; j++) { Choice problem = new Choice(); problem.problemId=Convert.ToInt32(p_Data.Rows[j]["PID"]); problem.problem = p_Data.Rows[j]["PContent"].ToString(); problem.optionA = p_Data.Rows[j]["A"].ToString(); problem.optionB = p_Data.Rows[j]["B"].ToString(); problem.optionC = p_Data.Rows[j]["C"].ToString(); problem.optionD = p_Data.Rows[j]["D"].ToString(); problem.ans = p_Data.Rows[j]["Answer"].ToString(); problem.unit.UnitId = Convert.ToInt32(p_Data.Rows[j]["Unit"]); problem.unit.UnitName = p_Data.Rows[j]["UnitName"].ToString(); problem.Plevel = Convert.ToInt32(p_Data.Rows[j]["PLevel"]); result.Add(problem); } return result; }
public List<Choice> GetChoiceProbelms() { List<Choice> list = new List<Choice>(); foreach (XmlNode xnn in xd.ChildNodes.Item(1).ChildNodes) { if (xnn.Name == "Choice") { Choice c = new Choice(); c.problemId = Convert.ToInt32(xnn.Attributes["ProblemId"].Value); c.orderId = Convert.ToInt32(xnn.Attributes["OrderId"].Value); foreach (XmlNode option in xnn.ChildNodes) { if (option.ChildNodes.Item(0) != null) { switch (option.Name) { case "Problem": c.problem = option.ChildNodes.Item(0).Value; break; case "OptionA": c.optionA = option.ChildNodes.Item(0).Value; break; case "OptionB": c.optionB = option.ChildNodes.Item(0).Value; break; case "OptionC": c.optionC = option.ChildNodes.Item(0).Value; break; case "OptionD": c.optionD = option.ChildNodes.Item(0).Value; break; } } } list.Add(c); } } return list; }