Пример #1
0
        public void AddStudentIntoWorkGroupOfaCourse() //this method will add a student into a workgroup and update the data file.This method will be called in administrator
        {
            bool workGroupExist = false;

            foreach (WorkGroup group in allGroups)
            {
                workGroupExist = true;
            }
            if (workGroupExist == true)
            {
                Person person = Program.GetPerson();  //call of the function to find a person and verify if it is a student
                if (person is Student)
                {
                    Student student = person as Student;
                    Console.WriteLine();
                    if (dataFileMarks.IsThePersonAlreadyIn(student.ID) == false && dataFileAttendance.IsThePersonAlreadyIn(student.ID) == false) //we want to verify if the student is already in a group or not
                    {
                        Console.WriteLine("status of the workGroup in this course: " + name);
                        foreach (WorkGroup group in allGroups)
                        {
                            try
                            {
                                Console.WriteLine(group.name + " " + "there is  " + group.members.Count + " students in this group the professor is: " + group.professor.name + " " + group.professor.surname);
                            }
                            catch
                            {
                                Console.WriteLine(group.name + " " + "there is  " + group.members.Count + " students in this group ");
                            }
                        }
                        bool   correctName = false;
                        string info        = "";
                        while (correctName == false && info != "exit")
                        {
                            Console.WriteLine("In wich group add the student? type the name of the group or type: exit");
                            info = Console.ReadLine();
                            foreach (WorkGroup group in allGroups)
                            {
                                if (group.name == info)
                                {
                                    correctName = true;
                                    group.members.Add(student);
                                    dataFileMarks.AddStudentInWorkGroup(student, info);      //add the student in the csv file with its workgroup name
                                    dataFileAttendance.AddStudentInWorkGroup(student, info); //add the student in the csv file with its workgroup name
                                    Console.WriteLine("the student has been hadded to the workGroup " + group.name);
                                    Console.WriteLine();
                                }
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("The person you have chosen is not a student");
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("there is no workgroup in this course. Create a workgroup before to add student in it.");
                Console.WriteLine();
            }
            allGroups = RebuildFromFiles(dataFileMarks);//actualizes the changes in the list of workgroup
        }