protected virtual void SaveOrUpdate(ExamSheetViewModel model) { var businessModel = CreateModel(model); ExamSheetManager.Save(businessModel); //TODO: generate word doc and save it }
public IActionResult ViewSheet(string id) { var examSheet = ExamSheetManager.GetById(id); var model = CreateClosedSheet(examSheet); return(View(model)); }
public IActionResult Edit(string id) { var examSheet = ExamSheetManager.GetById(id); var model = CreateViewModel(examSheet); return(View(model)); }
public IActionResult Edit(string id) { var examSheet = ExamSheetManager.GetById(id); var model = CreateViewModel(examSheet); InitSelectItems(model.Faculty.Id); return(View(model)); }
public virtual IActionResult Delete(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index", "Home")); } ExamSheetManager.Remove(id); return(Json(1)); }
public ChartController(ExamSheetManager examSheetManager, RatingManager ratingManager, GroupManager groupManager, SubjectManager subjectManager, StudentManager studentManager, DeaneryManager deaneryManager, TeacherManager teacherManager) { ExamSheetManager = examSheetManager; RatingManager = ratingManager; GroupManager = groupManager; SubjectManager = subjectManager; StudentManager = studentManager; DeaneryManager = deaneryManager; TeacherManager = teacherManager; }
public TeacherSheetController(ExamSheetManager examSheetManager, TeacherManager teacherManager, FacultyManager facultyManager, GroupManager groupManager, SubjectManager subjectManager, StudentManager studentManager, RatingManager ratingManager) { ExamSheetManager = examSheetManager; TeacherManager = teacherManager; FacultyManager = facultyManager; GroupManager = groupManager; SubjectManager = subjectManager; StudentManager = studentManager; RatingManager = ratingManager; }
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); }
public HomeController(ExamSheetManager examSheetManager, FacultyManager facultyManager, GroupManager groupManager, SubjectManager subjectManager, TeacherManager teacherManager, DeaneryManager deaneryManager, StudentManager studentManager, RatingManager ratingManager) { this.ExamSheetManager = examSheetManager; this.FacultyManager = facultyManager; this.GroupManager = groupManager; this.SubjectManager = subjectManager; this.TeacherManager = teacherManager; this.DeaneryManager = deaneryManager; this.StudentManager = studentManager; this.RatingManager = ratingManager; }
public IActionResult Edit(TeacherSheetViewModel model, string save, string saveAndClose) { bool shouldClose = !string.IsNullOrEmpty(saveAndClose); var valid = ModelState.IsValid && (shouldClose && ExamSheetManager.CloseSheet(model.Id) || !shouldClose); if (!valid) { var examSheet = ExamSheetManager.GetById(model.Id); return(View("Edit", CreateViewModel(examSheet))); } RatingManager.SaveRatings(model.Ratings?.Select(CreateRatingModel)); return(RedirectToAction("Index")); }
public IActionResult GetChartData(string group, string subject, short year, short semester, string teacher) { var sheet = ExamSheetManager.Get(group, teacher, subject, year, semester, true); var model = new GroupChartJsonModel(); if (sheet == null) { return(Json(model)); } var semesterMarks = new Dictionary <string, short>(); var rangeMarks = new Dictionary <string, short>(); var ratings = RatingManager.FindAll(sheet.Id); model.StudentsRating = new List <StudentRating>(); foreach (var rating in ratings) { var stringRepresentation = RatingMapper.MapRatingToString(rating.Mark); var rangeRepresentation = RatingMapper.MapRatingToRange(rating.Mark); if (semesterMarks.ContainsKey(stringRepresentation)) { semesterMarks[stringRepresentation] = (short)(semesterMarks[stringRepresentation] + 1); } else { semesterMarks[stringRepresentation] = 1; } if (rangeMarks.ContainsKey(rangeRepresentation)) { rangeMarks[rangeRepresentation] = (short)(rangeMarks[rangeRepresentation] + 1); } else { rangeMarks[rangeRepresentation] = 1; } var student = StudentManager.GetById(rating.StudentId); model.StudentsRating.Add(new StudentRating() { Surname = student.Surname, Name = student.Name, Rating = rating.Mark, StringRepresentation = stringRepresentation }); } var sorted = semesterMarks.OrderBy(key => key.Key); model.SemesterMarks = sorted.ToDictionary((keyItem) => keyItem.Key, (valueItem) => valueItem.Value); sorted = rangeMarks.OrderBy(key => key.Key); model.RangeMarks = sorted.ToDictionary((keyItem) => keyItem.Key, (valueItem) => valueItem.Value); model.StudentsRating = model.StudentsRating.OrderByDescending(x => x.Rating).ToList(); return(Json(model)); }
public IActionResult Edit(ExamSheetViewModel model) { if (!ModelState.IsValid) { InitSelectItems(model.Faculty.Id); return(View(model)); } var examSheet = ExamSheetManager.Get(model.GroupId, model.TeacherId, model.SubjectId, model.Year, model.Semester); if (examSheet != null && examSheet.Id != model.Id) { ModelState.AddModelError(string.Empty, "Така відомість вже існує!"); InitSelectItems(model.Faculty.Id); return(View(model)); } SaveOrUpdate(model); return(RedirectToAction("Index", "Home")); }
public IActionResult Subjects() { var referenceId = User.Claims.FirstOrDefault(x => x.Type.Equals(Constants.Claims.ReferenceId)); var deanery = DeaneryManager.GetById(referenceId.Value); var sheets = ExamSheetManager.FindClosedForFaculty(deanery.FacultyId); var subjectsIds = sheets.Select(x => x.SubjectId).Distinct().ToList(); var subjects = SubjectManager.GetByIdList(subjectsIds); var model = new SubjectStatisticViewModel(); model.SubjectList = new List <SelectListItem>(); foreach (var subject in subjects) { model.SubjectList.Add(new SelectListItem() { Text = subject.Name, Value = subject.Id }); } model.FacultyId = deanery.FacultyId; return(View(model)); }
public IActionResult Index() { var referenceId = User.Claims.FirstOrDefault(x => x.Type.Equals(Constants.Claims.ReferenceId)); var model = new GroupStatisticViewModel(); if (User.IsInRole(AccountType.Deanery)) { var deanery = DeaneryManager.GetById(referenceId.Value); var sheets = ExamSheetManager.FindClosedForFaculty(deanery.FacultyId); model = CreateGroupStatisticViewModel(sheets); } else if (User.IsInRole(AccountType.Teacher)) { var sheets = ExamSheetManager.FindClosedForTeacher(referenceId.Value); model = CreateGroupStatisticViewModel(sheets); model.TeacherId = referenceId.Value; } return(View(model)); }
public IActionResult GetSubjectData(string subject, string faculty) { var sheets = ExamSheetManager.Get(faculty, subject, true); var model = new SubjectChartJsonModel(); if (!sheets?.Any() ?? true) { return(Json(model)); } var ids = sheets.Select(x => x.Id); var groupedByYears = sheets.GroupBy(x => x.Year).OrderBy(x => x.Key); model.AverageRatings = new Dictionary <string, float>(); model.RatingFrequency = new Dictionary <short, short>(); var ratings = new List <RatingModel>(); foreach (var year in groupedByYears) { var groupedBySemesters = year.GroupBy(x => x.Semester).OrderByDescending(x => x.Key); foreach (var semester in groupedBySemesters) { var sum = 0; var count = 0; foreach (var item in semester) { ratings.AddRange(item.Ratings); sum += item.Ratings.Sum(x => x.Mark); count += item.Ratings.Count; } var average = sum / (float)count; var title = string.Format("{0} {1}", year.Key, semester.Key); model.AverageRatings.Add(title, average); } } foreach (var rating in ratings) { if (model.RatingFrequency.ContainsKey(rating.Mark)) { model.RatingFrequency[rating.Mark]++; } else { model.RatingFrequency.Add(rating.Mark, 1); } } var M = ratings.Sum(x => x.Mark) / ratings.Count; var D = ratings.Sum(x => Math.Pow(x.Mark - M, 2)) / (ratings.Count - 1); var sigma = Math.Sqrt(D); var size = 4; model.NormalDistributions = new Dictionary <short, double> [size]; for (int i = 0; i < size; ++i) { model.NormalDistributions[i] = new Dictionary <short, double>(); } var eScore = calcZScore(60, M, sigma); var cScore = calcZScore(74, M, sigma); var aScore = calcZScore(90, M, sigma); var eProbability = ZTable.GetProbability(eScore); var cProbability = ZTable.GetProbability(cScore); var aProbability = ZTable.GetProbability(aScore); var probFail = eProbability * 100; var probSatisfactorily = (cProbability - eProbability) * 100; var probGood = (aProbability - cProbability) * 100; var probExcellent = (1 - aProbability) * 100; model.NormalDistributionLabels = new List <string>() { string.Format("Ймовірність не здати предмет: {0}%", probFail.ToString("0.0")), string.Format("Ймовірність здати на 60-74: {0}%", probSatisfactorily.ToString("0.0")), string.Format("Ймовірність здати на 74-90: {0}%", probGood.ToString("0.0")), string.Format("Ймовірність здати на 90+: {0}%", probExcellent.ToString("0.0")) }; for (short i = 0; i < 100; ++i) { double func = (1 / (sigma * Math.Sqrt(2 * Math.PI))) * Math.Exp(-(Math.Pow((i - M), 2)) / (2 * sigma * sigma)); if (i < 60) { model.NormalDistributions[0].Add(i, func * 1000); } else if (i < 74) { model.NormalDistributions[1].Add(i, func * 1000); } else if (i < 90) { model.NormalDistributions[2].Add(i, func * 1000); } else { model.NormalDistributions[3].Add(i, func * 1000); } } return(Json(model)); }