예제 #1
0
        //自动出题抽取试题
        private ArrayList extractQuestion()
        {
            ArrayList list = new ArrayList();

            foreach (Control con in autoSetQuestionPanel.Controls)
            {
                if (con is NumericUpDown && con.Tag != null)
                {
                    NumericUpDown nud = con as NumericUpDown;
                    if ((int)nud.Value != 0)
                    {
                        int allQuestionCount = Test.getQuestionCount(UserHelper.currentMajorId, Convert.ToInt32(nud.Tag));
                        AutoSetQuestionHelper.allQuestionId      = new int[allQuestionCount];
                        AutoSetQuestionHelper.selectedState      = new bool[allQuestionCount];
                        AutoSetQuestionHelper.selectedQuestionId = new int[Convert.ToInt32(nud.Value)];
                        if (allQuestionCount < AutoSetQuestionHelper.selectedQuestionId.Length)
                        {
                            return(null);
                        }
                        Test.setAllQuestionId(UserHelper.currentMajorId, Convert.ToInt32(nud.Tag));
                        Test.setSelectedQuestionId(AutoSetQuestionHelper.selectedQuestionId.Length);
                        for (int i = 0; i < AutoSetQuestionHelper.selectedQuestionId.Length; i++)
                        {
                            Question question = QuestionInfoForm.getQuestionById(AutoSetQuestionHelper.selectedQuestionId[i]);
                            switch (Convert.ToInt32(nud.Tag))
                            {
                            case 1:
                                question.mark = (int)nudSelectMark.Value;
                                break;

                            case 2:
                                question.mark = (int)nudBlankMark.Value;
                                break;

                            case 3:
                                question.mark = (int)nudShortAnswerMark.Value;
                                break;

                            case 4:
                                question.mark = (int)nudJudgeMark.Value;
                                break;

                            default:
                                break;
                            }
                            list.Add(question);
                        }
                    }
                }
            }
            return(list);
        }
예제 #2
0
        private void showAllQuestions()
        {
            DBHelper db  = new DBHelper();
            string   sql = "select * from question_paper where paperId=" + paperId;

            try
            {
                DbCommand cmd = db.GetSqlStringCommand(sql);
                using (DbDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        Question question = QuestionInfoForm.getQuestionById((int)reader["questionId"]);
                        question.mark = (int)reader["mark"];
                        question.question_paper_id = (int)reader["id"];
                        switch (question.type)
                        {
                        case "选择题":
                            selectList.Add(question);
                            break;

                        case "填空题":
                            blankList.Add(question);
                            break;

                        case "判断题":
                            judgeList.Add(question);
                            break;

                        case "简答题":
                            shortAnswerList.Add(question);
                            break;

                        default:
                            break;
                        }
                    }
                }
                ExamHelper.selectAnswers = new String[selectList.Count];
                ExamHelper.judgeAnswers  = new String[judgeList.Count];
                layoutAllQuestions(selectList, blankList, judgeList, shortAnswerList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #3
0
        private void showAllQuestions()
        {
            List <Question> blankList       = new List <Question>();
            List <Question> shortAnswerList = new List <Question>();
            DBHelper        db  = new DBHelper();
            string          sql = "select a.answer,b.questionId,b.paperId,b.mark from stu_answers a,question_paper b where a.question_paper_id=b.id and a.studentId=" + stuId;

            try
            {
                DbCommand cmd = db.GetSqlStringCommand(sql);
                using (DbDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        Question question = QuestionInfoForm.getQuestionById((int)reader["questionId"]);
                        question.mark      = (int)reader["mark"];
                        question.stuAnswer = reader["answer"].ToString();
                        lblPaperName.Text  = getPaperNameById((int)reader["paperId"]);
                        switch (question.type)
                        {
                        case "填空题":
                            blankList.Add(question);
                            break;

                        case "简答题":
                            shortAnswerList.Add(question);
                            break;

                        default:
                            break;
                        }
                    }
                }
                layoutAllQuestions(blankList, shortAnswerList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }