public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.DialogueType              = ((DialogueTypeEnum)(binaryReader.ReadInt16()));
     this.VocalizationIndex         = binaryReader.ReadInt16();
     this.VocalizationName          = binaryReader.ReadStringID();
     this.SpeakerType               = ((SpeakerTypeEnum)(binaryReader.ReadInt16()));
     this.VocalizationPatternsFlags = ((Flags)(binaryReader.ReadInt16()));
     this.Listenertarget            = ((ListenertargetEnum)(binaryReader.ReadInt16()));
     this.fieldpad          = binaryReader.ReadBytes(2);
     this.fieldpad0         = binaryReader.ReadBytes(4);
     this.Hostility         = ((HostilityEnum)(binaryReader.ReadInt16()));
     this.DamageType        = ((DamageTypeEnum)(binaryReader.ReadInt16()));
     this.DangerLevel       = ((DangerLevelEnum)(binaryReader.ReadInt16()));
     this.Attitude          = ((AttitudeEnum)(binaryReader.ReadInt16()));
     this.fieldpad1         = binaryReader.ReadBytes(4);
     this.SubjectActorType  = ((SubjectActorTypeEnum)(binaryReader.ReadInt16()));
     this.CauseActorType    = ((CauseActorTypeEnum)(binaryReader.ReadInt16()));
     this.CauseType         = ((CauseTypeEnum)(binaryReader.ReadInt16()));
     this.SubjectType       = ((SubjectTypeEnum)(binaryReader.ReadInt16()));
     this.CauseAiTypeName   = binaryReader.ReadStringID();
     this.SpatialRelation   = ((SpatialRelationEnum)(binaryReader.ReadInt16()));
     this.fieldpad2         = binaryReader.ReadBytes(2);
     this.SubjectAiTypeName = binaryReader.ReadStringID();
     this.fieldpad3         = binaryReader.ReadBytes(8);
     this.VocalizationPatternsConditions = ((Conditions)(binaryReader.ReadInt32()));
     return(pointerQueue);
 }
Beispiel #2
0
        public ActionResult AddQuestion(int id, SubjectTypeEnum subjectType)
        {
            subjectType = SubjectTypeEnum.判断题;
            QuestionInputModel question = null;

            return(View(subjectType.ToString(), question));
        }
Beispiel #3
0
        public static StudentAnswerBase ConvertByType(SubjectTypeEnum type, string answer)
        {
            StudentAnswerBase res = null;

            try
            {
                switch (type)
                {
                case SubjectTypeEnum.择题:
                    res = JsonConvert.DeserializeObject <StuSelectAnswer>(answer);
                    break;

                case SubjectTypeEnum.判断题:
                    res = JsonConvert.DeserializeObject <StuTrueFalseAnswer>(answer);
                    break;

                case SubjectTypeEnum.填空题:
                    res = JsonConvert.DeserializeObject <StuBlankAnswer>(answer);
                    break;

                case SubjectTypeEnum.择填空:
                    res = JsonConvert.DeserializeObject <StuSelectBlankAnswer>(answer);
                    break;

                case SubjectTypeEnum.连线题:
                    res = JsonConvert.DeserializeObject <StuMatchAnswer>(answer);
                    break;

                case SubjectTypeEnum.主观题:
                    res = JsonConvert.DeserializeObject <StuFreeAnswer>(answer);
                    break;

                case SubjectTypeEnum.圈点批注标色:
                    res = JsonConvert.DeserializeObject <StuMarkColorAnswer>(answer);
                    break;

                case SubjectTypeEnum.圈点批注断句:
                    res = JsonConvert.DeserializeObject <StuMarkCutAnswer>(answer);
                    break;

                default:
                    break;
                }
            }
            catch (Exception)
            {
                //return null;
            }
            return(res);
        }
        public int CalcCoins(List <StudentAnswerBase> answers)
        {
            //一次课后任务或练习,所应得的金币总数
            int totalCoins = 0;
            //某道题应得的金币数
            double coinsOfAnswer = 0;

            foreach (var answer in answers)
            {
                SubjectTypeEnum type = (SubjectTypeEnum)answer.Type;
                switch (type)
                {
                //选择题 判断题,做对给5个金币,做错给0个金币
                case SubjectTypeEnum.择题:
                case SubjectTypeEnum.判断题:
                    coinsOfAnswer = answer.IsRight ? 5 : 0;
                    break;

                //填空 选择填空 连线 圈点批注, 10个金币
                case SubjectTypeEnum.填空题:
                case SubjectTypeEnum.择填空:
                case SubjectTypeEnum.连线题:
                case SubjectTypeEnum.圈点批注标色:
                case SubjectTypeEnum.圈点批注断句:
                    coinsOfAnswer = 10 * (answer.ResultStars * 1.0 / 5);
                    break;

                //首先根据答案、解析和打星规则打星,然后根据星级不同给金币,20个金币
                case SubjectTypeEnum.主观题:
                    coinsOfAnswer = 20 * (answer.ResultStars * 1.0 / 5);
                    break;

                default:
                    break;
                }
                answer.ResultCoins = (int)coinsOfAnswer;

                totalCoins += answer.ResultCoins;
            }

            return(totalCoins);
        }
