Exemplo n.º 1
0
        public dynamic Get(CourseManager courseManager, User teacher, SubscribeManager subscribeManager, AnswerManager answerManager,
                           QuestionManager questionManager, UserManager userManager)
        {
            var courses        = courseManager.GetAll(teacher);
            var students       = new List <User>();
            int correctAnswers = 0;
            int wrongAnswers   = 0;

            foreach (var course in courses)
            {
                students.AddRange(subscribeManager.UsersByCourse(course));
                correctAnswers += answerManager.CorrectAnswersCount(course.Id);
                wrongAnswers   += answerManager.WrongAnswersCount(course.Id);
            }

            var hardestQuestion = answerManager.HardestQuestion(courses);
            var easierQuestion  = answerManager.EasierQuestion(courses);
            var betterStudent   = answerManager.BetterStudent(courses);

            return(new
            {
                CoursesCount = courses.Count,
                Subscribers = students.Count,
                CorrectAnswers = correctAnswers,
                WrongAnswers = wrongAnswers,
                HardestQuestion = hardestQuestion != null?questionManager.Repository.GetById(hardestQuestion.Id).Description : string.Empty,
                EasierQuestion = easierQuestion != null?questionManager.Repository.GetById(easierQuestion.Id).Description : string.Empty,
                BetterStudent = betterStudent != null?userManager.Repository.GetById(betterStudent.Id).Name : string.Empty
            });
        }
Exemplo n.º 2
0
        public void SendQuestions(UserManager userManager, QuestionManager questionManager, CourseManager courseManager, SubscribeManager subscribeManager)
        {
            Transaction(() =>
            {
                var courses   = courseManager.EnabledCourses();
                var questions = questionManager.FirstQuestionsByCourse(courses);
                foreach (var question in questions)
                {
                    var users = subscribeManager.UsersByCourse(question.Course);
                    foreach (var user in users)
                    {
                        var userQuestion = new UserQuestion
                        {
                            Question = question,
                            User     = user,
                            Created  = DateTime.Now
                        };

                        Repository.Create(userQuestion);
                    }

                    question.Sent     = true;
                    question.SentDate = DateTime.Now;
                    questionManager.Update(question);
                }
            });
        }
Exemplo n.º 3
0
        public void SendFirstQuestion(SubscribeManager subscribeManager, SendQuestionManager sendQuestionManager, Course course, Question question)
        {
            var users = subscribeManager.UsersByCourse(course);

            users.ForEach(user =>
            {
                sendQuestionManager.SendQuestion(user, course, question);
            });
        }