Пример #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 btnShortcut_Click(object sender, EventArgs e)
        {
            string[] str  = (((Button)sender).Tag.ToString()).Split(',');
            string   type = QuestionInfoForm.getTypeByTypeId(Convert.ToInt32(str[0]));
            int      mark = Convert.ToInt32(str[1]);

            foreach (Question question in list)
            {
                if (question.type == type)
                {
                    question.mark = mark;
                }
            }
            refreshLstQuestion();
        }
Пример #3
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;
            }
        }
Пример #4
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;
            }
        }
Пример #5
0
        private void showAllPapers()
        {
            DBHelper  db  = new DBHelper();
            string    sql = "select a.id,a.name,b.name,c.name from papers a,users b,majors c where a.teacherId=b.id and a.majorId=c.id and a.majorId=" + UserHelper.currentMajorId;
            DbCommand cmd = db.GetSqlStringCommand(sql);
            DataTable dt  = db.ExecuteDataTable(cmd);

            dgvPaperInfo.DataSource = dt;
            //对记录数列填充数据
            updateColumns();
            //记录列
            //按钮列
            dgvPaperInfo.Columns[1].FillWeight = 10;
            //id
            //试卷名称
            dgvPaperInfo.Columns[3].FillWeight = 50;
            //出题人
            dgvPaperInfo.Columns[4].FillWeight = 30;
            //专业
            dgvPaperInfo.Columns[5].FillWeight = 10;
            QuestionInfoForm.setColor(dgvPaperInfo);
        }
Пример #6
0
        private void showAllScores()
        {
            DBHelper  db  = new DBHelper();
            string    sql = "select a.id,a.sname,a.pname,a.score,a.examTime,c.name as mname,b.name as tname from (select a.id,a.score,a.examTime,c.name as sname,b.name as pname,b.majorId,b.teacherId from scores a,papers b,users c where a.paperId=b.id and a.studentId=c.id and a.studentId=" + UserHelper.user.id + " and b.majorId=" + UserHelper.currentMajorId + " and a.state=1) a,users b,majors c where a.majorId=c.id and a.teacherId=b.id";
            DbCommand cmd = db.GetSqlStringCommand(sql);
            DataTable dt  = db.ExecuteDataTable(cmd);

            dgvScoreInfo.DataSource = dt;
            //id
            //姓名
            dgvScoreInfo.Columns[1].FillWeight = 10;
            //试卷名称
            dgvScoreInfo.Columns[2].FillWeight = 40;
            //总分
            dgvScoreInfo.Columns[3].FillWeight = 10;
            //考试时间
            dgvScoreInfo.Columns[4].FillWeight = 20;
            //专业
            dgvScoreInfo.Columns[5].FillWeight = 10;
            //评分人
            dgvScoreInfo.Columns[6].FillWeight = 10;
            QuestionInfoForm.setColor(dgvScoreInfo);
        }
Пример #7
0
        private void showAllPapers()
        {
            DBHelper  db  = new DBHelper();
            string    sql = "select a.id,a.name,a.publishTime,b.name from papers a,majors b where a.majorId=b.id and teacherId=" + UserHelper.user.id + " and a.majorId=" + UserHelper.currentMajorId;
            DbCommand cmd = db.GetSqlStringCommand(sql);
            DataTable dt  = db.ExecuteDataTable(cmd);

            dgvPaperInfo.DataSource = dt;
            //对考生人数列填充数据
            fillColumnExamineeNum();
            //考生人数列
            dgvPaperInfo.Columns[0].FillWeight = 20;
            //按钮列
            dgvPaperInfo.Columns[1].FillWeight = 5;
            //试卷id
            //试卷名称
            dgvPaperInfo.Columns[3].FillWeight = 50;
            //发布时间
            dgvPaperInfo.Columns[4].FillWeight = 20;
            //专业
            dgvPaperInfo.Columns[5].FillWeight = 5;
            QuestionInfoForm.setColor(dgvPaperInfo);
        }
