public void Initialize()
        {
            _testSupervisor = new User
            {
                UserName = "******"
            };
            _testStudent = new User()
            {
                UserName = "******"
            };

            _testEducationClass = new EducationClass
            {
                ClassId               = "klass1",
                Description           = "Testklass",
                EducationSupervisorId = "supervisor"
            };
            _testEducationClass.AddStudent(_testStudent);

            var otherClass = new EducationClass
            {
                ClassId               = "klass2",
                Description           = "Should not be found",
                EducationSupervisorId = "someone"
            };

            var classList = new List <EducationClass> {
                _testEducationClass, otherClass
            };

            _testEducationClassStore = new EducationClassStore(classList);
        }
        public void Initialize()
        {
            _testClass = new EducationClass
            {
                ClassId       = "su15",
                Description   = "Systemutvecklare, agil applikationsprogrammering",
                StudentString = "kalle",
                CourseString  = "Mattematik1"
            };

            _testSuperVisor = new User
            {
                UserLevel = UserLevel.EducationSupervisor,
                UserName  = "******"
            };
            _testClass.EducationSupervisorId = _testSuperVisor.UserName;

            List <EducationClass> classList = new List <EducationClass> {
                _testClass
            };
            List <User> userList = new List <User> {
                _testSuperVisor
            };

            _testUserStore = new UserStore(userList);
            _classStore    = new EducationClassStore(classList);
        }
Beispiel #3
0
        public static void ShowCoursesForClass()
        {
            EducationClassStore classStore = new EducationClassStore();

            bool loop = true;

            do
            {
                Console.Clear();
                Console.WriteLine("Tryck enter för att avbryta");
                string input = UserInput.GetInput <string>("Ange klass-id:");

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

                EducationClass klass = classStore.FindById(input);
                if (klass == null)
                {
                    Console.WriteLine("Finns ingen klass med det id:t");
                    UserInput.WaitForContinue();
                }
                else
                {
                    CoursePresenter.ShowClassCourseList(klass);
                    loop = false;
                }
            } while (loop);
        }
Beispiel #4
0
        public static void ShowClassCourseList(EducationClass klass)
        {
            List <string> courses = klass.GetCourseList();

            ListCourses(courses);
            UserInput.WaitForContinue();
        }
        public void FindByCourseId_Return_Null_If_Class_Not_Found()
        {
            string input = "Franska1";

            EducationClass foundClass = _classStore.FindByCourseId(input);

            Assert.IsNull(foundClass);
        }
        public void FindByStudentId_Return_Null_If_Student_Not_Found()
        {
            string input = "svenn";

            EducationClass foundClass = _classStore.FindByStudentId(input);

            Assert.IsNull(foundClass);
        }
        public void FindByCourseId_Can_Find_Class()
        {
            string input    = "Mattematik1";
            string expected = "su15";

            EducationClass foundClass = _classStore.FindByCourseId(input);

            Assert.AreEqual(expected, foundClass.ClassId);
        }
        public void FindByStudentId__Can_Find_Student()
        {
            string input    = "kalle";
            string expected = "su15";

            EducationClass foundClass = _classStore.FindByStudentId(input);
            string         actual     = foundClass.ClassId;

            Assert.AreEqual(expected, actual);
        }
        public void GetClassesForSuperVisor_Can_Find_Class()
        {
            var inputUser = _testSuperVisor;
            var expected  = "su15";

            var            foundClassList = _classStore.GetClassesForSupervisor(inputUser);
            EducationClass foundClass     = foundClassList.SingleOrDefault(c => c.EducationSupervisorId == inputUser.UserName);

            Assert.AreEqual(expected, foundClass.ClassId);
        }
Beispiel #10
0
        public static void RemoveStudentFromClass()
        {
            var classStore   = new EducationClassStore();
            var studentStore = new UserStore();

            do
            {
                Console.Clear();
                Console.WriteLine("Ta bort student från klass");
                Console.WriteLine();
                Console.WriteLine("Tryck enter för att avbryta");
                string input = UserInput.GetInput <string>("Ange klass-id:");

                if (input == string.Empty)
                {
                    return;
                }

                EducationClass edClass = classStore.FindById(input);

                if (edClass == null)
                {
                    Console.WriteLine("Finns ingen klass med det id:t");
                }
                else
                {
                    input = UserInput.GetInput <string>("Ange student-id:");
                    User student = studentStore.FindById(input);

                    if (student == null)
                    {
                        Console.WriteLine("Studenten finns inte");
                    }
                    else
                    {
                        if (edClass.HasStudent(student.UserName))
                        {
                            bool confirmation =
                                UserInput.AskConfirmation(
                                    $"Vill du ta bort {student.FullName()} från klassen {edClass.ClassId}?");
                            if (confirmation)
                            {
                                List <string> studentList = edClass.GetStudentList();
                                studentList.Remove(student.UserName);
                                Console.WriteLine($"Plockade bort {student.UserName} från klassen");

                                edClass.SetStudentList(studentList);
                                classStore.Save();
                            }
                        }
                    }
                }
            } while (true);
        }
