Esempio n. 1
0
        public void SubjectContentDtoBuilder_Create_ShouldReturnCorrect()
        {
            Yw_SubjectContent content = null;
            Yw_Subject        subject = null;
            DtoSubjectContent dto     = SubjectContentDtoBuilder.Create(content, subject);

            Assert.IsNotNull(dto);
            Console.WriteLine(dto.ToJson());
        }
Esempio n. 2
0
        /// <summary>
        /// 获取题目的SubjectContent完整数据
        /// </summary>
        /// <param name="subjectIds"></param>
        /// <returns></returns>
        public IList <DtoSubjectContent> GetCompleteContentsOfSubject(
            IEnumerable <int> subjectIds)
        {
            List <Yw_SubjectContent> contentEntities = Service.GetByIds(subjectIds.ToList());
            List <Yw_Subject>        subjectEntities = SubjectService.GetByIds(subjectIds.ToList());

            return(contentEntities
                   .Select(c => SubjectContentDtoBuilder.Create(c,
                                                                subjectEntities.FirstOrDefault(s => s.Ysj_Id == c.Ysc_SubjectId)))
                   .ToList());
        }
Esempio n. 3
0
        public static ReportVm Create(Yw_SubjectContent content, StudentAnswerBase studentAnswer, Yw_Subject subject)
        {
            DtoSubjectContent subjectContent = SubjectContentDtoBuilder.Create(content, subject);

            ReportVm        vm          = null;
            SubjectTypeEnum subjectType = (SubjectTypeEnum)studentAnswer.Type;

            switch (subjectType)
            {    //选择、选择填空、连线
            case SubjectTypeEnum.择题:
                StuSelectAnswer         selectAnswer  = studentAnswer as StuSelectAnswer;
                DtoSelectSubjectContent selectContent = subjectContent as DtoSelectSubjectContent;
                vm = new MultipleChoiceReportVm
                {
                    SubjectId   = selectAnswer.SubjectId,
                    Stem        = selectContent.Stem,
                    StemType    = (int)selectContent.StemType,
                    Answer      = selectContent.Answer,
                    Options     = selectContent.Options.OrderBy(s => Array.IndexOf(selectAnswer.OptionSequences.ToArray(), s.Key)).ToList(),
                    OptionType  = (int)selectContent.OptionType,
                    SubjectType = (int)selectContent.SubjectType,
                    Analysis    = selectContent.Analysis,

                    StudentAnswer = selectAnswer.Answers,
                    ResultStars   = selectAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.判断题:
                StuTrueFalseAnswer         trueFalseAns = studentAnswer as StuTrueFalseAnswer;
                DtoTrueFalseSubjectContent trueFalseCon = subjectContent as DtoTrueFalseSubjectContent;
                vm = new TrueFalseReportVm
                {
                    SubjectId   = trueFalseAns.SubjectId,
                    Stem        = trueFalseCon.Stem,
                    StemType    = (int)trueFalseCon.StemType,
                    Answer      = trueFalseCon.Answer,
                    SubjectType = (int)trueFalseCon.SubjectType,
                    Analysis    = trueFalseCon.Analysis,

                    StudentAnswer = trueFalseAns.Answer,
                    ResultStars   = trueFalseAns.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.填空题:
                StuBlankAnswer blankAnswer = studentAnswer as StuBlankAnswer;
                DtoFillInBlankSubjectContent fillInBlank = subjectContent as DtoFillInBlankSubjectContent;
                vm = new FillInBlankReportVm
                {
                    SubjectId   = blankAnswer.SubjectId,
                    Stem        = fillInBlank.Stem,
                    StemType    = (int)fillInBlank.StemType,
                    Answer      = fillInBlank.Answer,
                    SubjectType = (int)fillInBlank.SubjectType,
                    Analysis    = fillInBlank.Analysis,

                    StudentAnswer = blankAnswer.Answers,
                    ResultStars   = blankAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.择填空:
                StuSelectBlankAnswer selectBlankAnswer = studentAnswer as StuSelectBlankAnswer;

                DtoSelectFillInBlankSubjectContent multipleChoiceFillInBlank = subjectContent as DtoSelectFillInBlankSubjectContent;

                vm = new MultipleChoiceFillInBlankReportVm
                {
                    SubjectId   = selectBlankAnswer.SubjectId,
                    Stem        = multipleChoiceFillInBlank.Stem,
                    StemType    = (int)multipleChoiceFillInBlank.StemType,
                    Answer      = multipleChoiceFillInBlank.Answer,
                    Options     = multipleChoiceFillInBlank.Options.OrderBy(s => Array.IndexOf(selectBlankAnswer.OptionSequences.ToArray(), s.Key)).ToList(),
                    OptionType  = (int)multipleChoiceFillInBlank.OptionType,
                    SubjectType = (int)multipleChoiceFillInBlank.SubjectType,
                    Analysis    = multipleChoiceFillInBlank.Analysis,

                    StudentAnswer = selectBlankAnswer.Answers,
                    ResultStars   = selectBlankAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.连线题:
                StuMatchAnswer matchAnswer = studentAnswer as StuMatchAnswer;

                DtoMatchSubjectContent match = subjectContent as DtoMatchSubjectContent;

                vm = new MatchReportVm
                {
                    SubjectId       = matchAnswer.SubjectId,
                    Stem            = match.Stem,
                    StemType        = (int)match.StemType,
                    Answer          = match.Answer,
                    SubjectType     = (int)match.SubjectType,
                    LeftOptions     = match.LeftOptions.OrderBy(s => Array.IndexOf(matchAnswer.LeftOptionSequences.ToArray(), s.Key)).ToList(),
                    RightOptions    = match.RightOptions.OrderBy(s => Array.IndexOf(matchAnswer.RightOptionSequences.ToArray(), s.Key)).ToList(),
                    LeftOptionType  = (int)match.LeftOptionType,
                    RightOptionType = (int)match.RightOptionType,
                    Analysis        = match.Analysis,

                    StudentAnswer = matchAnswer.Answers,
                    ResultStars   = matchAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.主观题:
                StuFreeAnswer         freeAnswer = studentAnswer as StuFreeAnswer;
                DtoFreeSubjectContent free       = subjectContent as DtoFreeSubjectContent;

                vm = new FreeReportVm
                {
                    SubjectId   = freeAnswer.SubjectId,
                    Stem        = free.Stem,
                    StemType    = (int)free.StemType,
                    Answer      = free.Answer,
                    SubjectType = (int)free.SubjectType,
                    Analysis    = free.Analysis,
                    Standard    = free.Standard,

                    StudentAnswer = freeAnswer.Answer,
                    ResultStars   = freeAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.圈点批注标色:
                StuMarkColorAnswer    markColorAnswer = studentAnswer as StuMarkColorAnswer;
                DtoMarkSubjectContent mark            = subjectContent as DtoMarkSubjectContent;

                vm = new MarkReportVm
                {
                    SubjectId   = markColorAnswer.SubjectId,
                    Stem        = mark.Stem,
                    StemType    = (int)mark.StemType,
                    Answer      = mark.Answer,
                    SubjectType = (int)mark.SubjectType,
                    Analysis    = mark.Analysis,
                    Content     = mark.Content,
                    Color       = mark.Color,

                    StudentAnswer = markColorAnswer.Answers,
                    ResultStars   = markColorAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            case SubjectTypeEnum.圈点批注断句:
                StuMarkCutAnswer       markCutAnswer = studentAnswer as StuMarkCutAnswer;
                DtoMark2SubjectContent mark2         = subjectContent as DtoMark2SubjectContent;

                vm = new Mark2ReportVm
                {
                    SubjectId   = markCutAnswer.SubjectId,
                    Stem        = mark2.Stem,
                    StemType    = (int)mark2.StemType,
                    Answer      = mark2.Answer,
                    SubjectType = (int)mark2.SubjectType,
                    Analysis    = mark2.Analysis,
                    Content     = mark2.Content,
                    Color       = mark2.Color,

                    StudentAnswer = markCutAnswer.Answers,
                    ResultStars   = markCutAnswer.ResultStars,
                    Difficulty    = subject.Ysj_Difficulty
                };
                break;

            default:
                break;
            }
            return(vm);
        }