Пример #8
0
        private void clbQuestionInit()
        {
            clbQuestion.Items.Clear();
            DBHelper db  = new DBHelper();
            string   sql = "select * from questions where majorId=" + UserHelper.currentMajorId;

            try
            {
                DbCommand cmd = db.GetSqlStringCommand(sql);
                using (DbDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        Question question = QuestionInfoForm.readerToQuestion(reader);
                        clbQuestion.Items.Add(question);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Пример #9
0
        private void showAllScores(int paperId)
        {
            DBHelper  db  = new DBHelper();
            string    sql = "select a.id,b.id,b.name,a.score,c.name,a.state from scores a,users b,majors c where a.studentId=b.id and b.majorId=c.id and a.paperId=" + paperId;
            DbCommand cmd = db.GetSqlStringCommand(sql);
            DataTable dt  = db.ExecuteDataTable(cmd);

            dgvScoreInfo.DataSource = dt;
            //对总分列与按钮列进行更新
            updateColumns();
            //按钮列
            dgvScoreInfo.Columns[0].FillWeight = 10;
            //成绩id列
            //学员id列
            //姓名列
            dgvScoreInfo.Columns[3].FillWeight = 35;
            //总分列
            dgvScoreInfo.Columns[4].FillWeight = 35;
            //学员来自列
            dgvScoreInfo.Columns[5].FillWeight = 20;
            //状态列
            QuestionInfoForm.setColor(dgvScoreInfo);
        }
Пример #10
0
 private void dgvPaperInfo_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     updateColumns();
     QuestionInfoForm.setColor(dgvPaperInfo);
 }
Пример #11
0
 private void dgvScoreInfo_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     QuestionInfoForm.setColor(dgvScoreInfo);
 }
Пример #12
0
        private bool ReadExcel(string sExcelFile)
        {
            DBHelper oleDb;
            DBHelper sqlDb = new DBHelper();
            string   connectionString;
            string   dbProviderName = "System.Data.OleDb";
            string   fileType       = System.IO.Path.GetExtension(sExcelFile);

            if (string.IsNullOrEmpty(fileType))
            {
                return(false);
            }
            if (fileType == ".xls")
            {
                connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + sExcelFile + ";" + "Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"";
                oleDb            = new DBHelper(connectionString, dbProviderName);
            }
            else
            {
                connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sExcelFile + ";" + "Extended Properties=\"Excel 12.0;HDR=YES;IMEX=1\"";
                oleDb            = new DBHelper(connectionString, dbProviderName);
            }
            OleDbConnection conn = new OleDbConnection(connectionString);

            conn.Open();
            System.Data.DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
            conn.Close();
            if (dt.Rows.Count > 1)
            {
                MessageBox.Show("只支持对单工作表Excel文件的导入!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            string sheetName = dt.Rows[0][2].ToString();
            string sql;
            string oleSql = "select * from [" + sheetName + "]";
            int    result = 0;

            try
            {
                DbCommand cmd = oleDb.GetSqlStringCommand(oleSql);
                using (DbDataReader reader = oleDb.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        string reader0, reader1, reader2, reader3, reader4, reader5;
                        reader0 = (reader[0].ToString().Contains("'")) ? (reader[0].ToString().Replace("'", "''")) : (reader[0].ToString());
                        reader1 = (reader[1].ToString().Contains("'")) ? (reader[1].ToString().Replace("'", "''")) : (reader[1].ToString());
                        reader2 = (reader[2].ToString().Contains("'")) ? (reader[2].ToString().Replace("'", "''")) : (reader[2].ToString());
                        reader3 = (reader[3].ToString().Contains("'")) ? (reader[3].ToString().Replace("'", "''")) : (reader[3].ToString());
                        reader4 = (reader[4].ToString().Contains("'")) ? (reader[4].ToString().Replace("'", "''")) : (reader[4].ToString());
                        reader5 = (reader[5].ToString().Contains("'")) ? (reader[5].ToString().Replace("'", "''")) : (reader[5].ToString());
                        if (QuestionInfoForm.checkQuestion(reader0))
                        {
                            continue;
                        }
                        if (QuestionDialog.getTypeId(cboTypes) == 1)
                        {
                            sql = "insert into questions values('" + reader0 + "','" + reader5 + "',null," + QuestionDialog.getMajorId(cboMajors) + ",1,'" + reader1 + "','" + reader2 + "','" + reader3 + "','" + reader4 + "')";
                        }
                        else
                        {
                            sql = "insert into questions values('" + reader0 + "','" + reader1 + "',null," + QuestionDialog.getMajorId(cboMajors) + "," + QuestionDialog.getTypeId(cboTypes) + ",null,null,null,null)";
                        }
                        cmd     = sqlDb.GetSqlStringCommand(sql);
                        result += sqlDb.ExecuteNonQuery(cmd);
                    }
                }
                MessageBox.Show("成功导入了" + result + "条数据", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(true);
            }
            catch
            {
                return(false);
            }
        }