/* public struct structStuScore * { * string StuName; * string StuID; * string StuScore; * } * * structStuScore StudentScore = new structStuScore(); */ public void InitParam() { StudentName = null; //临时保存考生姓名 StudentID = null; //临时保存考生ID StudentUnitName = null; //临时保存考生单位名称 Score = 0; //临时保存考生成绩 ExamPaper = new Queue <stringQA>(); //保存本次考试试卷 tempQA = new stringQA(); //用于临时保存从试卷中dequeue出来的单个试题 intSingleNum = Convert.ToInt32(AppConfigTool.GetAppSettings("SingleNum")); intMultiNum = Convert.ToInt32(AppConfigTool.GetAppSettings("MultiNum")); }
//给定题号和DataSet,返回对应的stringQA结构 public stringQA GetQA(int index, DataSet dataSet) { stringQA rtn = new stringQA(); rtn.Question = (string)dataSet.Tables[0].Rows[index][0]; rtn.AnswerA = (string)dataSet.Tables[0].Rows[index][1]; rtn.AnswerB = (string)dataSet.Tables[0].Rows[index][2]; rtn.AnswerC = (string)dataSet.Tables[0].Rows[index][3]; rtn.AnswerD = (string)dataSet.Tables[0].Rows[index][4]; rtn.TureAnswer = (string)dataSet.Tables[0].Rows[index][5]; return(rtn); }
//生成试卷中题目的队列 public Queue <stringQA> GeneratePaper() { Queue <stringQA> rtn = new Queue <stringQA>(); //stringQA tempQA = new stringQA(); //产生单选题 if (intSingleNum != 0) { if (intSingleNum > SingleExamExcel.Tables[0].Rows.Count) { MessageBox.Show("考试设置错误:出题量超过了题库同题型的数量!"); InitParam(); HideControl(); } else { List <int> SingleList = GetNumList(intSingleNum, SingleExamExcel.Tables[0].Rows.Count); SingleList.Sort(); foreach (int index in SingleList) { stringQA tempQA = GetQA(index, SingleExamExcel); tempQA.singleQ = true; rtn.Enqueue(tempQA); } } } //产生多选题 if (intMultiNum != 0) { if (intMultiNum > MultiExamExcel.Tables[0].Rows.Count) { MessageBox.Show("考试设置错误:出题量超过了题库同题型的数量!"); HideControl(); InitParam(); } else { List <int> MultiList = GetNumList(intMultiNum, MultiExamExcel.Tables[0].Rows.Count); MultiList.Sort(); foreach (int index in MultiList) { stringQA tempQA = GetQA(index, MultiExamExcel); tempQA.MultiQ = true; rtn.Enqueue(tempQA); } } } return(rtn); }