public void AddSubjectToLesson(Yw_CourseLesson lesson, int subjectId) { Yw_CourseSubjectRelation rel = Repository.GetDirectRelation(lesson.Ycl_Id, subjectId); if (rel == null) { SubjectBll subjectBll = new SubjectBll(); Yw_Subject subject = subjectBll.GetSubject(subjectId); rel = new Yw_CourseSubjectRelation(); rel.Ysr_CourseId = lesson.Ycl_CourseId; rel.Ysr_CreateTime = DateTime.Now; rel.Ysr_DirectSubjectId = 0; rel.Ysr_IsDirect = true; rel.Ysr_LessonId = lesson.Ycl_Id; rel.Ysr_LessonIndex = lesson.Ycl_Index; rel.Ysr_SubjectId = subjectId; rel.Ysr_SubjectType = subject.Ysj_SubjectType; Repository.Add(rel); SubjectGroupBll groupBll = new SubjectGroupBll(); Yw_SubjectGroup group = groupBll.GetBySubjectId(subjectId); if (group != null && !string.IsNullOrEmpty(group.Ysg_RelSubjectId)) { int[] subjectIds = group.Ysg_RelSubjectId.Split(',').Select(x => Convert.ToInt32(x)).ToArray(); Repository.CreateInDirectRelation(rel.Ysr_Id, subjectIds); } } }
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()); }
public static Action <Yw_Subject> Fetch( QuestionInputModel subject, SubjectBll bll, int currentUser, out Yw_Subject entity) { Check.IfNull(subject, nameof(subject)); if (currentUser < 10000) { throw new ArgumentException( "当前登录用户的ID不能小于10000", nameof(currentUser)); } Action <Yw_Subject> saveSubject = null; Yw_Subject subjectEntity = null; if (subject.Id == 0) { subjectEntity = new Yw_Subject(); subjectEntity.Ysj_CreateTime = DateTime.Now; subjectEntity.Ysj_Creator = currentUser; subjectEntity.Ysj_Status = (int)SubjectStatusEnum.编辑中; saveSubject = bll.InsertSubject; } else { subjectEntity = bll.GetSubject(subject.Id); saveSubject = bll.UpdateSubject; } subjectEntity.Ysj_UpdateTime = DateTime.Now; if (!string.IsNullOrWhiteSpace(subject.PlainName)) { string n = subject.PlainName; if (n.Length <= 50) { subjectEntity.Ysj_Name = n; } else { subjectEntity.Ysj_Name = n.Substring(0, 50); } } subjectEntity.Ysj_Keywords = subject.Keywords; subjectEntity.Ysj_Grade = subject.Grade; subjectEntity.Ysj_Editor = currentUser; subjectEntity.Ysj_Difficulty = subject.Difficulty; subjectEntity.Ysj_SubjectType = subject.SubjectType; subjectEntity.Ysj_MainKnowledgeId = subject.Knowledge; entity = subjectEntity; return(saveSubject); }
public void Approve(Yw_Subject subject, Yw_SubjectProcess process) { using (TransactionScope scope = new TransactionScope()) { try { UpdateSubject(subject); MoveToNext(process); scope.Complete(); } catch { RollbackTran(); throw; } } }
public Tuple <StudentAnswerBase, Yw_SubjectContent, Yw_Subject, Yw_StudentWrongSubject> GetWorngSubjectVm(int studentId, int wrongSubjectId) { Yw_StudentWrongSubject wrongSubject = StudentWrongSubjectRepository.Get(wrongSubjectId); if (wrongSubject == null || wrongSubject.Yws_StudentId != studentId) { wrongSubject = null; } if (wrongSubject != null) { StudentAnswerBase answer = (wrongSubject as Yw_StudentWrongSubjectExt).Yws_Answer_Obj; Yw_SubjectContent subjectContent = SubjectBll.GetSubjectContent(wrongSubject.Yws_WrongSubjectId); Yw_Subject subject = SubjectBll.GetSubject(wrongSubject.Yws_WrongSubjectId); return(new Tuple <StudentAnswerBase, Yw_SubjectContent, Yw_Subject, Yw_StudentWrongSubject>(answer, subjectContent, subject, wrongSubject)); } return(null); }
public static SubjectViewModel Create(Yw_Subject subject) { return(new SubjectViewModel { Name = subject.Ysj_Name, SubjectType = subject.Ysj_SubjectType, SubjectTypeText = CustomEnumHelper.Parse( typeof(SubjectTypeEnum), subject.Ysj_SubjectType), Difficulty = CustomEnumHelper.Parse( typeof(DifficultyEnum), subject.Ysj_Difficulty), Grade = CustomEnumHelper.Parse(typeof(GradeEnum), subject.Ysj_Grade), Id = subject.Ysj_Id, Keywords = subject.Ysj_Keywords, QuestionState = subject.Ysj_Status, RelevancyQuestions = subject.Ysj_GroupItemCount }); }
public void ReEdit(Yw_SubjectProcess process) { using (TransactionScope scope = new TransactionScope()) { try { Yw_Subject subject = SubjectService.Get(process.Ysp_SubjectId); subject.EnableAudit(); subject.Ysj_Status = process.Ysp_Status; SubjectService.Update(subject); MoveToNext(process); scope.Complete(); } catch { RollbackTran(); throw; } } }
/// <summary> /// 添加题目到题目组,A,B两个题目互为主副关系。A如果与某些课时有直接关联关系,就要创建B与该课时的间接关联关系;同理B也一样。 /// </summary> /// <param name="subjectId"></param> /// <param name="targetSubjectId"></param> public void AddSubjectToGroup(int subjectId, int targetSubjectId) { SubjectBll subjectBll = new SubjectBll(); Yw_Subject subject = subjectBll.GetSubject(subjectId); Yw_Subject targetSubject = subjectBll.GetSubject(targetSubjectId); using (TransactionScope scope = new TransactionScope()) { try { Repository.AddSubjectToGroup(subjectId, subject.Ysj_SubjectType, targetSubjectId); Repository.AddSubjectToGroup(targetSubjectId, targetSubject.Ysj_SubjectType, subjectId); scope.Complete(); } catch { RollbackTran(); throw; } } }
public void SubjectRepository_Insert_ShouldSuccess() { SubjectRepository repository = new SubjectRepository(); DateTime now = DateTime.Now; Yw_Subject addedEntity = repository.Insert(new Yw_Subject() { Ysj_Id = 0, Ysj_CreateTime = now, Ysj_Creator = 1000, Ysj_Difficulty = (int)DifficultyEnum.一般, Ysj_Editor = 1000, Ysj_Grade = (int)GradeEnum.一年级, Ysj_Keywords = "keywords", Ysj_Name = "danxuanti", Ysj_Status = (int)SubjectStatusEnum.编辑中, Ysj_SubjectType = (int)SubjectTypeEnum.择题, Ysj_UpdateTime = now }); Assert.IsNotNull(addedEntity); Assert.IsTrue(addedEntity.Ysj_Id > 0); }
public void SubmitSubject( Yw_Subject subject, Yw_SubjectContent content, IEnumerable <Yw_SubjectIndex> subjectIndexToAdd, IEnumerable <int> subjectIndexToDelete, Yw_SubjectKnowledge mainKnowledge, IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd, IEnumerable <int> knowledgesToDelete, Yw_SubjectProcess subjectProcess) { using (TransactionScope scope = new TransactionScope()) { try { if (!Saved(subject.Ysj_Id)) { //SaveSubject( // subject, // content, // subjectIndexToAdd, // subjectIndexToDelete, // mainKnowledge, // knowledgesToAdd, // knowledgesToDelete); } subjectProcess.Ysp_SubjectId = subject.Ysj_Id; MoveSubjectProcessToNext(subjectProcess); scope.Complete(); } catch { RollbackTran(); throw; } } }
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); }
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); }
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 void InsertSubject(Yw_Subject subjectEntity) { SubjectService.Insert(subjectEntity); }
protected int SaveSubject(QuestionInputModel subject) { SubjectBll bll = new SubjectBll(); //题目信息 Yw_Subject subjectEntity = null; Action <Yw_Subject> saveSubjectMethod = SubjectFetcher.Fetch(subject, bll, CurrentUserID, out subjectEntity); //题目内容 Yw_SubjectContent content = null; ContentFetcher fetcher = GetContentFetcher(); Action <Yw_SubjectContent> saveContentMethod = fetcher.Fetch( subject, bll, CurrentUserID, out content); //要删除的关键词 IList <int> keywordIdsToDelete = null; //要添加的关键词 IList <Yw_SubjectIndex> keywordsToAdd = KeywordFetcher.Fetch( subject, bll, CurrentUserID, out keywordIdsToDelete); //主知识点 Yw_SubjectKnowledge mainKnowledgeEntity = null; Action <Yw_SubjectKnowledge> saveKnowledgeMethod = MainKnowledgeFetcher.Fetch( subject, bll, CurrentUserID, out mainKnowledgeEntity); //次级知识点 //需要删除的次级知识点 IEnumerable <int> idsOfknowledgeToDelete = null; //需要添加的次级知识点 IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd = SecondaryKnowledgeFetcher.Fetch( subject, bll, CurrentUserID, out idsOfknowledgeToDelete); Yw_SubjectProcess process = null; if (subject.Button == FormSubmitButton.Submit) { process = bll.GetNextProcess( subject.Id, CurrentUserID, subject.NextStatus, SubjectActionEnum.提交); subjectEntity.Ysj_Status = process.Ysp_Status; } return(bll.SaveSubject(saveSubjectMethod, subjectEntity, saveContentMethod, content, saveKnowledgeMethod, mainKnowledgeEntity, keywordsToAdd, keywordIdsToDelete, knowledgesToAdd, idsOfknowledgeToDelete, process, subject.Button)); }
public int SaveSubject( Action <Yw_Subject> saveSubject, Yw_Subject subject, Action <Yw_SubjectContent> saveContent, Yw_SubjectContent content, Action <Yw_SubjectKnowledge> saveKnowledge, Yw_SubjectKnowledge knowledge, IEnumerable <Yw_SubjectIndex> keywordsToAdd, IEnumerable <int> keywordIdsToDelete, IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd, IEnumerable <int> idsOfknowledgeToDelete, Yw_SubjectProcess process, FormSubmitButton button) { using (TransactionScope scope = new TransactionScope()) { try { Check.IfNull(saveSubject, nameof(saveSubject)); Check.IfNull(saveContent, nameof(saveContent)); Check.IfNull(saveKnowledge, nameof(saveKnowledge)); //题目 saveSubject(subject); //题目的内容 content.Ysc_SubjectId = subject.Ysj_Id; saveContent(content); //主知识点 if (knowledge != null) { knowledge.Ysw_SubjectId = subject.Ysj_Id; saveKnowledge(knowledge); } //关键词 if (keywordsToAdd != null) { for (int i = 0; i < keywordsToAdd.Count(); i++) { var k = keywordsToAdd.ElementAt(i); k.Ysi_SubjectId = subject.Ysj_Id; } } InsertKeywords(keywordsToAdd); DeleteKeywords(keywordIdsToDelete); //次级知识点 if (knowledgesToAdd != null) { for (int i = 0; i < knowledgesToAdd.Count(); i++) { var k = knowledgesToAdd.ElementAt(i); k.Ysw_SubjectId = subject.Ysj_Id; } } InsertSecondaryKnowledges(knowledgesToAdd); DeleteSecondaryKnowledges(idsOfknowledgeToDelete); //如果是提交操作,进入审批流程 if (button == FormSubmitButton.Submit) { process.Ysp_SubjectId = subject.Ysj_Id; MoveToNext(process); } scope.Complete(); return(subject.Ysj_Id); } catch { RollbackTran(); throw; } } }
private static int GetKnowledgeId(Yw_Subject subject) { return(subject == null ? 0 : subject.Ysj_MainKnowledgeId); }
public void UpdateSubject(Yw_Subject subjectEntity) { SubjectService.Update(subjectEntity); }