protected override Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content) { TrueFalse subject = sub as TrueFalse; Yw_TrueFalseContent derivedContent = null; if (content == null) { derivedContent = new Yw_TrueFalseContent(); derivedContent.Ysc_CreateTime = DateTime.Now; derivedContent.Ysc_Creator = currentUser; derivedContent.Ysc_SubjectType = subject.SubjectType; } else { derivedContent = content as Yw_TrueFalseContent; } derivedContent.Ysc_Editor = currentUser; derivedContent.Ysc_Explain = subject.Explain; derivedContent.Ysc_Content_Obj = new TrueFalseContentObj { StemType = (int)subject.StemType, Stem = UeditorContentFactory.FetchUrl(subject.Name, subject.StemType) }; derivedContent.Ysc_Answer_Obj = new TrueFalseAnswerObj { Answer = subject.Answer }; derivedContent.Ysc_UpdateTime = DateTime.Now; return(derivedContent); }
public ActionResult Detail(int id, int resourceType) { ResourceBll resourceBll = new ResourceBll(); SubjectBll subjectBll = new SubjectBll(); if (resourceType == (int)ResourceTypeEnum.文本资源) { var detail = resourceBll.GetDtoTextResource(id); return(Json(new JsonResponse <DtoTextResource>() { Data = detail, ErrorCode = (int)ResourceTypeEnum.文本资源 }, JsonRequestBehavior.AllowGet)); } else if (resourceType == (int)ResourceTypeEnum.多媒体资源) { var detail = resourceBll.GetMediaResourceGroup(id); return(Json(new JsonResponse <DtoMediaResourceToCourse>() { Data = detail, ErrorCode = (int)ResourceTypeEnum.多媒体资源 }, JsonRequestBehavior.AllowGet)); } else if (resourceType == (int)ResourceTypeEnum.题目) { var detail = subjectBll.GetSubject(id); return(Json(new JsonResponse <Yw_Subject>() { Data = detail, ErrorCode = (int)ResourceTypeEnum.题目 }, JsonRequestBehavior.AllowGet)); } return(Json(new JsonResponse <Yw_TextResource>() { ErrorCode = 0 }, JsonRequestBehavior.AllowGet)); }
protected override Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content) { FillInBlank subject = sub as FillInBlank; Yw_FillInBlankContent derivedContent = null; if (content == null) { derivedContent = new Yw_FillInBlankContent(); derivedContent.Ysc_CreateTime = DateTime.Now; derivedContent.Ysc_Creator = currentUser; derivedContent.Ysc_SubjectType = subject.SubjectType; } else { derivedContent = content as Yw_FillInBlankContent; } derivedContent.Ysc_Editor = currentUser; derivedContent.Ysc_Explain = subject.Explain; derivedContent.Ysc_Content_Obj = new FillInBlankContentObj { Stem = UeditorContentFactory.Blank(subject.Name) }; derivedContent.Ysc_Answer_Obj = new FillInBlankAnswerObj { Correct = subject.Correct.Blanks, Other = subject.Other.Blanks, Perfect = subject.Perfect.Blanks }; derivedContent.Ysc_UpdateTime = DateTime.Now; return(derivedContent); }
/// <summary> /// 获取Yw_SubjectContent对象,以及对对象如何操作(添加/更新) /// 用于向数据库添加或更新数据 /// </summary> /// <param name="subject"></param> /// <param name="bll"></param> /// <param name="currentUser"></param> /// <param name="entity"></param> /// <returns></returns> public Action <Yw_SubjectContent> Fetch( QuestionInputModel subject, SubjectBll bll, int currentUser, out Yw_SubjectContent entity) { Check.IfNull(subject, nameof(subject)); if (currentUser < 10000) { throw new ArgumentException( "当前登录用户的ID不能小于10000", nameof(currentUser)); } Action <Yw_SubjectContent> saveContentMethod = null; Yw_SubjectContent contentInDb = bll.GetSubjectContent(subject.Id); if (contentInDb == null) { saveContentMethod = bll.InsertContent; } else { saveContentMethod = bll.UpdateContent; } Yw_SubjectContent content = GetContent(subject, bll, currentUser, contentInDb); entity = content; return(saveContentMethod); }
public JsonResult GetSubjectsOfLearning(List <int> subjectIds) { SubjectBll subjectBll = new SubjectBll(); var result = subjectBll.GetCompleteContentsOfSubject(subjectIds); return(Json(new SuccessJsonResponse(result), JsonRequestBehavior.AllowGet)); }
public void SubjectBll_GetSubjectDetails_ShouldReturnAllInfo() { SubjectBll bll = new SubjectBll(); var result = bll.GetSubjectDetails(10000); Assert.IsNotNull(result); Console.WriteLine(result.ToJson()); }
public void GetCourseForSelectCenterTest() { List <int> list = new List <int>(); for (int index = 1; index <= 200; index++) { list.Add(10000 + index); } SubjectBll bll = new SubjectBll(); var x = bll.GetTaskSubjectsAutoForKnowledges(10062, list); }
public static IList <Yw_SubjectKnowledge> Fetch( QuestionInputModel subject, SubjectBll bll, int currentUser, out IEnumerable <int> toDelete) { Check.IfNull(subject, nameof(subject)); Check.IfNull(bll, nameof(bll)); if (currentUser < 10000) { throw new ArgumentException( "当前登录用户的ID不能小于10000", nameof(currentUser)); } DateTime now = DateTime.Now; IEnumerable <Yw_SubjectKnowledge> knowledgeEntities = bll.GetKnowledgesBySubject(subject.Id); IEnumerable <Yw_SubjectKnowledge> secondaryKnowledgeEntities = knowledgeEntities.Where(k => !k.Ysw_IsMain); //前台传过来的次级知识点 IList <int> knowledges = new List <int>(); if (subject.Knowledges.HasValue()) { knowledges = subject.Knowledges.Split(',').Select(k => int.Parse(k)).ToList(); } //需要添加的次级知识点 IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd = null; //需要删除的次级知识点 IEnumerable <int> idsOfknowledgeToDelete = null; //数据库的次级知识点 var knowledgesInDb = secondaryKnowledgeEntities.Select(k => k.Ysw_KnowledgeId); knowledgesToAdd = knowledges.Except(knowledgesInDb) .Select(k => new Yw_SubjectKnowledge { Ysw_KnowledgeId = k, Ysw_IsMain = false, Ysw_CreateTime = now, Ysw_Creator = currentUser, Ysw_UpdateTime = now, Ysw_Editor = currentUser }); var knowledgesToDelete = knowledgesInDb.Except(knowledges); idsOfknowledgeToDelete = secondaryKnowledgeEntities .Where(k => knowledgesToDelete.Contains(k.Ysw_KnowledgeId)) .Select(k => k.Ysw_Id); toDelete = idsOfknowledgeToDelete; return(knowledgesToAdd.ToList()); }
public void GetLessonTaskSubjectTest() { List <Tuple <int, int> > list = new List <Tuple <int, int> >(); for (int index = 1; index <= 200; index++) { list.Add(new Tuple <int, int>(10000 + index, 2)); } SubjectBll bll = new SubjectBll(); var x = bll.GetLessonTaskSubject(10062, list); }
public JsonResult GetSubjectOfLearning(int subjectId) { SubjectBll subjectBll = new SubjectBll(); var result = subjectBll.GetCompleteContentsOfSubject(new List <int> { subjectId }); return(Json( new SuccessJsonResponse(result.FirstOrDefault()), JsonRequestBehavior.AllowGet)); }
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); }
protected override Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content) { MultipleChoice subject = sub as MultipleChoice; Yw_SubjectSelectContent selectContent = null; if (content == null) { selectContent = new Yw_SubjectSelectContent(); selectContent.Ysc_CreateTime = DateTime.Now; selectContent.Ysc_Creator = currentUser; selectContent.Ysc_SubjectType = subject.SubjectType; } else { selectContent = content as Yw_SubjectSelectContent; } selectContent.Ysc_Editor = currentUser; selectContent.Ysc_Explain = subject.Explain; if (subject.ContentType == UeditorType.Image) { subject.Options = subject.Options.Select(o => UeditorContentFactory.FetchUrl(o, subject.ContentType)).ToList(); } var options = subject.Options .Select((o, i) => new SubjectOption { Text = o, Key = i }) .ToList(); selectContent.Ysc_Answer_Obj = new SubjectSelectAnswerObj { Answers = subject.Answers }; string stem = UeditorContentFactory.FetchUrl(subject.Name, subject.StemType); selectContent.Ysc_Content_Obj = new SubjectSelectContentObj { StemType = (int)subject.StemType, Stem = stem, ContentType = (int)subject.ContentType, Options = options, Display = subject.Display, Random = subject.Random }; selectContent.Ysc_UpdateTime = DateTime.Now; return(selectContent); }
public JsonResult GetQuestions(DtoQuestionSearch search) { //此处只需要合格状态的数据 search.SubjectStatus = SubjectStatusEnum.合格; SubjectBll bll = new SubjectBll(); IList <Yw_Subject> subjects = bll.GetSubjects(search); IEnumerable <SubjectViewModel> list = subjects.Select(s => SubjectViewModel.Create(s)); var table = AbhsTableFactory.Create(list, search.Pagination.TotalCount); return(Json(table, JsonRequestBehavior.AllowGet)); }
public ActionResult ReEdit(int subjectId) { SubjectBll bll = new SubjectBll(); Yw_SubjectProcess process = bll.GetNextProcess( subjectId, CurrentUserID, SubjectStatusEnum.编辑中, SubjectActionEnum.重新编辑); bll.ReEdit(process); return(Json(new SuccessJsonResponse())); }
public static IList <Yw_SubjectIndex> Fetch( QuestionInputModel subject, SubjectBll bll, int currentUser, out IList <int> toDelete) { Check.IfNull(subject, nameof(subject)); Check.IfNull(bll, nameof(bll)); if (currentUser < 10000) { throw new ArgumentException( "当前登录用户的ID不能小于10000", nameof(currentUser)); } DateTime now = DateTime.Now; //前端传值过来的关键词 IList <string> keywords = new List <string>(); if (!string.IsNullOrWhiteSpace(subject.Keywords)) { keywords = subject.Keywords.Split(','); } //数据库中的关键词 IEnumerable <Yw_SubjectIndex> keywordEntities = bll.GetKeywordsBySubject(subject.Id); //要删除的关键词 IList <int> keywordIdsToDelete = null; //要添加的关键词 IList <Yw_SubjectIndex> keywordsToAdd = null; IEnumerable <string> keywordsInDb = keywordEntities.Select(k => k.Ysi_Keyword); IEnumerable <string> keywordsToDelete = keywordsInDb.Except(keywords); keywordIdsToDelete = keywordEntities.Where(k => keywordsToDelete.Contains(k.Ysi_Keyword)) .Select(k => k.Ysi_Id) .ToList(); keywordsToAdd = keywords.Except(keywordsInDb) .Select(k => new Yw_SubjectIndex { Ysi_CreateTime = now, Ysi_Creator = currentUser, Ysi_Difficulty = subject.Difficulty, Ysi_Id = 0, Ysi_Keyword = k }).ToList(); toDelete = keywordIdsToDelete; return(keywordsToAdd); }
public JsonResult GetMyQuestions(DtoQuestionSearch search) { //if (!search.SubjectStatus.HasValue || (int)search.SubjectStatus.Value == 0) //{ // search.SubjectStatus= SubjectStatusEnum. //} SubjectBll bll = new SubjectBll(); IList <Yw_Subject> subjects = bll.GetSubjects(search); IEnumerable <SubjectViewModel> list = subjects.Select(s => SubjectViewModel.Create(s)); var table = AbhsTableFactory.Create(list, search.Pagination.TotalCount); return(Json(table, JsonRequestBehavior.AllowGet)); }
public static Action<Yw_SubjectKnowledge> Fetch( QuestionInputModel subject, SubjectBll bll, int currentUser, out Yw_SubjectKnowledge entity) { Check.IfNull(subject, nameof(subject)); Check.IfNull(bll, nameof(bll)); if (currentUser < 10000) { throw new ArgumentException( "当前登录用户的ID不能小于10000", nameof(currentUser)); } DateTime now = DateTime.Now; Action<Yw_SubjectKnowledge> saveKnowledge = null; IEnumerable<Yw_SubjectKnowledge> knowledgeEntities = bll.GetKnowledgesBySubject(subject.Id); Yw_SubjectKnowledge mainKnowledgeEntity = knowledgeEntities.FirstOrDefault(k => k.Ysw_IsMain); if (subject.Knowledge == 0)//不在指定主知识点 { saveKnowledge = bll.DeleteKnowledge; } else { if (mainKnowledgeEntity == null) { mainKnowledgeEntity = new Yw_SubjectKnowledge(); mainKnowledgeEntity.Ysw_IsMain = true; mainKnowledgeEntity.Ysw_CreateTime = now; mainKnowledgeEntity.Ysw_Creator = currentUser; saveKnowledge = bll.InsertMainKnowledge; } else { mainKnowledgeEntity.EnableAudit(); saveKnowledge = bll.UpdateMainKnowledge; } mainKnowledgeEntity.Ysw_Editor = currentUser; mainKnowledgeEntity.Ysw_KnowledgeId = subject.Knowledge; mainKnowledgeEntity.Ysw_UpdateTime = now; } entity = mainKnowledgeEntity; return saveKnowledge; }
/// <summary> /// 获取题目详情 /// </summary> /// <param name="wrongSubjectId"></param> /// <returns></returns> public ActionResult SubjectDetail(int wrongSubjectId) { StudentWrongBookBll wrongBookBll = new StudentWrongBookBll(); SubjectBll subjectBll = new SubjectBll(); var wrongSubject = wrongBookBll.GetWrongSubject(wrongSubjectId); if (CheckWrongSubject(wrongSubject)) { var subjectContent = subjectBll.GetCompleteContentsOfSubject(new List <int> { wrongSubject.Yws_WrongSubjectId }).FirstOrDefault(); return(Json(new SuccessJsonResponse(subjectContent), JsonRequestBehavior.AllowGet)); } return(SimpleResult(false)); }
public ActionResult GetDetails2(int id = 0) { SubjectBll bll = new SubjectBll(); DtoSubject subject = bll.GetSubjectDetails2(id); QuestionInputModel derived = ConvertToDerived2(subject?.Content); if (subject != null) { derived.Difficulty = subject.Difficulty; derived.Explain = subject.Content.Ysc_Explain; derived.Grade = subject.Grade; derived.Id = subject.Id; derived.Mark = subject.Mark; derived.SubjectStatus = (SubjectStatusEnum)subject.Status; derived.Keywords = subject.Keywords; derived.Knowledge = subject.MainKnowledge; derived.KnowledgeText = subject.MainKnowledgeName; derived.Knowledges = string.Join(",", subject.Knowledges); derived.KnowledgeTexts = subject.KnowledgeNames; derived.PlainName = subject.Name; derived.Name = FormatStem(derived.Name); } else { derived.Difficulty = 0; derived.Explain = string.Empty; derived.Grade = 0; derived.Id = 0; derived.Mark = new List <string>(); derived.SubjectStatus = SubjectStatusEnum.编辑中; derived.Keywords = string.Empty; derived.Knowledge = 0; derived.KnowledgeText = string.Empty; derived.Knowledges = string.Empty; derived.KnowledgeTexts = new List <string>(); derived.PlainName = string.Empty; derived.Name = string.Empty; } var response = new SuccessJsonResponse(derived); return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult GetSubjectsToPractice(int studyTaskId, int pageIndex) { StudentPracticeBll bll = new StudentPracticeBll(); int totalCount = 0; var result = bll.GetTaskSubject(studyTaskId, pageIndex, out totalCount); SubjectBll subjectBll = new SubjectBll(); var subjectIds = result.Select(s => s.SubjectId); var subjects = subjectBll.GetSubjectsByIds(subjectIds); foreach (var item in result) { //为vm的MainKnowledgeId属性赋值 var subject = subjects.FirstOrDefault(s => s.Ysj_Id == item.SubjectId); item.KnowledgeId = subject.Ysj_MainKnowledgeId; } return(Json( new AbhsTableJsonResponse(result, totalCount), JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取关联题目详情 /// </summary> /// <param name="wrongSubjectId"></param> /// <returns></returns> public ActionResult SubjectRelation(int wrongSubjectId) { StudentWrongBookBll wrongBookBll = new StudentWrongBookBll(); SubjectBll subjectBll = new SubjectBll(); var wrongSubject = wrongBookBll.GetWrongSubject(wrongSubjectId); if (CheckWrongSubject(wrongSubject)) { var subjectList = subjectBll.GetSubjectForWrongClear(wrongSubject.Yws_WrongSubjectId); var contentList = subjectBll.GetCompleteContentsOfSubject(subjectList.Select(s => s.Ysj_Id).ToList()); contentList.ForEach(s => { s.KnowledgeId = subjectList.Where(sub => sub.Ysj_Id == s.SubjectId).Select(sub => sub.Ysj_MainKnowledgeId).FirstOrDefault(); }); // contentList = contentList.Take(1).ToList(); return(Json( new AbhsTableJsonResponse(contentList, contentList.Count), JsonRequestBehavior.AllowGet)); } return(SimpleResult(false)); }
public ActionResult Approve(ApproveInputModel approve) { SubjectBll bll = new SubjectBll(); var subjectEntity = bll.GetSubject(approve.SubjectId); Yw_SubjectProcess nextProcess = new Yw_SubjectProcess(); nextProcess.Ysp_Action = (int)SubjectActionEnum.审批; nextProcess.Ysp_CreateTime = DateTime.Now; nextProcess.Ysp_Id = 0; nextProcess.Ysp_Operator = CurrentUserID; nextProcess.Ysp_Remark = ""; nextProcess.Ysp_Status = (int)approve.NextStatus; nextProcess.Ysp_SubjectId = approve.SubjectId; subjectEntity.Ysj_Status = nextProcess.Ysp_Status; if (approve.Mark != null && approve.Mark.Count > 0) { string mark = string.Join(",", approve.Mark); nextProcess.Ysp_Mark = mark; } bll.Approve(subjectEntity, nextProcess); return(Json(new SuccessJsonResponse())); }
protected override Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content) { Mark2 subject = sub as Mark2; Yw_SubjectMark2Content selectContent = null; if (content == null) { selectContent = new Yw_SubjectMark2Content(); selectContent.Ysc_CreateTime = DateTime.Now; selectContent.Ysc_Creator = currentUser; selectContent.Ysc_SubjectType = subject.SubjectType; } else { selectContent = content as Yw_SubjectMark2Content; } selectContent.Ysc_Editor = currentUser; selectContent.Ysc_Explain = subject.Explain; selectContent.Ysc_Content_Obj = new SubjectMark2ContentObj { Alignment = subject.Alignment, Color = subject.Color, Content = subject.Content, Stem = UeditorContentFactory.FetchUrl(subject.Name, subject.StemType), StemType = (int)subject.StemType }; selectContent.Ysc_Answer_Obj = new SubjectMark2AnswerObj { Answers = GenareteAnswers(subject.Content) }; selectContent.Ysc_UpdateTime = DateTime.Now; return(selectContent); }
public ActionResult GetReadonlyDetails(int id) { SubjectBll bll = new SubjectBll(); DtoSubject subject = bll.GetSubjectDetails(id); QuestionInputModel derived = ConvertToDerived(subject.Content); derived.Difficulty = subject.Difficulty; derived.Explain = subject.Content.Ysc_Explain; derived.Grade = subject.Grade; derived.Id = subject.Id; derived.Mark = subject.Mark; derived.SubjectStatus = (SubjectStatusEnum)subject.Status; derived.Keywords = subject.Keywords; derived.Knowledge = subject.MainKnowledge; derived.KnowledgeText = subject.MainKnowledgeName; derived.Knowledges = string.Join(",", subject.Knowledges); derived.KnowledgeTexts = subject.KnowledgeNames; derived.PlainName = subject.Name; derived.Name = FormatReadonlyStem(derived.Name); var response = new SuccessJsonResponse(derived); return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult GetGroupedSubjects(DtoQuestionSearch search) { var subjectGroup = new SubjectGroupBll().GetBySubjectId(search.Id); IList <SubjectViewModel> list = new List <SubjectViewModel>(); if (subjectGroup != null && !string.IsNullOrWhiteSpace(subjectGroup.Ysg_RelSubjectId)) { var ids = subjectGroup.Ysg_RelSubjectId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)); SubjectBll bll = new SubjectBll(); var subjects = bll.GetSubjectsByIds(ids); if (subjects != null && subjects.Count > 0) { list = subjects.Select(s => SubjectViewModel.Create(s)).ToList(); } } var table = AbhsTableFactory.Create(list, search.Pagination.TotalCount); return(Json(table, JsonRequestBehavior.AllowGet)); }
protected override Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content) { Free subject = sub as Free; Yw_SubjectFreeContent selectContent = null; if (content == null) { selectContent = new Yw_SubjectFreeContent(); selectContent.Ysc_CreateTime = DateTime.Now; selectContent.Ysc_Creator = currentUser; selectContent.Ysc_SubjectType = subject.SubjectType; } else { selectContent = content as Yw_SubjectFreeContent; } selectContent.Ysc_Editor = currentUser; selectContent.Ysc_Explain = subject.Explain; selectContent.Ysc_Answer_Obj = new SubjectFreeAnswerObj { Answer = subject.Answer }; selectContent.Ysc_Content_Obj = new SubjectFreeContentObj { ScoreRules = subject.ScoreRules, Stem = UeditorContentFactory.FetchUrl(subject.Name, subject.StemType), StemType = (int)subject.StemType }; selectContent.Ysc_UpdateTime = DateTime.Now; return(selectContent); }
protected override Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content) { MultipleChoiceFillInBlank subject = sub as MultipleChoiceFillInBlank; MultipleChoiceFillInBlankContent selectContent = null; if (content == null) { selectContent = new MultipleChoiceFillInBlankContent(); selectContent.Ysc_CreateTime = DateTime.Now; selectContent.Ysc_Creator = currentUser; selectContent.Ysc_SubjectType = subject.SubjectType; } else { selectContent = content as MultipleChoiceFillInBlankContent; } selectContent.Ysc_Editor = currentUser; selectContent.Ysc_Explain = subject.Explain; List <int[]> anses = new List <int[]>(); if (subject.Options != null) { for (int i = 0; i < subject.Options.Count; i++) { int[] ds = new int[2] { i, i }; anses.Add(ds); } } selectContent.Ysc_Answer_Obj = new MultipleChoiceFillInBlankAnswerObj { Answers = anses }; //答案的选项 List <SubjectOption> subjectOptions = new List <SubjectOption>(); if (subject.Options != null) { for (int i = 0; i < subject.Options.Count; i++) { subjectOptions.Add(new SubjectOption { Key = i, Text = UeditorContentFactory.FetchUrl(subject.Options[i], subject.ContentType) }); } } //干扰项 List <SubjectOption> subjectGOptions = new List <SubjectOption>(); if (subject.Goptions != null) { for (int i = 0; i < subject.Goptions.Count; i++) { subjectGOptions.Add(new SubjectOption { Key = i + 100,//干扰项的key设置值 Text = UeditorContentFactory.FetchUrl(subject.Goptions[i], subject.ContentType) }); } } selectContent.Ysc_Content_Obj = new MultipleChoiceFillInBlankContentObj { Stem = UeditorContentFactory.Blank(subject.Name), ContentType = (int)subject.ContentType, SubjectOptions = subjectOptions, SubjectGOptions = subjectGOptions, //GPositions = gps }; selectContent.Ysc_UpdateTime = DateTime.Now; return(selectContent); }
public void GetSubjectForPracticeTest() { SubjectBll bll = new SubjectBll(); var x = bll.GetSubjectForPractice(10003, 10001, 10, 20); }
/// <summary> /// 生成一个Subject Content对象,该对象用于向数据库中添加/更新数据 /// </summary> /// <param name="sub">封装着前端传来的数据</param> /// <param name="bll">SubjectBll对象</param> /// <param name="currentUser">当前用户</param> /// <param name="content">Subject Content对象,该对象从数据库中查询所得,用于判断是添加还是更新操作</param> /// <returns></returns> protected abstract Yw_SubjectContent GetContent( QuestionInputModel sub, SubjectBll bll, int currentUser, Yw_SubjectContent content);
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)); }