Exemple #1
0
        public IHttpActionResult GetExamClassList(int BelongId = 0)
        {
            var list = _examClassService.GetExamClassList().Where(c => c.BelongId == BelongId);

            List <ExamClassVM> examClassVMList = new List <ExamClassVM>();

            if (list != null && list.Count() > 0)
            {
                foreach (var item in list)
                {
                    List <ExamProblemVM> examProblemVM = new List <ExamProblemVM>();
                    if (item.ExamProblemList != null)
                    {
                        foreach (var ExamProblem in item.ExamProblemList)
                        {
                            ExamProblemVM model = new ExamProblemVM();
                            model.Analysis          = ExamProblem.Analysis;
                            model.ExamClassId       = ExamProblem.ExamClassId;
                            model.ExamProblemId     = ExamProblem.ExamProblemId;
                            model.ProblemCategoryId = ExamProblem.ProblemCategoryId;
                            model.Score             = item.Score;
                            model.Sort  = item.Sort;
                            model.Title = item.Title;
                            List <ExamAnswerVM> examAnswerVMList = new List <ExamAnswerVM>();

                            if (model.ExamAnswerList != null)
                            {
                                foreach (var cItem in model.ExamAnswerList)
                                {
                                    examAnswerVMList.Add(new ExamAnswerVM
                                    {
                                        ExamAnswerId = cItem.ExamAnswerId,
                                        IsCorrect    = cItem.IsCorrect,
                                        Title        = cItem.Title
                                    });
                                }
                            }
                            model.ExamAnswerList = examAnswerVMList;
                            examProblemVM.Add(model);
                        }
                    }
                    List <ExamProblemVM> examProblemVMList = new List <ExamProblemVM>();
                    examClassVMList.Add(new ExamClassVM {
                        BelongId          = item.BelongId,
                        CreateTime        = item.CreateTime,
                        EndTime           = item.EndTime,
                        ExamClassId       = item.ExamClassId,
                        IsShow            = item.IsShow,
                        Score             = item.Score,
                        Sort              = item.Sort,
                        StartTime         = item.StartTime,
                        Title             = item.Title,
                        ExamProblemVMList = examProblemVM
                    });
                }
            }

            return(Json(new { Success = true, Msg = "OK", Data = examClassVMList }));
        }
Exemple #2
0
        public IHttpActionResult GetExamProblemList(int ExamClassId = 0)
        {
            var list = _examProblemService.GetAll().Where(c => c.ExamClassId == ExamClassId);

            List <ExamProblemVM> examProblemVMList = new List <ExamProblemVM>();

            if (list != null && list.Count() > 0)
            {
                foreach (var item in list)
                {
                    ExamProblemVM model = new ExamProblemVM();
                    model.Analysis          = item.Analysis;
                    model.ExamClassId       = item.ExamClassId;
                    model.ExamProblemId     = item.ExamProblemId;
                    model.ProblemCategoryId = item.ProblemCategoryId;
                    model.Score             = item.Score;
                    model.Sort  = item.Sort;
                    model.Title = item.Title;
                    List <ExamAnswerVM> examAnswerVMList = new List <ExamAnswerVM>();

                    if (model.ExamAnswerList != null)
                    {
                        foreach (var cItem in model.ExamAnswerList)
                        {
                            examAnswerVMList.Add(new ExamAnswerVM
                            {
                                ExamAnswerId = cItem.ExamAnswerId,
                                IsCorrect    = cItem.IsCorrect,
                                Title        = cItem.Title
                            });
                        }
                    }
                    model.ExamAnswerList = examAnswerVMList;
                }
            }
            return(Json(new { Success = true, Msg = "OK", Data = examProblemVMList }));
        }