Beispiel #11
0
        public static void ShowClassStudentList()
        {
            EducationClassStore classStore   = new EducationClassStore();
            UserStore           studentStore = new UserStore();
            bool keepLooping = true;

            do
            {
                Console.Clear();
                Console.WriteLine("Visa klass");
                Console.WriteLine();
                Console.WriteLine("Tryck enter för att avbryta");
                string classId = UserInput.GetInput <string>("Ange klass-id:");

                if (classId == string.Empty)
                {
                    return;
                }

                EducationClass edClass = classStore.FindById(classId);

                if (edClass == null)
                {
                    Console.WriteLine($"Finns ingen klass med id {classId}");
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine(
                        "Student-id".PadRight(12) +
                        "Namn".PadRight(40) +
                        "Telefon".PadRight(15) +
                        "Person-nr"
                        );
                    Console.WriteLine(new string('-', Console.WindowWidth));

                    List <string> studentList = edClass.GetStudentList();
                    foreach (string studentId in studentList)
                    {
                        User student = studentStore.FindById(studentId);

                        Console.WriteLine(
                            student.UserName.PadRight(12) +
                            student.FullName().Truncate(39).PadRight(40) +
                            student.PhoneNumber.PadRight(15) +
                            student.SSN
                            );
                    }
                }
                UserInput.WaitForContinue();
            } while (keepLooping);
        }
Beispiel #12
0
        public static void ShowStudentCourseList(User student)
        {
            EducationClassStore classStore = new EducationClassStore();

            foreach (EducationClass klass in classStore.All())
            {
                if (klass.HasStudent(student.UserName))
                {
                    EducationClass studentClass = klass;
                    List <string>  courseList   = studentClass.GetCourseList();

                    ListCourses(courseList);
                    break;
                }
            }
        }
Beispiel #13
0
        public void Initialize()
        {
            _testClass = new EducationClass()
            {
                ClassId               = "testclass",
                Description           = "The Joy of Painting with Bob Ross",
                EducationSupervisorId = "bobross"
            };

            var studentList = new List <string>
            {
                "adam",
                "bertil",
                "caesar",
                "david",
                "erik",
                "johndoe"
            };

            _testClass.SetStudentList(studentList);

            _testCourse = new Course
            {
                CourseId      = "oop1",
                CourseName    = "Objektorienterad Programmering 1",
                CourseTeacher = "pontus",
                StartDate     = DateTime.Today,
                EndDate       = DateTime.Today
            };

            _testUser = new User
            {
                UserName = "******"
            };

            _testAddUser = new User
            {
                UserName = "******"
            };

            var courseList = new List <Course>();

            courseList.Add(_testCourse);
            _courseStore = new CourseStore(courseList);
        }
        /// <summary>
        /// Update the navigation property classes in education
        /// <param name="body"></param>
        /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
        /// </summary>
        public RequestInformation CreatePatchRequestInformation(EducationClass body, Action <EducationClassItemRequestBuilderPatchRequestConfiguration> requestConfiguration = default)
        {
            _ = body ?? throw new ArgumentNullException(nameof(body));
            var requestInfo = new RequestInformation {
                HttpMethod     = Method.PATCH,
                UrlTemplate    = UrlTemplate,
                PathParameters = PathParameters,
            };

            requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
            if (requestConfiguration != null)
            {
                var requestConfig = new EducationClassItemRequestBuilderPatchRequestConfiguration();
                requestConfiguration.Invoke(requestConfig);
                requestInfo.AddRequestOptions(requestConfig.Options);
                requestInfo.AddHeaders(requestConfig.Headers);
            }
            return(requestInfo);
        }
