/// <summary>
        /// 获取考试信息(包括学生信息 和学生答题情况)
        /// </summary>
        /// <param name="ExercisesTestId"></param>
        /// <param name="StudentId"></param>
        /// <returns></returns>
        public ExamInfo GetExamInfo(int ExercisesTestId, int StudentId)
        {
            StudentExamState?stateinfo = StudentExamStatebll.GetStudentExamState(StudentId, ExercisesTestId);
            ExercisesTest?   info1     = ExercisesTestbll.GetExercisesTest(ExercisesTestId);
            StudentExam?     info2     = StudentExambll.GetStudentExam(StudentId);
            ExamInfo         info      = new ExamInfo();

            if (info1 != null && info2 != null)
            {
                info.ExercisesDescribe = info1.Value.ExercisesDescribe;
                info.ExercisesName     = info1.Value.ExercisesName;
                info.ExercisesTestId   = info1.Value.ExercisesTestId;
                info.TotleScore        = ExercisesTestbll.GetExercisesTestTotleScore(info.ExercisesTestId);
                info.IsOver            = info1.Value.IsOver;
                if (stateinfo != null)
                {
                    info.State = stateinfo.Value.State;
                }
                else
                {
                    info.State = 0;
                }


                info.StudentExamId = info2.Value.StudentExamId;
                info.StudentName   = info2.Value.StudentName;
                info.StudentNumber = info2.Value.StudentNumber;
                info.StudentScore  = StudentExambll.GetStudentScore(info.StudentExamId, info.ExercisesTestId);
                info.ListExamTitle = GetExamTitleInfo(info.ExercisesTestId, info.StudentExamId);
            }


            return(info);

//            string strSql = @"select a.ExercisesTestId,a.ExercisesName,a.ExercisesDescribe,c.StudentExamId,c.StudentNumber,c.StudentName from ExercisesTest a
//                            left join StudentExaminationPaper b on a.ExercisesTestId=b.ExercisesTestId
//                            left join StudentExam c on b.StudentExamId=c.StudentExamId
//                            where a.ExercisesTestId=@ExercisesTestId and c.StudentExamId=@StudentExamId";
//            return DataTableToExamInfo(DBFactory.GetDB(DBType.SQLITE, m_strConn).ExecuteStrSql(strSql, new DbParameter[]{
//                new SQLiteParameter(){  Value=ExercisesTestId, ParameterName="@ExercisesTestId"},
//                new SQLiteParameter(){  Value=StudentId, ParameterName="@StudentExamId"}
//            }));
        }
Exemplo n.º 2
0
        private List <ExamList> DataTableToExamList(DataTable dt)
        {
            List <ExamList> listInfo = new List <ExamList>();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    int      StudentExamId = -1;
                    ExamList info          = new ExamList();
                    info.ExercisesTestId   = dr["ExercisesTestId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["ExercisesTestId"]);
                    info.ExercisesName     = dr["ExercisesName"] == DBNull.Value ? "" : dr["ExercisesName"].ToString();
                    info.ExercisesDescribe = dr["ExercisesDescribe"] == DBNull.Value ? "" : dr["ExercisesDescribe"].ToString();
                    StudentExamId          = dr["StudentExamId"] == DBNull.Value ? -100 : Convert.ToInt32(dr["StudentExamId"]);
                    info.TotleScore        = ExercisesTestbll.GetExercisesTestTotleScore(info.ExercisesTestId);
                    info.StudentScore      = GetStudentScore(StudentExamId, info.ExercisesTestId);

                    listInfo.Add(info);
                }
            }
            return(listInfo);
        }