private void PrintStudents(Dictionary <string, double> studentsSorted)
 {
     foreach (var student in studentsSorted)
     {
         OutputWriter.PrintStudent(new KeyValuePair <string, double>(student.Key, student.Value));    //?
     }
 }
 private void PrintStudents(IDictionary <string, double> studentsSorted)
 {
     foreach (KeyValuePair <string, double> student in studentsSorted)
     {
         OutputWriter.PrintStudent(student);
     }
 }
Exemple #3
0
 public void PrintStudents(Dictionary <string, List <int> > studentsSorted)
 {
     foreach (var kv in studentsSorted)
     {
         OutputWriter.PrintStudent(kv);
     }
 }
Exemple #4
0
 private static void PrintStudents(Dictionary <string, List <int> > studentsSorted)
 {
     foreach (var keyValuepair in studentsSorted)
     {
         OutputWriter.PrintStudent(keyValuepair);
     }
 }
Exemple #5
0
 public static void GetStudentScoresFromCourse(string courseName, string username)
 {
     if (IsQueryForStudentPossiblе(courseName, username))
     {
         OutputWriter.PrintStudent(new KeyValuePair <string, List <int> >(username, studentByCourse[courseName][username]));
     }
 }
Exemple #6
0
 private void PrintStudents(Dictionary <string, double> sortedStudents)
 {
     foreach (var kvp in sortedStudents)
     {
         OutputWriter.PrintStudent(kvp);
     }
 }
Exemple #7
0
        /// <summary>
        /// Gets students but also does filtering query on them
        /// </summary>
        /// <param name="courseName"></param>
        /// <param name="sorting">Choose either Filtering or Ordering</param>
        /// <param name="criteria">Filtering - by performance, Sorting - Ascending, Descending</param>
        /// <param name="takeNumber">Amount of items to take</param>
        public void GetAllStudentsFromCourse(string courseName, SortingOperation sorting, string criteria = null, int takeNumber = -1)
        {
            if (sorting == SortingOperation.None)
            {
                GetAllStudentsFromCourse(courseName);
            }
            else if (IsQueryForCoursePossible(courseName))
            {
                //Extract the student names and their marks
                var studentsWithMarks = courses[courseName].StudentsByName.ToDictionary(k => k.Key, v => v.Value.MarksByCourseName[courseName]);

                if (sorting == SortingOperation.Filter)
                {
                    studentsWithMarks = filter.FilterAndTake(studentsWithMarks, criteria, takeNumber) as Dictionary <string, double>;
                }

                else if (sorting == SortingOperation.Order)
                {
                    studentsWithMarks = sorter.OrderAndTake(studentsWithMarks, criteria, takeNumber) as Dictionary <string, double>;
                }

                if (studentsWithMarks is null)
                {
                    return;
                }

                foreach (var student in studentsWithMarks)
                {
                    OutputWriter.PrintStudent(student);
                }
            }
        }
 public void GetStudentScoresFromCourse(string courseName, string studentName)
 {
     if (IsQueryForStudentPossible(courseName, studentName))
     {
         OutputWriter.PrintStudent(new KeyValuePair <string, double> (studentName, this.courses[courseName].StudentsByName[studentName].MarksByCourseName[courseName]));
     }
 }
 private void PrintStudents(Dictionary <string, double> studentsSorted)
 {
     foreach (var student in studentsSorted)
     {
         OutputWriter.PrintStudent(student);
     }
 }
 private static void PrintStudents(Dictionary <string, List <int> > sortedStudents)
 {
     foreach (KeyValuePair <string, List <int> > student in sortedStudents)
     {
         OutputWriter.PrintStudent(student);
     }
 }
Exemple #11
0
 public void GetStudentMarkInCourse(string courseName, string username)
 {
     if (this.IsQueryForStudentPossible(courseName, username))
     {
         OutputWriter.PrintStudent(new KeyValuePair <string, double>(username, this.coursesByName[courseName].StudentsByName[username].MarksByCourseName[courseName]));
     }
 }
 private void PrintStudents(Dictionary <string, double> studentsSorted)
 {
     foreach (var keyValuePair in studentsSorted)
     {
         OutputWriter.PrintStudent(keyValuePair);
     }
 }
 private static void PrintStudents(Dictionary <string, List <int> > studentsSorted)
 {
     foreach (var student in studentsSorted)
     {
         OutputWriter.PrintStudent(student);
     }
 }
 private void PrintStudents(Dictionary <string, double> sortedStudents)
 {
     foreach (KeyValuePair <string, double> pair in sortedStudents)
     {
         OutputWriter.PrintStudent(pair);
     }
 }