Beispiel #15
0
        public static void ShowStudentsForCourse(User user)
        {
            bool isTeacher = user.HasLevel(UserLevel.Teacher);

            do
            {
                CourseStore         courseStore = new CourseStore();
                EducationClassStore classStore  = new EducationClassStore();

                Console.Clear();
                Console.WriteLine("Visa klasslista för kurs");
                Console.WriteLine();

                Console.WriteLine("Tryck enter för att avbryta.");
                string courseName = UserInput.GetInput <string>("Ange kurs-id:");

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

                Course course = courseStore.FindById(courseName);

                if (course == null)
                {
                    Console.WriteLine("Finns ingen kurs med det namnet");
                    Console.WriteLine();
                }
                else if (isTeacher && course.CourseTeacher != user.UserName)
                {
                    Console.WriteLine("Du är ej lärare för den kursen.");
                    Console.WriteLine();
                }
                else
                {
                    EducationClass klass        = classStore.FindByCourseId(course.CourseId);
                    List <string>  studentNames = klass.GetStudentList();
                    UserManagerPresenter.PrintStudentList(studentNames);
                }
            } while (true);
        }
Beispiel #16
0
        public static void ShowClassForStudent(User student)
        {
            EducationClassStore classStore   = new EducationClassStore();
            UserStore           studentStore = new UserStore();

            Console.Clear();
            Console.WriteLine("Visa klass");
            Console.WriteLine();
            Console.WriteLine("Tryck enter för att gå tillbaka till föregående skärm.");



            EducationClass edClass = classStore.FindByStudentId(student.UserName);

            Console.Clear();
            Console.WriteLine(
                "Student-id".PadRight(12) +
                "Namn".PadRight(40) +
                "Telefon".PadRight(15)
                );
            Console.WriteLine(new string('-', Console.WindowWidth));

            List <string> studentList = edClass.GetStudentList();

            foreach (string studentId in studentList)
            {
                User s = studentStore.FindById(studentId);

                Console.WriteLine(
                    s.UserName.PadRight(12) +
                    s.FullName().PadRight(40) +
                    s.PhoneNumber.PadRight(15)
                    );
            }
            UserInput.WaitForContinue();
        }
Beispiel #17
0
 public bool IsMy(EducationClass @class)
 {
     return(MyClasses != null && MyClasses.Any(c => c.Id == @class.Id));
 }
Beispiel #18
0
        public static void GradeStudentInCourse(User grader)
        {
            var userStore           = new UserStore();
            var educationClassStore = new EducationClassStore();
            var courseStore         = new CourseStore();
            var gradeStore          = new GradeStore();

            List <string> courseList;
            Course        course;
            User          student;

            Console.Clear();
            Console.WriteLine("Betygsätt student");
            Console.WriteLine();

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

            do
            {
                Console.WriteLine("Tryck enter för att avbryta");
                string studentName = UserInput.GetInput <string>("Ange student-id:");

                if (studentName == string.Empty)
                {
                    return;
                }

                student = userStore.FindById(studentName);

                if (student == null)
                {
                    Console.WriteLine("Finns ingen student med det id:t");
                }
                else
                {
                    EducationClass studentClass =
                        educationClassStore.FindByStudentId(student.UserName);
                    courseList = studentClass.GetCourseList();
                    break;
                }
            } while (true);

            do
            {
                Console.WriteLine("Tryck enter för att avbryta");
                string courseName = UserInput.GetInput <string>("Ange kurs-id:");
                if (courseName == string.Empty)
                {
                    return;
                }
                if (courses.Exists(c => c.CourseId == courseName))
                {
                    if (courseList.Contains(courseName))
                    {
                        course = courseStore.FindById(courseName);
                        break;
                    }

                    Console.WriteLine("Studentens klass läser inte kursen");
                    UserInput.WaitForContinue();
                }
                else
                {
                    Console.WriteLine("Kursen finns inte eller du är inte lärare för den");
                    UserInput.WaitForContinue();
                }
            } while (true);

            GradeLevel gradeLevel = AskForGrade();

            Console.WriteLine($"Student: {student.FullName()} ({student.UserName})");
            Console.WriteLine($"Kurs: {course.CourseName} ({course.CourseId})");
            Console.WriteLine($"Betyg: {gradeLevel}");
            bool confirm = UserInput.AskConfirmation("Betygsätt student?");



            if (confirm)
            {
                var grade = new Grade
                {
                    CourseId  = course.CourseId,
                    StudentId = student.UserName,
                    Result    = gradeLevel
                };

                gradeStore.GradeStudent(student, grade);
                gradeStore.Save();
            }
        }
Beispiel #19
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();
        }
        public void FindById__Returns_Null_If_Class_Not_Found()
        {
            EducationClass foundClass = _classStore.FindById("qwerty");

            Assert.IsNull(foundClass);
        }