示例#1
0
        private void btnBegin_Click(object sender, EventArgs e)
        {
            //如果没有选择科目点击开始答题,系统会提示“请选择科目”,才能答题
            if (cboSubjects.SelectedIndex == -1)
            {
                MessageBox.Show("请选择科目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cboSubjects.Focus();
            }
            else
            {
                // 获得选中科目的Id
                subjectId = GetSubjectId();
                string        str = LoginForm.str;
                string        sql = string.Format("select * from StudentScore where LoginId='" + str + "' and SubjectId=" + subjectId + " ");
                SqlDataReader dr  = null;

                dr = DBHelper.getReader(sql);
                if (!dr.Read())

                { // 剩余时间为20分钟
                    QuizHelper.remainSeconds = 1200;
                    AnswerQuestionForm answerQuestion = new AnswerQuestionForm(subjectId);
                    answerQuestion.MdiParent = this.MdiParent;
                    answerQuestion.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("不能重复选择已答完科目,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cboSubjects.Focus();
                }
            }
        }
示例#2
0
        // 转到相应的题目
        private void btnQuestion_Click(object sender, EventArgs e)
        {
            int questionIndex = Convert.ToInt32(((Button)sender).Tag);

            if (questionIndex < 15)
            {
                AnswerQuestionForm answerQuestionForm = new AnswerQuestionForm();
                answerQuestionForm.questionIndex = questionIndex;
                answerQuestionForm.MdiParent     = this.MdiParent;
                answerQuestionForm.Show();
            }
            else if (14 < questionIndex && questionIndex < 19)
            {
                fillblank fillblank = new fillblank();
                fillblank.questionIndex21 = questionIndex;
                fillblank.MdiParent       = this.MdiParent;
                fillblank.Show();
            }
            else
            {
                ShortAnswer shortanswer = new ShortAnswer();
                shortanswer.questionIndex31 = questionIndex;
                shortanswer.MdiParent       = this.MdiParent;
                shortanswer.Show();
            }
            this.Close();
        }
示例#3
0
        // 单击“开始答题”按钮
        private void btnBegin_Click(object sender, EventArgs e)
        {
            if (cboSubjects.SelectedIndex == -1)
            {
                MessageBox.Show("请选择科目!", "上海电力学院在线考试系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cboSubjects.Focus();
            }
            else if (!iscantest())
            {
                MessageBox.Show("该科目已经考试过,请重新选择科目!", "上海电力学院在线考试系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                QuizHelper.subjectId = 0;
                cboSubjects.Focus();
            }

            else
            {
                int subjectId = QuizHelper.subjectId;

                // 该科目问题总数
                int allQuestionCount  = GetQuestionCount(subjectId);
                int allQuestionCount2 = GetQuestionCount2(subjectId);
                int allQuestionCount3 = GetQuestionCount3(subjectId);

                // 指定所有问题数组的长度
                QuizHelper.allQuestionIds  = new int[allQuestionCount];
                QuizHelper.allQuestionIds2 = new int[allQuestionCount2];
                QuizHelper.allQuestionIds3 = new int[allQuestionCount3];

                // 指定是否选择标记的长度
                QuizHelper.selectedStates  = new bool[allQuestionCount];
                QuizHelper.selectedStates2 = new bool[allQuestionCount2];
                QuizHelper.selectedStates3 = new bool[allQuestionCount3];

                // 找出该科目的所有的问题
                SetAllQuestionIds(subjectId);
                SetAllQuestionIds2(subjectId);
                SetAllQuestionIds3(subjectId);

                // 抽题
                SetSelectedQuestionIds();
                SetSelectedQuestionIds2();
                SetSelectedQuestionIds3();

                // 取出标准答案
                SetRightAnswers();
                SetRightAnswers2();

                // 剩余时间为20分钟
                QuizHelper.remainSeconds = 1200;

                // 将学生答案数组初始化
                for (int i = 0; i < QuizHelper.studentAnswers.Length; i++)
                {
                    QuizHelper.studentAnswers[i] = "未回答";
                }

                // 打开答题窗体
                AnswerQuestionForm answerQuestion = new AnswerQuestionForm();
                answerQuestion.MdiParent = this.MdiParent;
                answerQuestion.Show();
                this.Close();
            }
        }