public ExamAnswer GetExamAnswer(RequestGetExamAnswer request) { ExamAnswerHelper eah = new ExamAnswerHelper(); ExamAnswer ea = eah.GetRow(request.usercode, request.ExamPaper); AnswerHelper ah = new AnswerHelper(); ea.Answers = ah.GetRows(ea.GUID); AnswerItemHelper aih = new AnswerItemHelper(); var ais = aih.GetRows(ea.GUID); Dictionary <string, IList <AnswerItem> > items = new Dictionary <string, IList <AnswerItem> >(); foreach (var ai in ais) { if (!items.ContainsKey(ai.Code)) { items.Add(ai.Code, new List <AnswerItem>()); } items[ai.Code].Add(ai); } foreach (var a in ea.Answers) { a.Answers = items[a.Code]; } return(ea); }
public ResultMessage IsExistsExamAnswer(RequestIsExistsExamAnswer request) { ExamAnswerHelper eah = new ExamAnswerHelper(); var result = eah.IsExistsExamAnswer(request.ExamPaper, request.UserCode); return(result); }
public ResultMessage SetExamAnswer(ExamAnswer request) { ExamAnswerHelper eah = new ExamAnswerHelper(); ResultMessage result = eah.Create(request.GUID = Guid.NewGuid().ToString(), request.ExamPaper, request.UserCode, request.ClientIP, request.LeftTime, request.RightTime, request.TotalScore); if (!result.State) { return(result); } AnswerHelper ah = new AnswerHelper(); AnswerItemHelper aih = new AnswerItemHelper(); if (request.Answers == null || request.Answers.Count == 0) { return(result); } foreach (var a in request.Answers) { result = ah.Create(a.GUID = Guid.NewGuid().ToString(), a.Ref_ExamAnswer_GUID = request.GUID, a.Code, a.Score, a.Comment); if (!result.State) { return(result); } if (a.Answers == null || a.Answers.Count == 0) { continue; } foreach (var ai in a.Answers) { if (string.IsNullOrWhiteSpace(ai.ItemOrder)) { continue; } result = aih.Create(ai.GUID = Guid.NewGuid().ToString(), ai.Answer_GUID = a.GUID, ai.ItemOrder, ai.Value, ai.ExpandValue); if (!result.State) { return(result); } } } return(result); }