Exemple #15
0
 /// <summary>
 /// Will print the student of the course and his/hers scores
 /// </summary>
 /// <param name="courseName"></param>
 /// <param name="userName"></param>
 public void GetStudentScoresFromCourse(string courseName, string userName)
 {
     if (IsQueryForStudentPossible(courseName, userName))
     {
         var student = new KeyValuePair <string, double>(userName, students[userName].MarksByCourseName[courseName]);
         OutputWriter.PrintStudent(student);
     }
 }
 private void FilterAndTake(Dictionary <string, double> studentsWithMarks, Predicate <double> givenFilter, int studentsToTake)
 {
     foreach (KeyValuePair <string, double> pointsByUsername
              in studentsWithMarks
              .Where(p => givenFilter(p.Value))
              .Take(studentsToTake))
     {
         OutputWriter.PrintStudent(pointsByUsername);
     }
 }
Exemple #17
0
 /// <summary>
 /// Get students scores from given course.
 /// </summary>
 /// <param name="courseName"></param>
 /// <param name="username"></param>
 public void GetStudentScoresFromCourse(string courseName, string username)
 {
     if (this.IsQueryForStudentPossiblе(courseName, username) &&
         this.courses[courseName].StudentsByName.ContainsKey(username))
     {
         OutputWriter.PrintStudent(
             new KeyValuePair <string, double>(
                 username, this.courses[courseName].StudentsByName[username].MarksByCourseName[courseName]));
     }
 }
 public static void GetAllStudentsFromCourse(string courseName)
 {
     if (IsQueryForCoursePossible(courseName))
     {
         OutputWriter.WriteMessageOnNewLine($"{courseName}:");
         foreach (var studentsMarkEntry in studentsByCourse[courseName])
         {
             OutputWriter.PrintStudent(studentsMarkEntry);
         }
     }
 }
Exemple #19
0
 public void GetStudentsByCourse(string courseName)
 {
     if (this.IsQueryForCoursePossible(courseName))
     {
         OutputWriter.WriteMessageOnNewLine($"{courseName}:");
         foreach (var studentMarksEntry in this.coursesByName[courseName].StudentsByName)
         {
             OutputWriter.PrintStudent(new KeyValuePair <string, double>(studentMarksEntry.Key, studentMarksEntry.Value.MarksByCourseName[courseName]));
         }
     }
 }
 public static void GetAllStudentsFromCourse(string courseName)
 {
     if (IsQueryForCoursePossible(courseName))
     {
         OutputWriter.WriteMessageOnNewLine($"{courseName}:");
         foreach (KeyValuePair <string, List <int> > student in studentsByCourse[courseName])
         {
             OutputWriter.PrintStudent(student);
         }
     }
 }
 public void GetAllStudentsFromCourse(string courseName)
 {
     if (this.IsQueryForCoursePossible(courseName))
     {
         OutputWriter.WriteMessageOnNewLine($"{courseName}");
         foreach (var studetMarksEntry in this.studentByCourse[courseName])
         {
             OutputWriter.PrintStudent(studetMarksEntry);
         }
     }
 }
Exemple #22
0
 public void GetStudentScoresFromCourse(string courseName, string userName)
 {
     if (this.UserNameExists(userName, courseName))
     {
         OutputWriter.PrintStudent(new KeyValuePair <string, double>(userName, this.courses[courseName].StudentsByName[userName].MarksByCourseName[courseName]));
     }
     else
     {
         OutputWriter.WriteMessageOnNewLine($"Course '{courseName}' or user '{userName}' does not exist in database!");
     }
 }
