1.今日任务
学生错题查看以及成绩统计
错题查看
控制器代码:错题查看
1 public ActionResult MyError() 2 { 3 var currentuser = Session[CommonFeild.SessionName] as Exam_User; 4 //获取答题信息 5 List<Exam_Answer> list = AnswerService.GetError(currentuser.UserID); 6 //加载试卷模型 7 List<ExamPaperBLL> paperbll = new List<ExamPaperBLL>(); 8 foreach (var item in list) 9 { 10 ExamPaperBLL examPaperBLL = new ExamPaperBLL(); 11 examPaperBLL.Exam_Question = QuestionService.GetdataByID(item.QuestionID); 12 examPaperBLL.AnswerOptionID = item.AnswerOptionID; 13 paperbll.Add(examPaperBLL); 14 15 } 16 return View(paperbll); 17 }
service层方法
1 /// <summary> 2 /// 获取用户错题 3 /// </summary> 4 /// <param name="userid"></param> 5 /// <returns></returns> 6 public static List<Exam_Answer> GetError(int userid) 7 { 8 using (ExamSysDBContext db = new ExamSysDBContext()) 9 { 10 var data = db.Exam_Answer.Where(x => x.UserID == userid && x.AnswerOptionID != "" && x.AnswerOptionID != x.OptionID).ToList(); 11 return data; 12 } 13 }
3.遇到问题
无
4.解决方案
无