public StudentgroupStudents(ExportLessons exportlesson)
        {
            using (StreamReader reader = new StreamReader(Global.InputStudentgroupStudentsCsv))
            {
                string überschrift = reader.ReadLine();

                while (true)
                {
                    string line = reader.ReadLine();

                    if (line != null)
                    {
                        StudentgroupStudent studentgroupStudent = new StudentgroupStudent(line, exportlesson);
                        if (studentgroupStudent.StartDate < DateTime.Now)
                        {
                            this.Add(studentgroupStudent);
                        }
                    }

                    if (line == null)
                    {
                        break;
                    }
                }
                Console.WriteLine(("StudentgroupStudents " + ".".PadRight(this.Count / 500, '.')).PadRight(48, '.') + (" " + this.Count).ToString().PadLeft(30), '.');
            }
        }
        public StudentgroupStudent(string line, ExportLessons exortlessons)
        {
            var x = line.Split('\t');

            StudentId    = Convert.ToInt32(x[0]);
            Name         = x[1];
            Forename     = x[2];
            Studentgroup = x[3];
            Subject      = x[4];
            StartDate    = (from e in exortlessons where e.Studentgroup == Studentgroup select e.StartDate).FirstOrDefault();
            EndDate      = (from e in exortlessons where e.Studentgroup == Studentgroup select e.EndDate).FirstOrDefault();
        }
