/// <summary> /// 初始化一个<see cref="ExamPagerQuestionBuildContext"/>对象实例 /// </summary> /// <param name="exam"></param> /// <param name="questions"></param> public ExamPagerQuestionBuildContext(Data.Entity.Exams exam, IEnumerable <Data.Entity.Questions> questions) { Exam = exam; Questions = questions; currentQuestions = new List <ExamPaperQuestion>(); nextSort = 1; }
/// <summary> /// 初始化一个<see cref="ExamsManage"/>对象实例 /// </summary> /// <param name="exams">考卷数据对象</param> public ExamsManage(Data.Entity.Exams exams) { if (exams != null) { this.exams = exams; ID = exams.ExamId; } }
/// <summary> /// 保存考卷 /// </summary> /// <returns></returns> public bool Save() { ThrowExceptionIfValidateFailure(); var exam = new Data.Entity.Exams { ExamId = ID, UserId = Request.UserId, ExamType = Request.ExamType, Title = Request.Title, Questions = Request.Questions, CourseIds = Request.CourseIds, Remarks = Request.Remarks, Time = Request.Time, Pass = Request.Pass, Total = Request.Total, Status = (int)Status, Radio = Request.Radio, RedioTotal = Request.RedioTotal, Multiple = Request.Multiple, MultipleTotal = Request.Multiple, Judge = Request.Judge, JudgeTotal = Request.JudgeTotal, Filling = Request.Filling, FillingTotal = Request.FillingTotal, Ask = Request.Ask, AskTotal = Request.AskTotal, CreateTime = DateTime.Now, StartTime = Request.StartTime, EndTime = Request.EndTime, Answers = 0, UseCount = 0 }; return(ExamsAccessor.Insert(exam)); }
/// <summary> /// 生成一个新考卷对象 /// </summary> /// <param name="state"></param> private Data.Entity.Exams CreateNewExamsFor(ExamsModifyState state) { var newExams = new Data.Entity.Exams { //不可修改内容 ExamId = ID, Answers = Exams.Answers, CreateTime = Exams.CreateTime, Status = Exams.Status, UseCount = Exams.Status, UserId = Exams.UserId, //以下为修改内容 ExamType = state.ExamType, CourseIds = state.CourseIds, Title = state.Title, Remarks = state.Remarks, Questions = state.Questions, Time = state.Time, Total = state.Total, Pass = state.Pass, Radio = state.Radio, RedioTotal = state.RedioTotal, Multiple = state.Multiple, MultipleTotal = state.MultipleTotal, Judge = state.Judge, JudgeTotal = state.JudgeTotal, Filling = state.Filling, FillingTotal = state.FillingTotal, Ask = state.Ask, AskTotal = state.AskTotal, StartTime = state.StartTime, EndTime = state.EndTime }; return(newExams); }