Beispiel #5
0
        public static string GetValue(this SubjectTypeEnum type)
        {
            switch (type)
            {
            case SubjectTypeEnum.book:
                return("书籍");

            case SubjectTypeEnum.anime:
                return("动画");

            case SubjectTypeEnum.music:
                return("音乐");

            case SubjectTypeEnum.game:
                return("游戏");

            case SubjectTypeEnum.real:
                return("三次元");

            default:
                return(type.ToString());
            }
        }
Beispiel #6
0
        private bool CheckAnswerNeedRecordWorng(StudentAnswerBase answer)
        {
            bool res = false;

            try
            {
                SubjectTypeEnum type = (SubjectTypeEnum)answer.Type;
                switch (type)
                {
                case SubjectTypeEnum.择题:
                case SubjectTypeEnum.判断题:
                    res = !answer.IsRight;
                    break;

                case SubjectTypeEnum.填空题:
                case SubjectTypeEnum.择填空:
                case SubjectTypeEnum.连线题:
                case SubjectTypeEnum.主观题:
                    res = answer.ResultStars <= 2;
                    break;

                case SubjectTypeEnum.圈点批注标色:
                case SubjectTypeEnum.圈点批注断句:
                    res = false;
                    break;

                default:
                    res = false;
                    break;
                }
            }
            catch (Exception ex)
            {
            }
            return(res);
        }
Beispiel #7
0
 protected Subject(SubjectTypeEnum type, string name)
     : base(name)
 {
     Type     = type;
     Children = ImmutableList <ISubject> .Empty;
 }
 public StudentAnswerBase(SubjectTypeEnum type)
 {
     Type = (int)type;
 }
Beispiel #9
0
 public SyntaxNodeSubject(SubjectTypeEnum type, CSharpSyntaxNode syntaxNode, string name)
     : base(type, name)
 {
     this.syntaxNode = syntaxNode;
 }
Beispiel #10
0
 public SyntaxNodeSubject(SubjectTypeEnum type, CSharpSyntaxNode syntaxNode, string name, IKeywordBuilder keywordBuilder)
     : base(type, name, keywordBuilder)
 {
     this.syntaxNode = syntaxNode;
 }
Beispiel #11
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);
        }
