Beispiel #1
0
        public static bool AddSubject(string given_subject_name, string given_teacher, SubjectColor given_color, int given_id = 0)
        {
            bool erfolgreich;

            if (given_color == null)
            {
                given_color = SubjectColorManager.GetList().Find(x => x.color == Colors.Black);
            }

            if (given_subject_name != "" && given_color != null)
            {
                Subject new_subject = new Subject()
                {
                    subject_name = given_subject_name, teacher = given_teacher, color = given_color
                };
                if (given_id == 0)
                {
                    new_subject.id = SubjectManager.FreeId();
                }
                else
                {
                    new_subject.id = given_id;
                }
                MyData.my_subjects_list.Add(new_subject);
                erfolgreich = true;
            }
            else
            {
                not_completed_dialog(); erfolgreich = false;
            }

            return(erfolgreich);
        }
Beispiel #2
0
        public async void cdg_DeleteSubject()
        {
            ContentDialog deletesubject = new ContentDialog()
            {
                Title               = "Fach löschen?",
                Content             = "Wenn du dieses Fach löschst, werden alle damit verbundenen Daten wie Noten, Stundenplaneinträge, etc. verloren gehen!",
                PrimaryButtonText   = "Abbrechen",
                SecondaryButtonText = "Bestätigen"
            };

            ContentDialogResult result = await deletesubject.ShowAsync();


            if (result == ContentDialogResult.Secondary)
            {
                Subject selected_subject = subject_to_show;
                SubjectManager.DeleteSubject(SubjectManager.selected_subject_id);
                Frame.Navigate(typeof(Subjects));
            }
        }
Beispiel #3
0
 public void DeleteSubject()
 {
     SubjectManager.DeleteSubject(this.id);
 }
Beispiel #4
0
        public static decimal GetAverage(int subject_id)
        {
            decimal      allclassworks         = 0;
            decimal      allnormaltests        = 0;
            decimal      average               = 0;
            decimal      allclassworksaverage  = 0;
            decimal      allnormaltestsaverage = 0;
            List <Grade> classwork_list        = new List <Grade> {
            };
            List <Grade> normaltest_list       = new List <Grade> {
            };

            Subject actual_subject = SubjectManager.GetSubject(subject_id);

            foreach (Grade grade in actual_subject.grades)
            {
                if (grade.type.typename == "classwork")
                {
                    classwork_list.Add(grade);
                }
                if (grade.type.typename == "normaltest")
                {
                    normaltest_list.Add(grade);
                }
            }

            foreach (Grade grade in classwork_list)
            {
                allclassworks += grade.grade;
            }
            foreach (Grade grade in normaltest_list)
            {
                allnormaltests += grade.grade;
            }

            if (allclassworks != 0)
            {
                allclassworksaverage = allclassworks / classwork_list.Count();
            }
            if (allnormaltests != 0)
            {
                allnormaltestsaverage = allnormaltests / normaltest_list.Count();
            }

            if (allclassworksaverage != 0 && allnormaltestsaverage != 0)
            {
                average = (allclassworksaverage + allnormaltestsaverage) / 2;
            }
            else
            {
                if (allclassworksaverage == 0 && allnormaltestsaverage != 0)
                {
                    average = allnormaltestsaverage;
                }
                if (allnormaltestsaverage == 0 && allclassworksaverage != 0)
                {
                    average = allclassworksaverage;
                }
            }

            average = Math.Round(average, 2);

            return(average);
        }
Beispiel #5
0
 public SubjectDetail()
 {
     this.InitializeComponent();
     subject_to_show = SubjectManager.GetSubject(SubjectManager.selected_subject_id);
 }