Пример #1
0
        public void FindByCourseId_Find_Goal()
        {
            string input    = "kurs50";
            Goal   expected = testGoal;

            var  findGoalList = testGoalStore.FindByCourseId(input);
            Goal actualGoal   = findGoalList.SingleOrDefault(g => g.CourseId == input);

            Assert.AreEqual(expected, actualGoal);
        }
Пример #2
0
        public static void ShowCourseGoals(Course course = null)
        {
            var goalStore = new GoalStore();

            if (course == null)
            {
                course = AskForCourseById();
                if (course == null)
                {
                    return;
                }
            }

            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            Console.Clear();
            Console.WriteLine($"Kursmål för {course.CourseName}");
            Console.WriteLine(new string('-', Console.WindowWidth));
            Console.WriteLine();
            if (goals.Count > 0)
            {
                Console.WriteLine("Den studerande ska:");
                foreach (Goal goal in goals)
                {
                    Console.WriteLine($" {goal.GoalId}.".PadRight(5) + goal.Description);
                }
            }
            else
            {
                Console.WriteLine("Kursen har inga mål.");
            }

            UserInput.WaitForContinue();
        }
Пример #3
0
        private static void RemoveCourseGoal()
        {
            Course course = AskForCourseById();

            var goalStore = new GoalStore();

            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            foreach (var goal in goals)
            {
                Console.WriteLine(goal.GoalId + ":  " + goal.Description.Truncate(Console.WindowWidth));
            }
            Console.WriteLine("Tryck enter för att avbryta");
            Console.WriteLine();
            string input = UserInput.GetInput <string>("Ange mål id");

            goals.RemoveAll(g => g.GoalId == input);
            goalStore.Remove(input);

            for (int i = 0; i < goals.Count; i++)
            {
                goals[i].GoalId = (i + 1).ToString();
            }
            goalStore.Save();
        }
Пример #4
0
        private static void EditCourseGoal()
        {
            Course course    = AskForCourseById();
            var    goalStore = new GoalStore();

            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            foreach (var g in goals)
            {
                Console.WriteLine(g.GoalId + ":  " + g.Description.Truncate(Console.WindowWidth));
            }

            UserInput.WaitForContinue();
            Console.WriteLine();
            string input = UserInput.GetInput <string>("Ange mål-id:");

            Console.Clear();
            Goal goal = goals.SingleOrDefault(g => g.GoalId == input);

            if (goal != null)
            {
                Console.WriteLine("Gammal beskrivning: " + goal.Description);
                Console.WriteLine();
                goal.Description = UserInput.GetInput <string>("Den studerande ska: ");
                goalStore.Save();
            }
            else
            {
                Console.WriteLine("Målet finns inte");
            }
        }
Пример #5
0
        public static void ShowStudentCourseGoals(User student)
        {
            var    goalStore = new GoalStore();
            Course course    = AskForCourseById();

            if (course == null)
            {
                Console.WriteLine("Kursen finns inte");

                UserInput.WaitForContinue();
                return;
            }


            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            Console.Clear();
            Console.WriteLine($"Kursmål för {course.CourseName}");
            Console.WriteLine(new string('-', Console.WindowWidth));
            Console.WriteLine();
            if (goals.Count > 0)
            {
                GradeStore   gradeStore = new GradeStore();
                List <Grade> grades     = gradeStore.FindGradesForStudent(student, course).ToList();
                Console.WriteLine("Den studerande ska:");
                foreach (Goal goal in goals)
                {
                    Grade grade = grades.SingleOrDefault(g => g.CourseGoal == goal.GoalId);
                    Console.WriteLine($" {goal.GoalId}.".PadRight(5) + goal.Description);
                    if (grade == null)
                    {
                        Console.WriteLine("     Ej betygsatt");
                    }
                    else
                    {
                        Console.WriteLine($@"   Betyg: {grade.Result}");
                    }
                }
            }
            else
            {
                Console.WriteLine("Kursen har inga mål.");
            }

            UserInput.WaitForContinue();
        }
Пример #6
0
        private static void CreateNewCourseGoal()
        {
            var goalStore = new GoalStore();

            Console.Clear();
            Console.WriteLine("Skapa nytt mål för kurs");
            Console.WriteLine();

            Course course = AskForCourseById();

            if (course == null)
            {
                return;
            }

            Console.Clear();
            Console.WriteLine($"Kurs: {course.CourseName} ({course.CourseId})");

            int goalCount = goalStore.FindByCourseId(course.CourseId).Count();

            Console.WriteLine("Tryck enter för att avbryta");
            Console.WriteLine();
            while (true)
            {
                string description = UserInput.GetInput <string>("Den studerande ska:");

                if (description == string.Empty)
                {
                    break;
                }

                var goal = new Goal
                {
                    CourseId    = course.CourseId,
                    GoalId      = (goalCount + 1).ToString(),
                    Description = description
                };
                goalCount++;
                goalStore.AddItem(goal);
                goalStore.Save();
            }
            ShowCourseGoals(course);
        }
Пример #7
0
        public static void GradeStudentGoal(User grader)
        {
            var courseStore = new CourseStore();
            var gradeStore  = new GradeStore();
            var goalStore   = new GoalStore();

            List <Course> courses = GetCourses(grader, courseStore).ToList();


            Course course = CoursePresenter.AskForCourseById();

            if (course == null)
            {
                return;
            }
            if (grader.HasLevel(UserLevel.Teacher) && course.CourseTeacher != grader.UserName)
            {
                Console.WriteLine("Du är ej lärare för den kursen");
                UserInput.WaitForContinue();
                return;
            }

            User           student = UserManagerPresenter.SearchForUser(UserLevel.Student);
            EducationClass klass   = student.GetClass();

            if (klass == null)
            {
                Console.WriteLine("Användaren är inte en student");
                UserInput.WaitForContinue();
                return;
            }
            if (!klass.HasCourse(course.CourseId))
            {
                Console.WriteLine("Klassen läser ej den kursen");
                UserInput.WaitForContinue();
                return;
            }

            List <Goal> goals = goalStore.FindByCourseId(course.CourseId).ToList();

            foreach (Goal g in goals)
            {
                Console.WriteLine($"  {g.GoalId}: {g.Description.Truncate(95)}");
            }

            Console.WriteLine();
            string goalToGrade = UserInput.GetInput <string>("Välj mål att betygsätta:");

            Goal goal = goals.SingleOrDefault(g => g.GoalId == goalToGrade);

            if (goal == null)
            {
                Console.WriteLine($"Finns inget mål med id {goalToGrade}");
                UserInput.WaitForContinue();
                return;
            }

            GradeLevel gradeLevel = AskForGrade();

            var grade = new Grade
            {
                StudentId  = student.UserName,
                CourseId   = course.CourseId,
                CourseGoal = goal.GoalId,
                Result     = gradeLevel
            };

            Console.WriteLine();
            Console.WriteLine($"Student: {student.FullName()}");
            Console.WriteLine($"Kursmål: {goal.Description.Truncate(95)}");
            Console.WriteLine($"Betyg:   {grade.Result}");

            bool confirm = UserInput.AskConfirmation("Spara betyg?");

            if (confirm)
            {
                Grade existingGrade = gradeStore.FindById(grade.GradeId);
                if (existingGrade == null)
                {
                    gradeStore.AddItem(grade);
                    gradeStore.Save();
                }
                else
                {
                    gradeStore.GradeStudent(student, grade);
                    gradeStore.Save();
                }
            }

            Console.WriteLine();
            UserInput.WaitForContinue();
        }