protected virtual IndexPageViewModel CreateIndexPageViewModel(int page, SheetFilterViewModel filter = null) { var model = new IndexPageViewModel(); var claim = User.Claims.FirstOrDefault(x => x.Type.Equals(Constants.Claims.ReferenceId)); var sheetFilter = CreateFilter(filter, claim.Value); var totalCount = ExamSheetManager.GetTotal(sheetFilter); model.Page = new PageViewModel(totalCount, page, PageSize); model.ExamSheets = ExamSheetManager.FindAll(sheetFilter, page, PageSize).Select(ExamSheetListViewModel).ToList(); model.Filter = CreateFilterModel(claim.Value, filter); return(model); }
//TODO: mock exam sheet data protected virtual void GenerateData(string subjectId, int notPass, int low, int middle, int high) { var sheets = ExamSheetManager.FindAll(); var mmdo = sheets.Where(x => x.SubjectId.Equals(subjectId) && x.State == Business.ExamSheet.ExamSheetState.Open).ToList(); var rand = new Random(DateTime.Now.Millisecond); foreach (var sheet in mmdo) { var students = StudentManager.FindGroup(sheet.GroupId); var ratings = new List <RatingModel>(); foreach (var st in students) { var rating = new RatingModel() { ExamSheetId = sheet.Id, StudentId = st.Id }; var prob = rand.Next(0, 100); if (prob <= notPass) { rating.Mark = (short)rand.Next(0, 59); } else if (prob > notPass && prob <= (notPass + low)) { rating.Mark = (short)rand.Next(60, 73); } else if (prob > (notPass + low) && prob <= (notPass + low + middle)) { rating.Mark = (short)rand.Next(74, 89); } else if (prob > (notPass + low + middle) && prob <= (notPass + low + middle + high)) { rating.Mark = (short)rand.Next(90, 98); } ratings.Add(rating); } ExamSheetManager.CloseSheet(sheet.Id); RatingManager.SaveRatings(ratings); } }