Example #1
0
        public override string ToString()
        {
            string displaystudent = "";


            foreach (Student student in this._studentslist)
            {
                //Test if already have given evaluations to the student in the list
                if (student.is_evaluated == false)
                {
                    if (student.Matricule.ToString() == this._input)
                    {
                        string line;
                        System.IO.StreamReader evaluations = new System.IO.StreamReader("Evaluations.txt");
                        while ((line = evaluations.ReadLine()) != null)
                        {
                            string[] evaluation = line.Split(new Char[] { ';' });
                            //On each line of the document, the Student's matricule is the third element
                            if (evaluation[2] == student.Matricule.ToString())
                            {
                                if (this._activitieslist.Count == 0)
                                {
                                    ReturnActivities result = new ReturnActivities(this._teacherslist);
                                    this._activitieslist = result.List();
                                }


                                foreach (Activity eachactivity in this._activitieslist)
                                {
                                    //The "Code" of each Activity is the first element of each line of the document
                                    if (eachactivity.Code == evaluation[0])
                                    {
                                        int value;
                                        //Create different object given that evaluation can be string or number
                                        if (int.TryParse(evaluation[1], out value))
                                        {
                                            Cote cotestudent = new Cote(eachactivity,
                                                                        Convert.ToInt32(evaluation[1]));
                                            student.Add(cotestudent);
                                        }
                                        else
                                        {
                                            Appreciation studentappreciation = new Appreciation(eachactivity,
                                                                                                evaluation[1]);
                                            student.Add(studentappreciation);
                                        }
                                    }
                                }
                            }
                        }
                        displaystudent = student.Bulletin();
                    }
                }
                else
                {
                    if (student.Matricule.ToString() == this._input)
                    {
                        displaystudent += student.Bulletin();
                    }
                }
            }

            return(displaystudent);
        }
        public List <Student> Return(System.IO.StreamReader evaluations2, List <int> nameslines, List <Activity> activitieslist,
                                     List <Student> studentslist, List <Student> studentnames)
        {
            string line;
            int    countline = 0;

            while ((line = evaluations2.ReadLine()) != null)
            {
                //students.Add(line);
                if (countline > nameslines[0])
                {
                    for (int i = 0; i < nameslines.Count; i++)
                    {
                        if (i < (nameslines.Count - 1))
                        {
                            //on n'ajoute que les cours et pas les noms des eleves
                            if (countline > nameslines[i] & countline < nameslines[i + 1])
                            {
                                string[] evaluation = line.Split(new Char[] { ';' });
                                for (int k = 0; k < activitieslist.Count; k++)
                                {
                                    if (activitieslist[k].Code == evaluation[0])
                                    {
                                        int value;
                                        if (int.TryParse(evaluation[1], out value))
                                        {
                                            Cote cotestudent = new Cote(activitieslist[k],
                                                                        Convert.ToInt32(evaluation[1]));
                                            for (int n = 0; n < studentslist.Count; n++)
                                            {
                                                if (studentslist[n].Firstname == studentnames[i].Firstname &
                                                    studentslist[n].Lastname == studentnames[i].Lastname)
                                                {
                                                    studentslist[n].Add(cotestudent);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Appreciation studentappreciation = new Appreciation(activitieslist[k],
                                                                                                evaluation[1]);
                                            for (int n = 0; n < studentslist.Count; n++)
                                            {
                                                if (studentslist[n].Firstname == studentnames[i].Firstname &
                                                    studentslist[n].Lastname == studentnames[i].Lastname)
                                                {
                                                    studentslist[n].Add(studentappreciation);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //we just check if we're below a name 'cause it's the last student in the file
                        else
                        {
                            if (countline > nameslines[i])
                            {
                                string[] evaluation = line.Split(new Char[] { ';' });
                                for (int k = 0; k < activitieslist.Count; k++)
                                {
                                    if (activitieslist[k].Code == evaluation[0])
                                    {
                                        //check if the Evaluation is an integer to use as a 'Cote'
                                        int value;
                                        if (int.TryParse(evaluation[1], out value))
                                        {
                                            Cote cotestudent = new Cote(activitieslist[k], Convert.ToInt32(evaluation[1]));

                                            for (int n = 0; n < studentslist.Count; n++)
                                            {
                                                if (studentslist[n].Firstname == studentnames[i].Firstname &
                                                    studentslist[n].Lastname == studentnames[i].Lastname)
                                                {
                                                    studentslist[n].Add(cotestudent);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Appreciation studentappreciation = new Appreciation(activitieslist[k],
                                                                                                evaluation[1]);

                                            for (int n = 0; n < studentslist.Count; n++)
                                            {
                                                if (studentslist[n].Firstname == studentnames[i].Firstname &
                                                    studentslist[n].Lastname == studentnames[i].Lastname)
                                                {
                                                    studentslist[n].Add(studentappreciation);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                countline++;
            }

            return(studentslist);
        }