Exemplo n.º 1
0
        private string GetTopStudentsPraise(List <StudentHistoryDTO> list)
        {
            if (list != null)
            {
                var speech = new StringBuilder();

                var topStudents = StudentsPerformanceHelper.GetTopStudents(list);
                var x           = new Random().Next(0, 3);

                if (topStudents.Count == 1)
                {
                    switch (x)
                    {
                    case 0:
                        speech.Append($"Currently the top students for this class is {topStudents.FirstOrDefault().Key}" +
                                      $" with a score of {topStudents.FirstOrDefault().Value.ToString()}. ");
                        break;

                    case 1:
                        speech.Append($"{topStudents.FirstOrDefault().Key} is having the" +
                                      $" highest score in the class, congratulation! ");
                        break;

                    case 2:
                        speech.Append($"With the score of {topStudents.FirstOrDefault().Value.ToString()}. " +
                                      $"I wanna say that, now, {topStudents.FirstOrDefault().Key} is the top student" +
                                      $", congratulation {topStudents.FirstOrDefault().Key}. ");
                        break;
                    }

                    speech.Append("The rest of you please try your best!");
                }
                else if (topStudents.Count <= 5)
                {
                    foreach (var stud in topStudents)
                    {
                        speech.Append(stud.Key);
                        speech.Append(", ");
                    }
                    speech.Append(" are currently the top students in this class, ");
                    speech.Append($"with a score of {topStudents.FirstOrDefault().Value.ToString()}. ");
                    speech.Append("Great job everyone!");
                }
                else
                {
                    speech.Append($"Many of you have done well with a score of {topStudents.FirstOrDefault().Value.ToString()}. ");
                    speech.Append("Keep up the good work! ");
                }
                return(speech.ToString());
            }
            return(null);
        }
        private static string GetTopStreakPraise(List <StudentHistoryDTO> list)
        {
            if (list != null)
            {
                var speech         = new StringBuilder();
                var studentsStreak = StudentsPerformanceHelper.GetCorrectStreak(list);
                var numOfQuestions = StudentsPerformanceHelper.GetNumberOfQuestions(list);

                var maxStreak          = studentsStreak.Values.Max();
                var studentsFullStreak = new List <string>();
                foreach (var stud in studentsStreak)
                {
                    if (stud.Value == maxStreak)
                    {
                        studentsFullStreak.Add(stud.Key);
                    }
                }

                if (studentsFullStreak.Count == 1)
                {
                    speech.Append($"Only {studentsFullStreak[0]} has gotten every question correct! ");
                    speech.Append($"A round of applause for {studentsFullStreak[0]}. ");
                }
                else if (studentsFullStreak.Count > 1)
                {
                    if (studentsFullStreak.Count > 1 && studentsFullStreak.Count <= 5)
                    {
                        foreach (var stud in studentsFullStreak)
                        {
                            speech.Append($"{stud}, ");
                        }
                        speech.Append("have gotten every question correct! ");
                    }
                    else if (studentsFullStreak.Count > 5)
                    {
                        speech.Append("I am very happy that many of you gotten all questions correct! ");
                    }
                    speech.Append("Keep up the good work! ");
                }
                else
                {
                    return(null);
                }
                return(speech.ToString());
            }
            return(null);
        }
Exemplo n.º 3
0
        private void AnalyzeStudentPerformance(List <StudentHistoryDTO> list)
        {
            var rdm    = new Random();
            var rdmNum = rdm.Next(1, 4); // generate random number 1-3

            int incorrectCnt = StudentsPerformanceHelper.GetNumberOfInCorrectStudent(list);
            int correctCnt   = StudentsPerformanceHelper.GetNumberOfCorrectStudent(list);

            var speech = "";

            if (correctCnt == 0)
            {
                var x = rdm.Next(0, 3);
                switch (x)
                {
                case 0:
                    speech = "I am very sad now, because no one got any correct answer for this question. ";
                    break;

                case 1:
                    speech = "No one is correct. Is it because this question too difficult? ";
                    break;

                case 2:
                    speech = "Sorry to say this, but none of you had a correct answer. ";
                    break;
                }
                speech += "Come on guys, don't give up. ";

                LessonHelper.InsertPraise(speech);


                return;
            }
            else
            {
                var x = rdm.Next(0, 3);
                if (incorrectCnt == 0)
                {
                    switch (x)
                    {
                    case 0:
                        speech = "Brilliant! No one did any mistake for this question. ";
                        break;

                    case 1:
                        speech = "Amazing! Everybody answers are correct. ";
                        break;

                    case 2:
                        speech = "Incredible! All of you got the correct answer. ";
                        break;
                    }

                    speech += "Everyone, please clap your hands";
                    LessonHelper.InsertPraise(speech);
                    return;
                }
                else if (correctCnt >= incorrectCnt)
                {
                    switch (x)
                    {
                    case 0:
                        speech = "Well, I am every happy to see many of you got correct answer. ";
                        break;

                    case 1:
                        speech = "Great! Most of you did a good job! ";
                        break;

                    case 2:
                        speech = "Good job everybody, most of you are correct. ";
                        break;
                    }
                }
            }

            var numOfFullScore = StudentsPerformanceHelper.GetNumOfFullScore(list);

            if (numOfFullScore != 0)
            {
                speech += $"Awesome, we have {numOfFullScore.ToString()} students with full score! ";
            }

            switch (rdmNum)
            {
            case 1:
                speech += GetTopStudentsPraise(list);
                break;

            case 2:

                speech += GetTopStudentsPraise(list);

                break;

            case 3:
                speech += GetTopStudentsPraise(list);
                break;
            }

            LessonHelper.InsertPraise(speech);
        }