Ejemplo n.º 1
0
        //显示单选题
        private void ShowSO(QuesInfo curQues)
        {
            //显示题目
            this.lab_QuesDesp.Text = new string(curQues.cQuesDisp);
            this.lab_Num.Text = (m_iQuesNum + 1) + ". 单选题";
            string strSelections = new string(curQues.cSelection);
            string strAnswer = (string)Utility_Struct.g_curAnswerList[m_iQuesNum];
            int i = 0;
            while(strSelections.Length > 0)
            {
                string strSelection = "";
                if(strSelections.Length > 0)
                {
                    strSelection = strSelections.Substring(0, strSelections.IndexOf("!:!"));
                    strSelections = strSelections.Substring(strSelections.IndexOf("!:!") + 3,strSelections.Length - strSelection.Length -3);

                }
                else
                {
                    strSelection = strSelections;
                    strSelections = "";

                }
                RadioButton rb = new RadioButton();
                rb.Text = strSelection;
                rb.Top = 200 + i * 32;
                rb.Left = 20;
                rb.AutoSize = true;
                if(strAnswer == strSelection)
                {
                    rb.Checked = true;

                }
                this.Controls.Add(rb);
                m_CtrlList.Add(rb);
                i++;
            }
        }
Ejemplo n.º 2
0
        private void bt_Add_Click(object sender, EventArgs e)
        {
            //获取输入信息
            //根据用户选择获取试题类型
            int iSubectID = ((ListItem)this.cb_Subject.SelectedItem).id;
            int iQuesType = 0;
            if(this.rb_SO.Checked)
            {
                iQuesType = 0;
            }
            else if (this.rb_MC.Checked)
            {
                iQuesType = 1;
            }
            else if (this.rb_Judge.Checked)
            {
                iQuesType = 2;
            }
            else if (this.rb_Blank.Checked)
            {
                iQuesType = 3;
            }

            //获取numbericUpDown 控件的值
            int iPoint = Convert.ToInt32(this.nud_Point.Value);
            //获取其他选项的值
            string strQuesDesp = this.txt_QuesDesp.Text.ToString();
            string strSelection = this.txt_Selection.Text.ToString();
            string strAnswer = this.txt_Answer.Text.ToString();
            //校验参数
            if(strQuesDesp == null || strQuesDesp.Length ==0)
            {
                MessageBox.Show("题目不可为空");
                return;
            }
            if (strSelection == null || strSelection.Length == 0)
            {
                MessageBox.Show("选项不可为空");
                return;
            }
            if (iQuesType != 3 && (strAnswer == null || strAnswer.Length ==0))
            {
                MessageBox.Show("答案不可为空");
                return;
            }
            //生成一条试题,用来存储接收的信息
            QuesInfo quesInfo = new QuesInfo();
            //计算ID,获取试题中的最后一个ID
            if(Utility_Struct.g_QuesList.Count > 0)
            {
                QuesInfo lastQues = (QuesInfo)Utility_Struct.g_QuesList[Utility_Struct.g_QuesList.Count - 1];
                quesInfo.iQuesID = lastQues.iQuesID + 1;
            }
            else
            {
                quesInfo.iQuesID = 1;
            }
            quesInfo.cQuesDisp = strQuesDesp.ToCharArray();
            quesInfo.iPoint = iPoint;

            quesInfo.iQuesType = iQuesType;
            quesInfo.iSubjectID = iSubectID;
            quesInfo.cAnswer = strAnswer.ToCharArray();
            quesInfo.cSelection = strSelection.ToCharArray();
            quesInfo.cTeacherAccount = "张三".ToCharArray();
            quesInfo.cCreateTime =
                string.Format("{0:yyyy/MM/dd HH:mm:ss}", DateTime.Now).ToCharArray();
            quesInfo.iQuesState = 1;
            Utility_Struct.g_QuesList.Add(quesInfo);
            this.Close();
            //关闭窗口
            this.Close();
        }