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));
        }
Exemple #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double val = (double)value;
            Color  col = ColorGet.ColorFromPercent((int)Math.Round(val, 0));

            return(col);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double percent = (double)value;

            if (targetType.Name == "String")
            {
                return(percent.ToString());
            }
            return(ColorGet.ColorFromPercent((int)Math.Round(percent, 0)));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            List <CategoryInfo> cats = new List <CategoryInfo>();
            double d   = 0;
            int    par = (int)parameter;

            switch (par)
            {
            case 1:
            {
                cats = (List <CategoryInfo>)value;
                switch (cats.Count)
                {
                case 1:
                    return(0.25);

                case 2:
                    return(0.7);

                case 3:
                    return(0.6);

                case 4:
                    return(0.55);

                default:
                    return(0.4);
                }
            }

            case 2:
            {
                cats = (List <CategoryInfo>)value;
                switch (cats.Count)
                {
                case 1:
                    return(60);

                case 2:
                    return(45);

                case 3:
                    return(27);

                default:
                    return(17);
                }
            }

            case 3:
                d = (double)value;
                return(ColorGet.ColorFromPercent((int)Math.Round(d, 0)));

            case 4:
            {
                cats = (List <CategoryInfo>)value;
                ChartColorModel cm = new ChartColorModel();
                cm.Palette = ChartColorPalette.Custom;
                ChartColorCollection cmc = new ChartColorCollection();
                foreach (CategoryInfo ci in cats)
                {
                    cmc.Add(ColorGet.ColorFromPercent((int)Math.Round(ci.Percent, 0)));
                }
                cm.CustomBrushes = cmc;
                return(cm);
            }

            default:
                return(10);

            case 5:
            {
                cats = (List <CategoryInfo>)value;
                switch (cats.Count)
                {
                case 1:
                    return(40);

                case 2:
                    return(30);

                case 3:
                    return(20);

                default:
                    return(10);
                }
            }

            case 6:
            {
                d = (double)value;
                if (d < 20)
                {
                    return(new Thickness(0, -20));
                }
                return(-1);
            }

            case 7:
            {
                d  = (double)value;
                d *= 100;
                Console.WriteLine("Color double=>" + d);
                return(ColorGet.ColorFromPercent((int)Math.Round(d, 0)));
            }
            }
        }
        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();
        }
Exemple #6
0
        private static async Task SetDataset()
        {
            var TempClass = await StoreClassesAsync();

            var TermsData = await GetTermsAsync();

            Globals.TermsData             = TermsData;
            ClientInitializor.CurrentTerm = TermsData[TermsData.Count - 1].Code;
            foreach (Classes c in TempClass)
            {
                Data obj = new Data();

                obj.StudentName = c.Student;
                obj.SectionCode = c.SectionId;

                String name = c.CourseName;
                if (name.Contains("AP "))
                {
                    obj.ClassType  = "AP";
                    obj.CourseName = name.Replace("AP ", "");
                }
                else if (name.Contains("HON "))
                {
                    obj.ClassType  = "HON";
                    obj.CourseName = name.Replace("HON ", "");
                }
                else if (name.Contains("ADV "))
                {
                    obj.ClassType  = "ADV ";
                    obj.CourseName = name.Replace("ADV ", "");
                }
                else
                {
                    obj.ClassType  = "REG";
                    obj.CourseName = name;
                }

                obj.TermCode = c.Termid;
                foreach (Terms t in TermsData)
                {
                    if (t.Code == obj.TermCode)
                    {
                        obj.TermName = t.Termname;
                    }
                }

                obj.OverallGrade = c.OverallGrade;

                obj.OverallPercent = await GetSubjectOverview(c.SectionId, c.Termid);

                obj.OverallColor = ColorGet.ColorFromPercent((int)Math.Round(obj.OverallPercent, 0));

                obj.TeachersName  = c.Teacher;
                obj.TeachersEmail = c.Email_Addr;
                obj.Period        = c.Period;

                var Cats = await SetCategoriesDataAsync(c.SectionId, c.Termid);

                foreach (CategoryInfo cats1 in Cats)
                {
                    cats1.WeightPercent = (cats1.Percent * cats1.Weight) / 100;
                }

                var Asss = await SetAssignmentsData(c.SectionId, c.Termid);

                foreach (Assignments asses in Asss)
                {
                    asses.AssignmentType = Regex.Replace(asses.AssignmentType, "[^a-zA-Z]", "");
                    if (asses.Points == 0)
                    {
                        if (asses.Grade == "")
                        {
                            asses.Grade = "NG";
                        }
                        else
                        {
                            if (asses.Grade != "X")
                            {
                                asses.Grade = "Z";
                            }
                        }
                    }
                    if (Math.Abs(asses.Possible) > 0)
                    {
                        asses.Percent = (asses.Points / asses.Possible) * 100;
                    }
                    else
                    {
                        asses.Percent = 100;
                    }
                }

                for (int i = 0; i < Asss.Count; i++)
                {
                    Asss[i].Id = i;
                }
                foreach (Assignments asses in Asss)
                {
                    int counter = 0;
                    foreach (CategoryInfo cats2 in Cats)
                    {
                        if (cats2.Description == asses.AssignmentType)
                        {
                            asses.CatIndex = counter;
                            asses.Weight   = cats2.Weight;
                        }
                        counter += 1;
                    }
                    if (asses.AssignmentType.Contains("Ungraded"))
                    {
                        asses.AssignmentType = "Ungraded";
                        asses.Weight         = 0;
                        asses.CatIndex       = (counter);
                    }

                    asses.BackColor = ColorGet.ColorFromPercent((int)Math.Round(asses.Percent, 0));
                }
                if (Asss.Where(x => x.AssignmentType.Contains("Ungraded")).Count() > 0)
                {
                    CategoryInfo uCat = new CategoryInfo();
                    uCat.Description = "Ungraded";
                    uCat.Weight      = 0;
                    Cats.Add(uCat);
                }

                obj.NoOfCat     = Cats.Count;
                obj.UCatInfoSet = Cats;

                List <CategoryInfo> tempCats = new List <CategoryInfo>();
                foreach (CategoryInfo cats3 in Cats)
                {
                    if (cats3.PointsPossible != 0)
                    {
                        tempCats.Add(cats3);
                    }
                }
                if (tempCats.Count > 1)
                {
                    CategoryInfo finalCat = new CategoryInfo();
                    finalCat.Description   = "Overall";
                    finalCat.Percent       = obj.OverallPercent;
                    finalCat.Weight        = 100;
                    finalCat.WeightPercent = obj.OverallPercent;
                    tempCats.Add(finalCat);
                }

                foreach (Assignments asses in Asss)
                {
                    if (asses.Grade != "" && asses.Grade != "NG" && asses.Grade != "X")
                    {
                        if (asses.Points == 0)
                        {
                            if (asses.Possible > 0)
                            {
                                asses.Grade = "Z";
                            }
                        }
                        else
                        {
                            if (asses.Grade != "X")
                            {
                                asses.Grade = "Graded";
                            }
                        }
                    }
                }

                obj.CatInfoSet = tempCats;

                obj.AssignmentsList = Asss;

                Globals.Dataset.Add(obj);
            }
        }
Exemple #7
0
 void SetNewOverallColor()
 {
     OverallColor = ColorGet.ColorFromPercent((int)Math.Round(OverallPercent, 0));
 }