private string GetOverallFromPoint() { ObservableCollection <CategoriesBox> tempCats = new ObservableCollection <CategoriesBox>(); double netWeight = 0; double tempOverall = 0; foreach (CategoriesBox cb1 in catBoxes) { tempOverall += cb1.Percent * cb1.Weight; if (cb1.Weight > 0 && cb1.CatPossible > 0) { CategoriesBox cbTemp = new CategoriesBox(); cbTemp.CatPoints = cb1.CatPoints; cbTemp.Percent = Math.Round(cb1.Percent, 2); cbTemp.CatPossible = cb1.CatPossible; cbTemp.Weight = cb1.Weight; cbTemp.Description = cb1.Description; cbTemp.WeightPercent = Math.Round((cbTemp.Percent * cbTemp.Weight), 2); cbTemp.DelWeight = cbTemp.Weight - cbTemp.WeightPercent; cbTemp.CatColor = ColorGet.ColorFromPercent((int)Math.Round(cbTemp.Percent * 100, 0)); tempCats.Add(cbTemp); netWeight += cb1.Weight; } } tempOverall = Math.Round((100 * tempOverall) / netWeight, 2); return(GradeFromScore.GetGrade(tempOverall)); }
private static void InitCatList() { if (catBoxes.Count > 0) { catBoxes.Clear(); Ot.OverallAll = 0; } int count = 0; foreach (CategoryInfo c in Globals.SelectedData.UCatInfoSet) { CategoriesBox b = new CategoriesBox(); b.Id = count; b.Weight = c.Weight; b.Description = c.Description; catBoxes.Add(b); count += 1; } }
private void InitList() { Cats.Clear(); this.Title = Globals.SelectedData.CourseName; AssList.ItemsSource = Asses; int count = 0; foreach (CategoryInfo c in Globals.SelectedData.UCatInfoSet) { CategoriesBox b = new CategoriesBox(); b.Id = count; b.Weight = c.Weight; b.Description = c.Description; catBoxes.Add(b); Cats.Add(c.Description); count += 1; } }
private static void UpdateOverallScore() { chart.SuspendSeriesNotification(); double netWeight = 0; CatsOverall.Clear(); List <CategoryInfo> unboundCats = Globals.SelectedData.UCatInfoSet; InitCatList(); foreach (Assignments a in Asses) { if (a.Grade != "" && a.Grade != "NG" && a.Grade != "X") { foreach (CategoriesBox cb1 in catBoxes) { if (cb1.Description == a.AssignmentType) { if (a.Grade == "Z") { a.Points = 0; } cb1.CatPossible += a.Possible; cb1.CatPoints += a.Points; cb1.Percent = (cb1.CatPoints / cb1.CatPossible); break; } } } } ObservableCollection <CategoriesBox> tempCats = new ObservableCollection <CategoriesBox>(); foreach (CategoriesBox cb1 in catBoxes) { Ot.OverallAll += cb1.Percent * cb1.Weight; if (cb1.Weight > 0 && cb1.CatPossible > 0) { CategoriesBox cbTemp = new CategoriesBox(); cbTemp.CatPoints = cb1.CatPoints; cbTemp.Percent = Math.Round(cb1.Percent, 2); cbTemp.CatPossible = cb1.CatPossible; cbTemp.Weight = cb1.Weight; cbTemp.Description = cb1.Description; cbTemp.WeightPercent = Math.Round((cbTemp.Percent * cbTemp.Weight), 2); cbTemp.DelWeight = cbTemp.Weight - cbTemp.WeightPercent; cbTemp.CatColor = ColorGet.ColorFromPercent((int)Math.Round(cbTemp.Percent * 100, 0)); tempCats.Add(cbTemp); netWeight += cb1.Weight; } } Ot.OverallAll = Math.Round((100 * Ot.OverallAll) / netWeight, 2); if (catBoxes.Count >= 2) { if (tempCats.Count >= 2) { CategoriesBox overall = new CategoriesBox(); overall.Percent = Ot.OverallAll; overall.Weight = 100; overall.Description = "Overall"; overall.WeightPercent = overall.Percent; overall.CatColor = ColorGet.ColorFromPercent((int)Math.Round(Ot.OverallAll, 0)); tempCats.Add(overall); } } ColorModel.Palette = ChartColorPalette.Custom; ChartColorCollection cmc = new ChartColorCollection(); foreach (CategoriesBox cv in tempCats) { cmc.Add(cv.CatColor); } ColorModel.CustomBrushes = cmc; Ot.OverallColor = ColorGet.ColorFromPercent((int)Math.Round(Ot.OverallAll, 0)); Ot.CatsOverall = tempCats; chart.ResumeSeriesNotification(); }