public Course(string name, string yeargrade, string filepath1, string filepath2) //this constructor is used when the course is recreated from csv file { this.yearGrade = yeargrade; this.dataFileAttendance = new Database_Attendance(name, filepath2); this.dataFileMarks = new Database_Marks(name, filepath1); allGroups = RebuildFromFiles(dataFileMarks); this.name = dataFileMarks.courseName; }
public Course(string _name, string yeargrade) //this constructor is used when it is the first time a course is created { this.name = _name; this.yearGrade = yeargrade; this.allGroups = new List <WorkGroup>(); this.dataFileMarks = CreateCsvFileMarks(name); this.dataFileAttendance = CreateCsvFileAttendance(name); AddWrkGroupToCourse(); AddStudentIntoWorkGroupOfaCourse(); }
public List <WorkGroup> RebuildFromFiles(Database_Marks marks) //this function enables to rebuilt a course from a csv file. { List <List <string> > data = marks.ReturnDatas(); List <string> workGroupName = new List <string>(); //this list is temporary and used in order to create the correct wkgp and not 2x the same one List <WorkGroup> everyWorkGroup = new List <WorkGroup>(); foreach (List <string> personInfo in data) { if (workGroupName.Contains(personInfo[3]) == false) { workGroupName.Add(personInfo[3]); WorkGroup group = new WorkGroup(personInfo[3]); try { if (personInfo[4] != null && personInfo[5] != null) { Teacher teacher = Program.GetPerson(personInfo[4], personInfo[5]) as Teacher; group.professor = teacher; //at this point, the workgroup and its teacher is generated } } catch { } everyWorkGroup.Add(group); } Person person = Program.GetPerson(personInfo[2]); { if (person is Student) { Student student = person as Student; foreach (WorkGroup wkgp in everyWorkGroup) { if (wkgp.name == personInfo[3]) { wkgp.members.Add(student); //at this point the student is added inside its workgroup student.group.Add(wkgp); student.courseList.Add(name); //the course is added to the student course list } } } } } return(everyWorkGroup); //should get the list of all WorkGroup in it }
//public Database_Marks CreateCsvFileMarks(string courseName) //{ // Console.WriteLine("type the string path of the new file. Don't type .csv at the end, it is automatic"); // string path = Console.ReadLine(); // dataFileMarks = new Database_Marks(name + "dataFileMarks", path+".csv"); // Console.WriteLine(); // return dataFileMarks; //} public Database_Marks CreateCsvFileMarks(string courseName) { dataFileMarks = new Database_Marks(courseName, courseName + "_dataFileMarks.csv"); Console.WriteLine(); return(dataFileMarks); }
public Course(Database_Marks datafileMark, Database_Attendance datafileAttendance) //this constructor is used when the course is recreated from csv file { allGroups = RebuildFromFiles(datafileMark); this.name = datafileMark.courseName; this.dataFileAttendance = datafileAttendance; }