// GET: Sections/Problems/5 public async Task <IActionResult> Problems(int?id) { if (id == null) { return(NotFound()); } var section = await _context.Sections .Include(s => s.ProblemSet) .FirstOrDefaultAsync(m => m.ID == id); if (section == null) { return(NotFound()); } var pvmList = new List <ProblemVM>(); foreach (var problem in section.ProblemSet) { var pvm = new ProblemVM { Problem = problem, ID = problem.ID, CorrectAnswer = problem.CorrectChoiceID, Score = problem.Score }; pvmList.Add(pvm); } var vm = new ProblemPageVM { SectionID = Convert.ToInt32(id), Problems = pvmList }; return(View(vm)); }
public IActionResult Problems(int PatientId) { var model = new ProblemVM(); if (User.IsInRole("Patient")) { PatientId = _userManager.Users.First(b => b.UserName == User.Identity.Name).PatientId.Value; } var user = _context.Patient.First(u => u.Id == PatientId); model.DOB = user.Dob; model.PatientId = PatientId; model.PatientName = user.FirstName + " " + user.LastName; if (User.IsInRole("HCP")) { model.Problems = _context.Problems.Where(m => m.PatientId == PatientId).ToList(); } else { model.Problems = _context.Problems.Where(m => m.PatientId == PatientId && m.Approved).ToList(); } return(View(model)); }
/// <summary> /// 答案列表 /// </summary> /// <returns></returns> public ActionResult AnswerList(ProblemVM _ProblemVM) { var entity = _ProblemService.GetById(_ProblemVM.Id); _ProblemVM.AnswerList = entity.AnswerList; _ProblemVM.Title = entity.Title; return(View(_ProblemVM)); }
/// <summary> /// 编辑 /// </summary> /// <param name="_ProblemVM"></param> /// <returns></returns> public ActionResult Edit(ProblemVM _ProblemVM) { _ProblemVM.Problem = _ProblemService.GetById(_ProblemVM.Id) ?? new Problem(); _ProblemVM.ProblemCategorys = _ProblemCategoryService.GetAll(); _ProblemVM.Belongs = _BelongService.GetAll(); _ProblemVM.Chapters = _ChapterService.GetAll(); _ProblemVM.SubjectInfos = _SubjectInfoService.GetAll(); return(View(_ProblemVM)); }
//Ta bort sig själv på listan - digistudent public Task RemoveSelfFromWaitingList(string jsonString) { var json = JsonConvert.DeserializeObject <ProtocolMessage>(jsonString); if (json.Command == "Remove") { ProblemVM problem = waitingList.SingleOrDefault(p => p.Alias == json.Alias && p.ClassroomName == json.ClassroomName); if (problem != null) { repository.EndProblem(json.Alias, json.ClassroomName); waitingList.Remove(problem); } string jsonList = JsonConvert.SerializeObject(waitingList.Where(c => c.ClassroomName == json.ClassroomName)); return(Clients.Group(json.ClassroomName).InvokeAsync("onUpdateWaitingListItem", jsonList)); } return(Task.FromResult <object>(null)); //ingenting händer }
//Ta bort student från waiting list - digimaster public Task DeleteWaitingListItem(string jsonMessage) { ProtocolMessage json = JsonConvert.DeserializeObject <ProtocolMessage>(jsonMessage); if (json.Command == "Delete") { ProblemVM problem = waitingList.SingleOrDefault(p => p.Alias == json.Alias); if (problem != null) { var id = loggedInList.SingleOrDefault(x => x.Value.Alias == json.Alias); Clients.Client(id.Key).InvokeAsync("onRemoveItem", "delete"); repository.EndProblem(json.Alias, json.ClassroomName); waitingList.Remove(problem); } string jsonList = JsonConvert.SerializeObject(waitingList); return(Clients.Group(json.ClassroomName).InvokeAsync("onUpdateWaitingListItem", jsonList)); } return(Task.FromResult <object>(null)); //ingenting händer }
public IHttpActionResult GetIntensive([FromUri] int belongId = 0) { if (belongId != 0) { var problemlist = problemService.GetIntensive(belongId); List <ProblemVM> problemVMlist = new List <ProblemVM>(); foreach (var result in problemlist) { int IsCollect = 0; ProblemVM problem = new ProblemVM(); problem.ProblemId = result.ProblemId; problem.Title = result.Title; problem.ProblemCategoryId = result.ProblemCategoryId; problem.ProblemCategory = result.ProblemCategory; problem.Analysis = result.Analysis; problem.IsCollect = IsCollect; List <AnswerVM> childList = new List <AnswerVM>(); foreach (var item in result.AnswerList) { childList.Add(new AnswerVM { AnswerId = item.AnswerId, ProblemId = item.ProblemId, IsCorrect = item.IsCorrect, Title = item.Title }); } problem.AnswerList = childList; problemVMlist.Add(problem); } return(Json(new { Success = true, Msg = "OK", Data = problemVMlist })); } else { return(Json(new { Success = false, Msg = "请输入对应的级别", Data = "" })); } }
/// <summary> /// 列表 /// </summary> /// <param name="_ProblemVM"></param> /// <param name="pn"></param> /// <returns></returns> public ActionResult List(ProblemVM vm, int pn = 1) { if (Session["QueryData"] != null && vm.RefreshFlag == 1) { vm = (ProblemVM)Session["QueryData"]; vm.RefreshFlag = 0; } else { Session["QueryData"] = vm; } int totalCount, pageIndex = pn, pageSize = PagingConfig.PAGE_SIZE; var list = _ProblemService.GetManagerList(vm.QueryName, vm.QueryBelongId, vm.QueryChapterId, vm.QuerySubjectInfoId, vm.QueryProblemCategoryId, pageIndex, pageSize, out totalCount); var paging = new Paging <Problem>() { Items = list, Size = PagingConfig.PAGE_SIZE, Total = totalCount, Index = pn, }; vm.Paging = paging; vm.Belongs = _BelongService.GetAll(); vm.ProblemCategorys = _ProblemCategoryService.GetAll(); vm.SubjectInfos = _SubjectInfoService.GetAll(); if (vm.QueryChapterId != 0) { vm.Chapters = _ChapterService.GetAll().Where(p => p.SubjectInfoId == vm.QueryChapterId).ToList(); } else { vm.Chapters = new List <Chapter>(); } return(View(vm)); }
public IHttpActionResult GetProblemAndRecord([FromUri] SelctProblemVM SelctProblemVM) { if (SelctProblemVM != null) { int count = 0; var problemCollectList = problemCollectService.GetProblemCollectList(SelctProblemVM.UserInfoId, 1, 10000, out count); //ProblemVM var problemList = problemService.GetProblemList(SelctProblemVM.belongId, SelctProblemVM.ChapterId, SelctProblemVM.SubjectInfoId); List <ProblemVM> problemVMlist = new List <ProblemVM>(); foreach (var result in problemList) { int IsCollect = 0; if (problemCollectList != null && problemCollectList.Count > 0) { var problemCollect = (from a in problemCollectList where a.ProblemId == result.ProblemId select a).FirstOrDefault(); if (problemCollect != null) { IsCollect = 1; } } ProblemVM problem = new ProblemVM(); problem.ProblemId = result.ProblemId; problem.Title = result.Title; problem.ProblemCategoryId = result.ProblemCategoryId; problem.ProblemCategory = result.ProblemCategory; problem.Analysis = result.Analysis; ChapterVM chapterVM = new ChapterVM(); if (result.Chapter != null) { chapterVM.ChapterId = result.Chapter.ChapterId; chapterVM.Title = result.Chapter.Title; chapterVM.Sort = result.Chapter.Sort; } problem.Chapter = chapterVM; problem.IsCollect = IsCollect; List <AnswerVM> childList = new List <AnswerVM>(); if (result.AnswerList != null) { foreach (var item in result.AnswerList) { childList.Add(new AnswerVM { AnswerId = item.AnswerId, ProblemId = item.ProblemId, IsCorrect = item.IsCorrect, Title = item.Title }); } } problem.AnswerList = childList; problemVMlist.Add(problem); } //获取用户此分类的答题记录 var answerRecordModel = userInfoAnswerRecordService.GetUserLastRecord(SelctProblemVM.ChapterId, SelctProblemVM.UserInfoId); LastAnswerRecordVM lar = new LastAnswerRecordVM(); //获取答题记录详细 if (answerRecordModel != null) { var uifa = new UserInfoAnswerVM(); uifa.ChapterId = answerRecordModel.ChapterId; uifa.UserInfoAnswerRecordId = answerRecordModel.UserInfoAnswerRecordId; uifa.UserInfoId = answerRecordModel.UserInfoId; uifa.CTime = answerRecordModel.CTime; uifa.UTime = answerRecordModel.UTime; //通过编号获取详细 var problemRecordList = problemRecordService.GetForUserInfoRecordId(answerRecordModel.UserInfoAnswerRecordId); var prList = new List <ProblemRecordVM>(); foreach (ProblemRecord item in problemRecordList) { prList.Add(new ProblemRecordVM() { ProblemId = item.ProblemId, ProblemRecordId = item.ProblemRecordId, CorrectAnswer = item.CorrectAnswer, ErrorAnswer = item.ErrorAnswer, YesOrNo = item.YesOrNo, }); } lar.problemsRecord = prList; lar.userInfoAnswerRecord = uifa; } ProblemAndRecord par = new ProblemAndRecord(); par.problemsvm = problemVMlist; par.lastAnswervm = lar; return(Json(new { Success = true, Msg = "OK", Data = par })); } else { return(Json(new { Success = false, Msg = "参数不对", Data = "" })); } }
public IHttpActionResult GetProblemList([FromUri] SelctProblemVM SelctProblemVM) { if (SelctProblemVM != null) { int count = 0; var problemCollectList = problemCollectService.GetProblemCollectList(SelctProblemVM.UserInfoId, 1, 10000, out count); //ProblemVM var problemList = problemService.GetProblemList(SelctProblemVM.belongId, SelctProblemVM.ChapterId, SelctProblemVM.SubjectInfoId); List <ProblemVM> problemVMlist = new List <ProblemVM>(); foreach (var result in problemList) { int IsCollect = 0; if (problemCollectList != null && problemCollectList.Count > 0) { var problemCollect = (from a in problemCollectList where a.ProblemId == result.ProblemId select a).FirstOrDefault(); if (problemCollect != null) { IsCollect = 1; } } ProblemVM problem = new ProblemVM(); problem.ProblemId = result.ProblemId; problem.Title = result.Title; problem.ProblemCategoryId = result.ProblemCategoryId; problem.ProblemCategory = result.ProblemCategory; problem.Analysis = result.Analysis; ChapterVM chapterVM = new ChapterVM(); if (result.Chapter != null) { chapterVM.ChapterId = result.Chapter.ChapterId; chapterVM.Title = result.Chapter.Title; chapterVM.Sort = result.Chapter.Sort; } problem.Chapter = chapterVM; problem.IsCollect = IsCollect; List <AnswerVM> childList = new List <AnswerVM>(); if (result.AnswerList != null) { foreach (var item in result.AnswerList) { childList.Add(new AnswerVM { AnswerId = item.AnswerId, ProblemId = item.ProblemId, IsCorrect = item.IsCorrect, Title = item.Title }); } } problem.AnswerList = childList; problemVMlist.Add(problem); } return(Json(new { Success = true, Msg = "OK", Data = problemVMlist })); } else { return(Json(new { Success = false, Msg = "参数不对", Data = "" })); } }