示例#3
0
        internal void Unterrichte()
        {
            ExportLessons        exportLessons        = new ExportLessons();
            StudentgroupStudents studentgroupStudents = new StudentgroupStudents(exportLessons);
            Noten noten = new Noten();

            Sortierung sortierung = new Sortierung();

            foreach (var schueler in this)
            {
                // Alle Unterrichte ohne Studentgroup seiner Klasse werden zugeordnet

                foreach (var e in exportLessons)
                {
                    if (e.Klassen.Split('~').Contains(schueler.Klasse.NameUntis) &&
                        e.Teacher != null &&
                        e.Teacher != "" &&
                        e.Subject != null &&
                        e.Subject != "" &&
                        !Global.ZuIgnorierendeFächer.Contains(e.Subject) &&
                        e.StartDate < DateTime.Now &&
                        e.Studentgroup == "")
                    {
                        // Wenn es noch keine Note für das Fach gibt

                        if (!(from n in noten
                              where n.Fach == e.Subject
                              where n.StudentId == schueler.Id
                              select n).Any())
                        {
                            // ... und das Fach mit diesem Lehrer auch noch nicht existiert

                            if (!(from s in schueler.Fächer
                                  where s.Lehrerkürzel == e.Teacher
                                  where s.KürzelUntis == e.Subject
                                  select s).Any())
                            {
                                schueler.Fächer.Add(new Fach(
                                                        schueler.Id,
                                                        schueler.Klasse.NameUntis,
                                                        e.Subject,
                                                        e.Teacher,
                                                        null,
                                                        sortierung
                                                        ));
                            }
                        }

                        // Wenn es mehr als eine Note für das selbe Fach vom selben Kollegen gibt.
                        foreach (var note in (from n in noten
                                              where n.Fach == e.Subject
                                              where n.StudentId == schueler.Id
                                              select n).ToList())
                        {
                            // ... und es das Fach mit dieser Note noch nicht gibt ...

                            if (!(from s in schueler.Fächer
                                  where s.KürzelUntis == e.Subject
                                  where s.Note == note.PrüfungsartNote
                                  select s).Any())
                            {
                                // ... wird es erneut angelegt

                                if (!(from f in schueler.Fächer
                                      where f.KürzelUntis == note.Fach
                                      where f.Lehrerkürzel == note.LehrerKürzel
                                      where f.Note == note.PrüfungsartNote
                                      select f).Any())
                                {
                                    if (e.StartDate < DateTime.Now)
                                    {
                                        schueler.Fächer.Add(new Fach(
                                                                schueler.Id,
                                                                schueler.Klasse.NameUntis,
                                                                e.Subject,
                                                                e.Teacher,
                                                                note,
                                                                sortierung
                                                                ));
                                    }
                                }
                            }
                        }
                    }
                }

                // Alle Gruppen werden zu Unterrichten

                foreach (var s in studentgroupStudents)
                {
                    if (s.StudentId == schueler.Id &&
                        s.Subject != null &&
                        s.Subject != "" &&
                        s.StartDate < DateTime.Now)
                    {
                        // Wenn es noch keine Note für das Fach gibt

                        if (!(from n in noten
                              where n.Fach == s.Subject
                              where n.StudentId == schueler.Id
                              select n).Any())
                        {
                            if (!(from f in schueler.Fächer
                                  where f.Lehrerkürzel == (from e in exportLessons
                                                           where e.Studentgroup == s.Studentgroup
                                                           where e.Subject == s.Subject
                                                           where !Global.ZuIgnorierendeFächer.Contains(e.Subject)
                                                           select e.Teacher).FirstOrDefault()
                                  where f.KürzelUntis == s.Subject
                                  select f).Any())
                            {
                                // Fächer, die erst in der Zukunft beginnen, weil Sie extra für die Prüfung angelegt wurde, werden ignoriert.

                                if (s.StartDate < DateTime.Now)
                                {
                                    schueler.Fächer.Add(new Fach(
                                                            schueler.Id,
                                                            schueler.Klasse.NameUntis,
                                                            s.Subject,
                                                            (from e in exportLessons
                                                             where e.Studentgroup == s.Studentgroup
                                                             where e.Subject == s.Subject
                                                             select e.Teacher).FirstOrDefault(),
                                                            null,
                                                            sortierung
                                                            ));
                                }
                            }
                        }

                        // Wenn es mehr als eine Note für das selbe Fach vom selben Kollegen gibt.
                        foreach (var note in (from n in noten
                                              where n.Fach == s.Subject
                                              where n.StudentId == schueler.Id
                                              select n).ToList())
                        {
                            // ... und es das Fach mit dieser Note noch nicht gibt wird es ...

                            if (!(from f in schueler.Fächer
                                  where f.KürzelUntis == s.Subject
                                  where f.Note == note.PrüfungsartNote
                                  select f).Any())
                            {
                                // ... sofern das Fach mit diesem Kollegen und dieser Note nicht schon existiert ...

                                if (!(from f in schueler.Fächer
                                      where f.KürzelUntis == note.Fach
                                      where f.Lehrerkürzel == note.LehrerKürzel
                                      where f.Note == note.PrüfungsartNote
                                      select f).Any())
                                {
                                    // ... angelegt.

                                    if (s.StartDate < DateTime.Now)
                                    {
                                        schueler.Fächer.Add(new Fach(
                                                                schueler.Id,
                                                                schueler.Klasse.NameUntis,
                                                                s.Subject,
                                                                note.LehrerKürzel,
                                                                note,
                                                                sortierung
                                                                ));
                                    }
                                }
                            }
                        }
                    }
                }

                // Prüfung, ob es noch Noten ohne Unterricht gibt. Das ist der Fall, wenn Fächer nach der Unterstuf nicht fortgeführt wurden.

                foreach (var note in noten)
                {
                    if (note.StudentId == schueler.Id && (note.Fach.StartsWith("BI") || note.Fach.StartsWith("PH")))
                    {
                        if (!(from f in schueler.Fächer where f.KürzelUntis == note.Fach select f).Any())
                        {
                            Console.WriteLine(schueler.Klasse.NameUntis + " " + schueler.Nachname + " hat eine Note in " + note.Fach + " bekommen, aber dieses Fach nicht im Unterricht.");

                            schueler.Fächer.Add(new Fach(
                                                    schueler.Id,
                                                    schueler.Klasse.NameUntis,
                                                    note.Fach + "*",
                                                    note.LehrerKürzel,
                                                    note,
                                                    sortierung
                                                    ));
                        }
                    }
                }
            }
        }