Beispiel #12
0
        public static DtoSubjectContent Create(Yw_SubjectContent content, Yw_Subject subject)
        {
            Check.IfNull(content, nameof(content));
            Check.IfNull(subject, nameof(subject));

            int kernalKnowledgeId         = subject == null ? 0 : subject.Ysj_MainKnowledgeId;
            DtoSubjectContent dto         = null;
            SubjectTypeEnum   subjectType = (SubjectTypeEnum)content.Ysc_SubjectType;

            switch (subjectType)
            {
            case SubjectTypeEnum.择题:
                Yw_SubjectSelectContent select = content as Yw_SubjectSelectContent;
                var random   = select.Ysc_Content_Obj.Random;
                var mOptions = StorageIfHasValue(select.Ysc_Content_Obj.Options);
                if (random == 1)    //随机显示
                {
                    mOptions = mOptions.OrderBy(c => Guid.NewGuid()).ToList();
                }
                UeditorType optionType = (UeditorType)select.Ysc_Content_Obj.ContentType;
                foreach (var item in mOptions)
                {
                    item.Text = UeditorContentFactory.RestoreUrl(
                        item.Text, optionType);
                }
                dto = new DtoSelectSubjectContent
                {
                    SubjectId   = select.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = select.Ysc_Explain,
                    Answer      = select.Ysc_Answer_Obj.Answers,
                    StemType    = (UeditorType)select.Ysc_Content_Obj.StemType,
                    Stem        = UeditorContentFactory.RestoreUrl(
                        select.Ysc_Content_Obj.Stem,
                        (UeditorType)select.Ysc_Content_Obj.StemType),
                    Options     = mOptions,
                    OptionType  = optionType,
                    SubjectType = (SubjectTypeEnum)select.Ysc_SubjectType,
                    Display     = select.Ysc_Content_Obj.Display
                };
                break;

            case SubjectTypeEnum.判断题:
                Yw_TrueFalseContent trueFalse = content as Yw_TrueFalseContent;
                dto = new DtoTrueFalseSubjectContent
                {
                    SubjectId   = trueFalse.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = trueFalse.Ysc_Explain,
                    Answer      = trueFalse.Ysc_Answer_Obj.Answer,
                    StemType    = (UeditorType)trueFalse.Ysc_Content_Obj.StemType,
                    Stem        = UeditorContentFactory.RestoreUrl(
                        trueFalse.Ysc_Content_Obj.Stem,
                        (UeditorType)trueFalse.Ysc_Content_Obj.StemType),
                    SubjectType = (SubjectTypeEnum)trueFalse.Ysc_SubjectType
                };
                break;

            case SubjectTypeEnum.填空题:
                Yw_FillInBlankContent fillInBlank = content as Yw_FillInBlankContent;
                string blankStem = UeditorContentFactory.Blank(
                    fillInBlank.Ysc_Content_Obj.Stem);
                dto = new DtoFillInBlankSubjectContent
                {
                    SubjectId   = fillInBlank.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = fillInBlank.Ysc_Explain,
                    Answer      = new
                    {
                        Perfect = fillInBlank.Ysc_Answer_Obj.Perfect,
                        Correct = fillInBlank.Ysc_Answer_Obj.Correct,
                        Other   = fillInBlank.Ysc_Answer_Obj.Other
                    },
                    StemType    = UeditorType.Text,
                    Stem        = blankStem,
                    SubjectType = (SubjectTypeEnum)fillInBlank.Ysc_SubjectType
                };
                break;

            case SubjectTypeEnum.择填空:
                MultipleChoiceFillInBlankContent multipleChoiceFillInBlank
                    = content as MultipleChoiceFillInBlankContent;
                List <SubjectOption> options = new List <SubjectOption>();
                options.AddRange(multipleChoiceFillInBlank.Ysc_Content_Obj.SubjectOptions);
                var gOptions = multipleChoiceFillInBlank.Ysc_Content_Obj.SubjectGOptions;
                options.AddRange(gOptions);
                options = StorageIfHasValue(options).ToList();
                UeditorType contentType =
                    (UeditorType)multipleChoiceFillInBlank.Ysc_Content_Obj.ContentType;
                RestoreUrl(options, contentType);
                options = options.OrderBy(c => Guid.NewGuid()).ToList();
                string mBlankStem = UeditorContentFactory.Blank(
                    multipleChoiceFillInBlank.Ysc_Content_Obj.Stem);
                dto = new DtoSelectFillInBlankSubjectContent
                {
                    SubjectId   = multipleChoiceFillInBlank.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = multipleChoiceFillInBlank.Ysc_Explain,
                    Answer      = multipleChoiceFillInBlank.Ysc_Answer_Obj.Answers,
                    StemType    = UeditorType.Text,
                    Stem        = mBlankStem,
                    Options     = options,
                    OptionType  = (UeditorType)multipleChoiceFillInBlank.Ysc_Content_Obj.ContentType,
                    SubjectType = (SubjectTypeEnum)multipleChoiceFillInBlank.Ysc_SubjectType
                };
                break;

            case SubjectTypeEnum.连线题:
                Yw_MatchContent match = content as Yw_MatchContent;

                var contentObj = match.Ysc_Content_Obj;

                var leftOptions = new List <SubjectOption>();
                leftOptions.AddRange(contentObj.LeftOptions);
                leftOptions = StorageIfHasValue(leftOptions).ToList();
                RestoreUrl(leftOptions, (UeditorType)contentObj.LeftOptionContentType);
                leftOptions = leftOptions.OrderBy(c => Guid.NewGuid()).ToList();

                var rightOptions = new List <SubjectOption>();
                rightOptions.AddRange(contentObj.RightOptions);
                rightOptions = StorageIfHasValue(rightOptions).ToList();
                RestoreUrl(rightOptions, (UeditorType)contentObj.RightOptionContentType);
                rightOptions = rightOptions.OrderBy(c => Guid.NewGuid()).ToList();
                dto          = new DtoMatchSubjectContent
                {
                    SubjectId   = match.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = match.Ysc_Explain,
                    Answer      = match.Ysc_Answer_Obj.Answers,
                    StemType    = (UeditorType)contentObj.StemType,
                    Stem        = UeditorContentFactory.RestoreUrl(
                        contentObj.Stem,
                        (UeditorType)contentObj.StemType),
                    LeftOptions     = leftOptions,
                    RightOptions    = rightOptions,
                    SubjectType     = (SubjectTypeEnum)match.Ysc_SubjectType,
                    LeftOptionType  = (UeditorType)match.Ysc_Content_Obj.LeftOptionContentType,
                    RightOptionType = (UeditorType)match.Ysc_Content_Obj.RightOptionContentType
                };
                break;

            case SubjectTypeEnum.主观题:
                Yw_SubjectFreeContent free = content as Yw_SubjectFreeContent;
                string freeAnswer          = free.Ysc_Answer_Obj.Answer;
                string freeStandard        = free.Ysc_Content_Obj.ScoreRules;

                string freeStem = free.Ysc_Content_Obj.Stem;
                if (free.Ysc_Content_Obj.StemType == (int)UeditorType.Image)
                {
                    freeStem = fileUrlPrefix + freeStem;
                }
                dto = new DtoFreeSubjectContent
                {
                    SubjectId   = free.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = free.Ysc_Explain,
                    Answer      = freeAnswer,
                    StemType    = (UeditorType)free.Ysc_Content_Obj.StemType,
                    Stem        = freeStem,
                    SubjectType = (SubjectTypeEnum)free.Ysc_SubjectType,
                    Standard    = freeStandard
                };
                break;

            case SubjectTypeEnum.圈点批注标色:
                Yw_SubjectMarkContent mark = content as Yw_SubjectMarkContent;
                string stem = mark.Ysc_Content_Obj.Stem;
                if (mark.Ysc_Content_Obj.StemType == (int)UeditorType.Image)
                {
                    stem = fileUrlPrefix + stem;
                }
                string markContent = ReplacePlaceholder(mark.Ysc_Content_Obj.Content);

                dto = new DtoMarkSubjectContent
                {
                    Alignment   = mark.Ysc_Content_Obj.Alignment,
                    SubjectId   = mark.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = mark.Ysc_Explain,
                    Answer      = mark.Ysc_Answer_Obj.Answers,
                    StemType    = (UeditorType)mark.Ysc_Content_Obj.StemType,
                    Stem        = stem,
                    SubjectType = (SubjectTypeEnum)mark.Ysc_SubjectType,
                    Content     = markContent,
                    Color       = mark.Ysc_Content_Obj.Color
                };
                break;

            case SubjectTypeEnum.圈点批注断句:
                Yw_SubjectMark2Content mark2 = content as Yw_SubjectMark2Content;
                string mark2Stem             = mark2.Ysc_Content_Obj.Stem;
                if (mark2.Ysc_Content_Obj.StemType == (int)UeditorType.Image)
                {
                    mark2Stem = fileUrlPrefix + mark2Stem;
                }
                string mark2Content = mark2.Ysc_Content_Obj.Content?
                                      .Replace("/", string.Empty);
                dto = new DtoMark2SubjectContent
                {
                    Alignment   = mark2.Ysc_Content_Obj.Alignment,
                    SubjectId   = mark2.Ysc_SubjectId,
                    KnowledgeId = kernalKnowledgeId,
                    Analysis    = mark2.Ysc_Explain,
                    Answer      = mark2.Ysc_Answer_Obj.Answers,
                    StemType    = (UeditorType)mark2.Ysc_Content_Obj.StemType,
                    Stem        = mark2Stem,
                    SubjectType = (SubjectTypeEnum)mark2.Ysc_SubjectType,
                    Content     = mark2Content,
                    Color       = mark2.Ysc_Content_Obj.Color
                };
                break;

            default:
                break;
            }

            return(dto);
        }
 public string CreateSubjectType(SubjectTypeEnum subjectType)
 {
     return EnumHelper.GetEnumDescription(subjectType);
 }
