示例#1
0
        /// <summary>
        /// 显示试卷做题结果
        /// </summary>
        /// <param name="examPaperId"></param>
        /// <param name="resultId"></param>
        /// <param name="System_Station_ID"></param>
        /// <param name="stuId"></param>
        /// <returns></returns>
        public dynamic GetExamPaperResult(int examPaperId, int resultId, int System_Station_ID, string stuId)
        {
            W_ExamPaper paper = Orm.Single <W_ExamPaper>(x => x.ID == examPaperId && x.System_Station_ID == System_Station_ID);

            if (paper == null)
            {
                throw new ApiException("试卷不存在或者已删除");
            }
            //查出试卷所有题型
            List <W_ExamPaperDetail> paperDetails = Orm.Select <W_ExamPaperDetail>(x => x.ExamPaper_ID == examPaperId).ToList();
            //根据试卷ID查出题目
            //List<W_ExamPaperDetail_Detail> dList = Orm.Select<W_ExamPaperDetail_Detail>(x => x.ExamPaper_ID == paper.ID);
            //if (dList == null || dList.Count == 0)
            //    throw new ApiException("试卷有误,请重试");
            List <Question>       qList    = SqlMapper.QueryForList <Question>("GetExamResult", new { busId = examPaperId, resultId, stuId }).ToList();
            List <W_QuestionData> dataList = SqlMapper.QueryForList <W_QuestionData>("GetExamQuestionData", new { examPaperId }).ToList();

            List <W_QuestionNote> NoteList = Orm.Select <W_QuestionNote>(x => x.StuID == stuId).ToList();//题目笔记列表

            List <ExamQuestionType> list = new List <ExamQuestionType>();
            decimal TotalScore           = 0;

            foreach (W_ExamPaperDetail item in paperDetails)
            {
                ExamQuestionType QuestionType = new ExamQuestionType();
                QuestionType.TypeInfo = item;

                QuestionType.Question = qList.Where(x => x.ExamPaper_Detail_ID == item.ID).OrderBy(x => x.Sort).OrderBy(x => x.ID).ToList();

                foreach (Question q in QuestionType.Question)
                {
                    if (item.QuestionType_ID == 7)//组合题
                    {
                        W_QuestionData temp = dataList.FirstOrDefault(x => x.ID == q.QuestionData_ID);
                        q.QuestionData = temp != null ? temp.Content : "";
                    }
                    q.NoteList = NoteList != null?NoteList.Where(x => x.Question_ID == q.ID).ToList() : null;
                }
                list.Add(QuestionType);

                TotalScore += item.Num * item.Sorce;
            }
            W_DoExamResult    theResult = Orm.Single <W_DoExamResult>(x => x.ID == resultId);
            ExamPaperQuestion model     = new ExamPaperQuestion();

            model.PaperInfo    = paper;
            model.ResultId     = resultId;
            model.TotalScore   = TotalScore;
            model.TotalTime    = theResult != null ? (theResult.EndTime - theResult.BeginTime).TotalSeconds : 0.00;
            model.QuestionType = list;
            return(model);
        }
示例#2
0
        /// <summary>
        /// 获取试卷题目信息
        /// </summary>
        /// <param name="examPaperId"></param>
        /// <returns></returns>
        public dynamic GetExamPaperQuestions(int examPaperId, int System_Station_ID, string stuId)
        {
            W_ExamPaper paper = Orm.Single <W_ExamPaper>(x => x.ID == examPaperId && x.System_Station_ID == System_Station_ID);

            if (paper == null)
            {
                throw new ApiException("试卷不存在或者已删除");
            }
            //查出试卷所有题型
            List <W_ExamPaperDetail> paperDetails = Orm.Select <W_ExamPaperDetail>(x => x.ExamPaper_ID == examPaperId).ToList();

            List <Question>       qList    = SqlMapper.QueryForList <Question>("GetExamQuestion", new { examPaperId }).ToList();
            List <W_QuestionData> dataList = SqlMapper.QueryForList <W_QuestionData>("GetExamQuestionData", new { examPaperId }).ToList();

            List <ExamQuestionType> list = new List <ExamQuestionType>();
            decimal TotalScore           = 0;

            foreach (W_ExamPaperDetail item in paperDetails)
            {
                ExamQuestionType QuestionType = new ExamQuestionType();
                QuestionType.TypeInfo = item;

                QuestionType.Question = qList.Where(x => x.ExamPaper_Detail_ID == item.ID).OrderBy(x => x.Sort).OrderBy(x => x.ID).ToList();
                if (item.QuestionType_ID == 7)//组合题
                {
                    foreach (Question q in QuestionType.Question)
                    {
                        W_QuestionData temp = dataList.FirstOrDefault(x => x.ID == q.QuestionData_ID);
                        q.QuestionData = temp != null ? temp.Content : "";
                    }
                }
                list.Add(QuestionType);

                TotalScore += item.Num * item.Sorce;
            }

            W_DoExamResult er = Orm.Single <W_DoExamResult>(x => x.BusID == examPaperId && x.BusType == 0 && x.StuId == stuId && x.Valid == 0);
            int            resultId;

            if (er == null)//重新做题
            {
                // 创建学生做题记录主表,保存开始做题时间
                W_DoExamResult result = new W_DoExamResult();
                result.StuId     = stuId;
                result.BusType   = 0;//试卷
                result.BusID     = examPaperId;
                result.BeginTime = DateTime.Now;
                result.EndTime   = DateTime.Now;
                resultId         = (int)Orm.Insert <W_DoExamResult>(result, true);
            }
            else  //继续做题
            {
                resultId     = er.ID;
                er.BeginTime = DateTime.Now;
                Orm.Update <W_DoExamResult>(er);
            }

            ExamPaperQuestion model = new ExamPaperQuestion();

            model.PaperInfo    = paper;
            model.ResultId     = resultId;
            model.TotalScore   = TotalScore;
            model.QuestionType = list;
            return(model);
        }