Exemple #23
0
        private void OrderAndTake(IDictionary <string, double> wantedData, int studentsToTake,
                                  Func <KeyValuePair <string, double>, KeyValuePair <string, double>, int> comparisonFunc)
        {
            var students = GetSortedStudents(wantedData, studentsToTake, comparisonFunc);

            foreach (var st in students.OrderBy(x => x.Value).Take(studentsToTake)
                     .ToDictionary(pair => pair.Key, pair => pair.Value))
            {
                OutputWriter.PrintStudent(new KeyValuePair <string, double>(st.Key, st.Value));
            }
        }
Exemple #24
0
 /// <summary>
 /// Gets all the students from the course and lists their names and grades
 /// </summary>
 /// <param name="courseName"></param>
 public void GetAllStudentsFromCourse(string courseName)
 {
     if (IsQueryForCoursePossible(courseName))
     {
         OutputWriter.WriteMessageOnNewLine($"{courseName}:");
         foreach (var student in courses[courseName].StudentsByName)
         {
             var studentMark = new KeyValuePair <string, double>(student.Value.UserName, student.Value.MarksByCourseName[courseName]);
             OutputWriter.PrintStudent(studentMark);
         }
     }
 }
Exemple #25
0
        private void FilterAndTake(Dictionary <string, double> studentsWithMarks, Predicate <double> givenFilter, int studentsToTake)
        {
            int counterForPrinted = 0;

            foreach (var studentMark in studentsWithMarks)
            {
                if (counterForPrinted == studentsToTake)
                {
                    break;
                }
                if (givenFilter(studentMark.Value))
                {
                    OutputWriter.PrintStudent(new KeyValuePair <string, double>(studentMark.Key, studentMark.Value));
                    counterForPrinted++;
                }
            }
        }
Exemple #26
0
        private static void FilterAndTake(Dictionary <string, List <int> > wantedData, Predicate <double> givenFilter, int studentsToTake)
        {
            int countedForPrinted = 0;

            foreach (var usernamePoints in wantedData)
            {
                double averageScore            = usernamePoints.Value.Average();
                double percentageOfFullfilment = averageScore / 100;
                double mark = percentageOfFullfilment * 4 + 2;

                if (givenFilter(mark))
                {
                    OutputWriter.PrintStudent(usernamePoints);
                    countedForPrinted++;
                }
            }
        }
Exemple #27
0
        private void FilterAndTake(Dictionary <string, double> studentsWithMarks, Predicate <double> givenFilter, int studentsToTake)
        {
            var takenCounter = 0;

            foreach (var studentMark in studentsWithMarks)
            {
                if (takenCounter == studentsToTake)
                {
                    break;
                }

                if (givenFilter(studentMark.Value))
                {
                    OutputWriter.PrintStudent(studentMark);
                    takenCounter++;
                }
            }
        }
        private void FilterAndTake(Dictionary <string, double> studentsWithMarks, Predicate <double> givenFilter, int studentsToTake)
        {
            var counter = 0;

            foreach (var usernameScore in studentsWithMarks)
            {
                if (counter == studentsToTake)
                {
                    break;
                }

                if (givenFilter(usernameScore.Value))
                {
                    OutputWriter.PrintStudent(usernameScore);
                    counter++;
                }
            }
        }
Exemple #29
0
        private static void FilterAndTake(Dictionary <string, List <int> > wantedData, Predicate <double> givenFilter, int studentsToTake)
        {
            int counterForPrinted = 0;

            foreach (var userName_Points in wantedData)
            {
                if (counterForPrinted == studentsToTake)
                {
                    break;
                }

                double averageMark = userName_Points.Value.Average();

                if (givenFilter(averageMark))
                {
                    OutputWriter.PrintStudent(userName_Points);
                    counterForPrinted++;
                }
            }
        }
Exemple #30
0
        private void FilterAndTake(Dictionary <string, List <int> > wantedData, Predicate <double> givenFilter, int studentsToTake)
        {
            int counter = 0;

            foreach (var username_score in wantedData)
            {
                if (counter == studentsToTake)
                {
                    break;
                }

                var avrScore = username_score.Value.Average();
                var percentageOfFullfillments = avrScore / 100;
                var mark = percentageOfFullfillments * 4 + 2;

                if (givenFilter(mark))
                {
                    OutputWriter.PrintStudent(username_score);
                    counter++;
                }
            }
        }