Beispiel #14
0
        /// <summary>
        /// 显示用户选定类别收藏信息。
        /// </summary>
        /// <param name="subjectCollection"></param>
        /// <param name="subjectType"></param>
        /// <returns></returns>
        public static async Task PopulateSubjectCollectionAsync(ObservableCollection <Collection> subjectCollection, SubjectTypeEnum subjectType)
        {
            try
            {
                //从文件反序列化
                var PreCollection = JsonConvert.DeserializeObject <List <Collection> >(await FileHelper.ReadFromCacheFileAsync("JsonCache\\" + subjectType));
                subjectCollection.Clear();
                if (PreCollection != null)
                {
                    foreach (var type in PreCollection)
                    {
                        subjectCollection.Add(type);
                    }
                }

                var subjectCollections = await BangumiHttpWrapper.GetSubjectCollectionAsync(OAuthHelper.MyToken.UserId, subjectType);

                //清空原数据
                subjectCollection.Clear();
                foreach (var type in subjectCollections.Collects)
                {
                    subjectCollection.Add(type);
                }

                //将对象序列化并存储到文件
                await FileHelper.WriteToCacheFileAsync(JsonConvert.SerializeObject(subjectCollection), "JsonCache\\" + subjectType);
            }
            catch (Exception e)
            {
                Debug.WriteLine("显示用户选定类别收藏信息失败。");
                Debug.WriteLine(e.Message);
                throw e;
            }
        }
        public static DtoSubjectContent Create(Yw_SubjectContent content, Yw_Subject subject)
        {
            Check.IfNull(content, nameof(content));
            Check.IfNull(subject, nameof(subject));

            DtoSubjectContent dto         = null;
            dynamic           contentObj  = null;
            UeditorType       optionType  = UeditorType.Text;
            SubjectTypeEnum   subjectType = (SubjectTypeEnum)content.Ysc_SubjectType;

            switch (subjectType)
            {
            case SubjectTypeEnum.择题:
                Yw_SubjectSelectContent select = content as Yw_SubjectSelectContent;
                contentObj = select.Ysc_Content_Obj;
                optionType = (UeditorType)contentObj.ContentType;
                AppendUrlIfIsImage(contentObj.Options, optionType);
                dto = new DtoSelectSubjectContent
                {
                    Random     = contentObj.Random,
                    Answer     = select.Ysc_Answer_Obj.Answers,
                    Options    = contentObj.Options,
                    OptionType = optionType,
                    Display    = contentObj.Display
                };
                break;

            case SubjectTypeEnum.判断题:
                Yw_TrueFalseContent trueFalse = content as Yw_TrueFalseContent;
                contentObj = trueFalse.Ysc_Content_Obj;
                dto        = new DtoTrueFalseSubjectContent
                {
                    Answer = trueFalse.Ysc_Answer_Obj.Answer
                };
                break;

            case SubjectTypeEnum.填空题:
                Yw_FillInBlankContent fillInBlank = content as Yw_FillInBlankContent;
                contentObj = fillInBlank.Ysc_Content_Obj;
                dto        = new DtoFillInBlankSubjectContent
                {
                    Answer = new
                    {
                        Perfect = fillInBlank.Ysc_Answer_Obj.Perfect,
                        Correct = fillInBlank.Ysc_Answer_Obj.Correct,
                        Other   = fillInBlank.Ysc_Answer_Obj.Other
                    }
                };
                break;

            case SubjectTypeEnum.择填空:
                MultipleChoiceFillInBlankContent multipleChoiceFillInBlank
                           = content as MultipleChoiceFillInBlankContent;
                contentObj = multipleChoiceFillInBlank.Ysc_Content_Obj;
                optionType = (UeditorType)contentObj.ContentType;
                AppendUrlIfIsImage(contentObj.SubjectOptions, optionType);
                AppendUrlIfIsImage(contentObj.SubjectGOptions, optionType);
                dto = new DtoSelectFillInBlankSubjectContent
                {
                    Answer = multipleChoiceFillInBlank.Ysc_Answer_Obj.Answers,
                    //Options = options,
                    OptionType = optionType
                };
                break;

            case SubjectTypeEnum.连线题:
                Yw_MatchContent match = content as Yw_MatchContent;
                contentObj = match.Ysc_Content_Obj;

                var leftOptionType = (UeditorType)contentObj.LeftOptionContentType;
                AppendUrlIfIsImage(contentObj.LeftOptions, leftOptionType);

                var rightOptionType = (UeditorType)contentObj.RightOptionContentType;
                AppendUrlIfIsImage(contentObj.RightOptions, rightOptionType);

                dto = new DtoMatchSubjectContent
                {
                    Answer          = match.Ysc_Answer_Obj.Answers,
                    LeftOptions     = contentObj.LeftOptions,
                    RightOptions    = contentObj.RightOptions,
                    LeftOptionType  = leftOptionType,
                    RightOptionType = rightOptionType
                };
                break;

            case SubjectTypeEnum.主观题:
                Yw_SubjectFreeContent free = content as Yw_SubjectFreeContent;
                contentObj = free.Ysc_Content_Obj;
                dto        = new DtoFreeSubjectContent
                {
                    Answer   = free.Ysc_Answer_Obj.Answer,
                    Standard = contentObj.ScoreRules
                };
                break;

            case SubjectTypeEnum.圈点批注标色:
                Yw_SubjectMarkContent mark = content as Yw_SubjectMarkContent;
                contentObj = mark.Ysc_Content_Obj;
                dto        = new DtoMarkSubjectContent
                {
                    Answer  = mark.Ysc_Answer_Obj.Answers,
                    Content = contentObj.Content,
                    Color   = mark.Ysc_Content_Obj.Color
                };
                break;

            case SubjectTypeEnum.圈点批注断句:
                Yw_SubjectMark2Content mark2 = content as Yw_SubjectMark2Content;
                contentObj = mark2.Ysc_Content_Obj;
                dto        = new DtoMark2SubjectContent
                {
                    Answer  = mark2.Ysc_Answer_Obj.Answers,
                    Content = contentObj.Content,
                    Color   = contentObj.Color
                };
                break;

            default:
                dto        = new DtoDefaultSubjectContent();
                contentObj = new ExpandoObject();
                break;
            }
            dto.SubjectId   = content.Ysc_SubjectId;
            dto.KnowledgeId = GetKnowledgeId(subject);
            dto.Analysis    = content.Ysc_Explain;
            dto.Stem        = contentObj.Stem;
            dto.StemType    = (UeditorType)contentObj.StemType;
            dto.SubjectType = subjectType;

            return(dto);
        }
