예제 #1
0
        /// <summary>
        /// 修改组合题材料
        /// </summary>
        /// <param name="id"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public bool UpdateQuestionData(int id, string content, int storeId)
        {
            W_QuestionData model = Orm.Single <W_QuestionData>(x => x.ID == id);

            if (model == null)
            {
                throw new ApiException("题目不存在或者已删除");
            }
            model.Content = content;

            List <W_Question> list = Orm.Select <W_Question>(x => x.QuestionData_ID == id).ToList();

            SqlMapper.BeginTransaction();
            try
            {
                if (Orm.Update(model) > 0)
                {
                    foreach (W_Question question in list)
                    {
                        if (question.QuestionStore_ID != storeId)
                        {
                            question.QuestionStore_ID = storeId;
                            Orm.Update <W_Question>(question);
                        }
                    }
                }
                SqlMapper.CommitTransaction();
            }
            catch
            {
                SqlMapper.RollBackTransaction();
                return(false);
            }
            return(true);
        }
예제 #2
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);
        }
예제 #3
0
 public dynamic DeleteQuestionData(W_QuestionData model)
 {
     return(Success(mapper.DeleteQuestionData(model.ID) ? "操作成功" : "操作失败"));
 }
예제 #4
0
 public dynamic DeleteQuestion(W_QuestionData model)
 {
     return(Success(mapper.DeleteQuestion(model.ID, this.System_Station_ID) ? "操作成功" : "操作失败"));
 }
예제 #5
0
 public dynamic AddQuestionData(W_QuestionData model)
 {
     model.AddPerson = this.AccountID;
     model.AddTime   = DateTime.Now;
     return(Success(mapper.AddQuestionData(model)));
 }
예제 #6
0
 /// <summary>
 /// 添加组合题材料
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddQuestionData(W_QuestionData model)
 {
     return((int)Orm.Insert(model, true));
 }
예제 #7
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);
        }