/// <summary> /// 用户参加考试,返回根据考卷模板生成最终的考试卷 /// </summary> /// <param name="userId">用户ID</param> /// <param name="examId">准备参考的试卷</param> /// <remarks></remarks> public NewExamPaper TakeExam(long userId, long examId) { var examManage = new ExamsManage(examId); var newExamPaper = examManage.CreateNewExamPaper(); if (newExamPaper != null) { //将题目信息初始化为作答信息 var results = newExamPaper.Questions.Select(p => new UserExamQuestionResult(p)).ToList(); //将新参考试卷到数据库 UserExamInitRequest request = new UserExamInitRequest { UserExamId = newExamPaper.PaperId, ExamId = examId, UserId = userId, CreateTime = newExamPaper.CreateTime, QuestionsResults = results }; var userExamInit = new UserExamInit(request); bool success = userExamInit.Save(); if (success) { return(newExamPaper); } } return(null); }
/// <summary> /// 获取考卷详细信息 /// </summary> /// <param name="examsId">考卷ID</param> /// <returns></returns> public ExamsDetails GetDetails(long examsId) { var exams = new ExamsManage(examsId); return(exams.ConvertToExamsDetails()); }
/// <summary> /// 更新考卷信息 /// </summary> /// <param name="examsId">考卷ID</param> /// <param name="state">要更新的数据</param> /// <returns></returns> public bool ModifyTo(long examsId, ExamsModifyState state) { var exams = new ExamsManage(examsId); return(exams.ModifyTo(state)); }
/// <summary> /// 获取考卷信息 /// </summary> /// <param name="examsId">考卷ID</param> /// <returns></returns> public Exams GetExams(long examsId) { var exams = new ExamsManage(examsId); return(exams.Exams); }
/// <summary> /// 设置考卷状态为禁用 /// </summary> /// <param name="examsId"></param> /// <returns></returns> public bool SetDisable(long examsId) { var exams = new ExamsManage(examsId); return(exams.SetDisable()); }