Beispiel #16
0
 protected Subject(SubjectTypeEnum type, string name, IKeywordBuilder keywordBuilder)
     : base(name, keywordBuilder)
 {
     Type     = type;
     Children = ImmutableList <ISubject> .Empty;
 }
        public static SubjectVm Create(Yw_SubjectContent content)
        {
            Check.IfNull(content, nameof(content));

            SubjectVm       vm          = null;
            SubjectTypeEnum subjectType = (SubjectTypeEnum)content.Ysc_SubjectType;

            switch (subjectType)
            {
            case SubjectTypeEnum.择题:
                Yw_SubjectSelectContent select = content as Yw_SubjectSelectContent;
                var random   = select.Ysc_Content_Obj.Random;
                var mOptions = select.Ysc_Content_Obj.Options;
                if (random == 1)    //随机显示
                {
                    mOptions = mOptions.OrderBy(c => Guid.NewGuid()).ToList();
                }
                vm = new MultipleChoiceSubjectVm
                {
                    KnowledgeId = 0,
                    Analysis    = select.Ysc_Explain,
                    Answer      = select.Ysc_Answer_Obj.Answers,
                    StemType    = select.Ysc_Content_Obj.StemType,
                    Stem        = select.Ysc_Content_Obj.Stem,
                    Options     = mOptions,
                    OptionType  = select.Ysc_Content_Obj.ContentType,
                    SubjectType = select.Ysc_SubjectType,
                    Display     = select.Ysc_Content_Obj.Display
                };
                break;

            case SubjectTypeEnum.判断题:
                Yw_TrueFalseContent trueFalse = content as Yw_TrueFalseContent;
                vm = new TrueFalseSubjectVm
                {
                    KnowledgeId = 0,
                    Analysis    = trueFalse.Ysc_Explain,
                    Answer      = trueFalse.Ysc_Answer_Obj.Answer,
                    StemType    = trueFalse.Ysc_Content_Obj.StemType,
                    Stem        = trueFalse.Ysc_Content_Obj.Stem,
                    SubjectType = trueFalse.Ysc_SubjectType
                };
                break;

            case SubjectTypeEnum.填空题:
                Yw_FillInBlankContent fillInBlank = content as Yw_FillInBlankContent;
                string blankStem = UeditorContentFactory.Blank(
                    fillInBlank.Ysc_Content_Obj.Stem);
                vm = new FillInBlankSubjectVm
                {
                    KnowledgeId = 0,
                    Analysis    = fillInBlank.Ysc_Explain,
                    Answer      = new
                    {
                        Perfect = fillInBlank.Ysc_Answer_Obj.Perfect,
                        Correct = fillInBlank.Ysc_Answer_Obj.Correct,
                        Other   = fillInBlank.Ysc_Answer_Obj.Other
                    },
                    StemType    = (int)UeditorType.Text,
                    Stem        = blankStem,
                    SubjectType = fillInBlank.Ysc_SubjectType
                };
                break;

            case SubjectTypeEnum.择填空:
                MultipleChoiceFillInBlankContent multipleChoiceFillInBlank = content as MultipleChoiceFillInBlankContent;
                List <SubjectOption>             options = new List <SubjectOption>();
                options.AddRange(multipleChoiceFillInBlank.Ysc_Content_Obj.SubjectOptions);
                options.AddRange(multipleChoiceFillInBlank.Ysc_Content_Obj.SubjectGOptions);
                UeditorType contentType =
                    (UeditorType)multipleChoiceFillInBlank.Ysc_Content_Obj.ContentType;
                RestoreUrl(options, contentType);
                options = options.OrderBy(c => Guid.NewGuid()).ToList();
                string mBlankStem = UeditorContentFactory.Blank(
                    multipleChoiceFillInBlank.Ysc_Content_Obj.Stem);
                vm = new MultipleChoiceFillInBlankSubjectVm
                {
                    KnowledgeId = 0,
                    Analysis    = multipleChoiceFillInBlank.Ysc_Explain,
                    Answer      = multipleChoiceFillInBlank.Ysc_Answer_Obj.Answers,
                    StemType    = (int)UeditorType.Text,
                    Stem        = mBlankStem,
                    Options     = options,
                    OptionType  = multipleChoiceFillInBlank.Ysc_Content_Obj.ContentType,
                    SubjectType = multipleChoiceFillInBlank.Ysc_SubjectType
                };
                break;

            case SubjectTypeEnum.连线题:
                Yw_MatchContent match = content as Yw_MatchContent;

                var contentObj = match.Ysc_Content_Obj;

                var leftOptions = new List <SubjectOption>();
                leftOptions.AddRange(contentObj.LeftOptions);
                RestoreUrl(leftOptions, (UeditorType)contentObj.LeftOptionContentType);
                leftOptions = leftOptions.OrderBy(c => Guid.NewGuid()).ToList();

                var rightOptions = new List <SubjectOption>();
                rightOptions.AddRange(contentObj.RightOptions);
                RestoreUrl(rightOptions, (UeditorType)contentObj.RightOptionContentType);
                rightOptions = rightOptions.OrderBy(c => Guid.NewGuid()).ToList();
                vm           = new MatchSubjectVm
                {
                    KnowledgeId     = 0,
                    Analysis        = match.Ysc_Explain,
                    Answer          = match.Ysc_Answer_Obj.Answers,
                    StemType        = contentObj.StemType,
                    Stem            = contentObj.Stem,
                    LeftOptions     = leftOptions,
                    RightOptions    = rightOptions,
                    SubjectType     = match.Ysc_SubjectType,
                    LeftOptionType  = match.Ysc_Content_Obj.LeftOptionContentType,
                    RightOptionType = match.Ysc_Content_Obj.RightOptionContentType
                };
                break;

            case SubjectTypeEnum.主观题:
                Yw_SubjectFreeContent free = content as Yw_SubjectFreeContent;
                string freeAnswer          = free.Ysc_Answer_Obj.Answer;
                if (free.Ysc_Content_Obj.AnswerType == (int)UeditorType.Image)
                {
                    freeAnswer = ConfigurationManager.AppSettings["OssHostUrl"]
                                 + freeAnswer;
                }

                string freeStandard = free.Ysc_Content_Obj.ScoreRules;
                if (free.Ysc_Content_Obj.ScoreRulesType == (int)UeditorType.Image)
                {
                    freeStandard = ConfigurationManager.AppSettings["OssHostUrl"]
                                   + freeStandard;
                }

                string freeStem = free.Ysc_Content_Obj.Stem;
                if (free.Ysc_Content_Obj.StemType == (int)UeditorType.Image)
                {
                    freeStem = ConfigurationManager.AppSettings["OssHostUrl"]
                               + freeStem;
                }
                vm = new FreeSubjectVm
                {
                    KnowledgeId  = 0,
                    Analysis     = free.Ysc_Explain,
                    Answer       = freeAnswer,
                    AnswerType   = free.Ysc_Content_Obj.AnswerType,
                    StemType     = free.Ysc_Content_Obj.StemType,
                    Stem         = freeStem,
                    SubjectType  = free.Ysc_SubjectType,
                    Standard     = freeStandard,
                    StandardType = free.Ysc_Content_Obj.ScoreRulesType
                };
                break;

            case SubjectTypeEnum.圈点批注标色:
                Yw_SubjectMarkContent mark = content as Yw_SubjectMarkContent;
                string stem = mark.Ysc_Content_Obj.Stem;
                if (mark.Ysc_Content_Obj.StemType == (int)UeditorType.Image)
                {
                    stem = ConfigurationManager.AppSettings["OssHostUrl"]
                           + stem;
                }
                string markContent = mark.Ysc_Content_Obj.Content?
                                     .Replace("{:", string.Empty)
                                     .Replace("{:", string.Empty)
                                     .Replace("}", string.Empty);

                vm = new MarkSubjectVm
                {
                    KnowledgeId = 0,
                    Analysis    = mark.Ysc_Explain,
                    Answer      = mark.Ysc_Answer_Obj.Answers,
                    StemType    = mark.Ysc_Content_Obj.StemType,
                    Stem        = stem,
                    SubjectType = mark.Ysc_SubjectType,
                    Content     = markContent,
                    Color       = mark.Ysc_Content_Obj.Color
                };
                break;

            case SubjectTypeEnum.圈点批注断句:
                Yw_SubjectMark2Content mark2 = content as Yw_SubjectMark2Content;
                string mark2Stem             = mark2.Ysc_Content_Obj.Stem;
                if (mark2.Ysc_Content_Obj.StemType == (int)UeditorType.Image)
                {
                    mark2Stem = ConfigurationManager.AppSettings["OssHostUrl"]
                                + mark2Stem;
                }
                string mark2Content = mark2.Ysc_Content_Obj.Content?
                                      .Replace("/", string.Empty);
                vm = new Mark2SubjectVm
                {
                    KnowledgeId = 0,
                    Analysis    = mark2.Ysc_Explain,
                    Answer      = mark2.Ysc_Answer_Obj.Answers,
                    StemType    = mark2.Ysc_Content_Obj.StemType,
                    Stem        = mark2Stem,
                    SubjectType = mark2.Ysc_SubjectType,
                    Content     = mark2Content,
                    Color       = mark2.Ysc_Content_Obj.Color
                };
                break;

            default:
                break;
            }

            return(vm);
        }
