public static List <dto_Paper> SetPaperSubmited(List <dto_Paper> list, int studentId) { if (list != null && studentId != 0) { int[] Submited = B_Paper.GetSubmitedPapers(studentId, list.Select(a => a.PaperId).ToArray()); if (Submited != null) { foreach (var s in Submited) { list.FirstOrDefault(a => a.PaperId == s).Submited = true; } } } return(list); }
public static List <dto_Question> GetPaperAnswer(int courseId, long paperId, int studentId) { int id = IdNamingHelper.Decrypt(IdNamingHelper.IdTypeEnum.Paper, paperId); var answer = D_Paper.GetAnswer(id, studentId); List <dto_UserAnswer> ansl = null; if (answer != null) { ansl = JsonConvert.DeserializeObject <List <dto_UserAnswer> >(answer.AnswerJson); } List <dto_Question> ql = B_Paper.GetPaperQuestions(courseId, paperId); if (ql != null) { foreach (dto_Question q in ql) { if (!q.haschildren && Const.OBJECTIVE_QUES_TYPES.Contains(q.ptypeid)) { q.SAnswer = ansl == null ? "" : ansl.Find(b => b.QId == q.id).Answer; } //隐藏真实Id q.NewId = IdNamingHelper.Encrypt(IdNamingHelper.IdTypeEnum.Ques, q.id); q.id = 0; if (q.Children != null && q.Children.Count > 0) { q.Children.ForEach(a => { if (Const.OBJECTIVE_QUES_TYPES.Contains(a.ptypeid)) { a.SAnswer = ansl == null ? "" : ansl.Find(b => b.QId == a.id).Answer; } a.NewId = IdNamingHelper.Encrypt(IdNamingHelper.IdTypeEnum.Ques, a.id); a.id = 0; }); } } } return(ql); }