Beispiel #18
0
        /// <summary>
        /// 获取指定类别收藏信息。
        /// </summary>
        /// <param name="subjectType"></param>
        /// <returns></returns>
        public static async Task <Collection2> GetSubjectCollectionAsync(string userIdString, SubjectTypeEnum subjectType)
        {
            string url = string.Format("{0}/user/{1}/collections/{2}?app_id={3}&max_results=25", BaseUrl, userIdString, subjectType, ClientId);

            try
            {
                string response = await HttpHelper.GetAsync(url);

                if (response == "null")
                {
                    return(new Collection2 {
                        Collects = new List <Collection>()
                    });
                }
                var result = JsonConvert.DeserializeObject <List <Collection2> >(response);
                foreach (var type in result.ElementAt(0).Collects)
                {
                    foreach (var item in type.Items)
                    {
                        item.Subject.Name   = System.Net.WebUtility.HtmlDecode(item.Subject.Name);
                        item.Subject.NameCn = string.IsNullOrEmpty(item.Subject.NameCn) ? item.Subject.Name : System.Net.WebUtility.HtmlDecode(item.Subject.NameCn);
                    }
                }
                return(result.ElementAt(0));
            }
            catch (Exception e)
            {
                Debug.WriteLine("GetSubjectCollectionAsync Error.");
                throw e;
            }
        }