Exemple #1
0
        public static void TeacherLogsIn()
        {
            var studentList = DataBase.AllStudent();
            var teacherList = DataBase.AllTeachers();

            Console.WriteLine("Please enter the userrname for teachers:");
            var username = Console.ReadLine();

            Console.WriteLine("Please enter the password for teachers:");
            var     password    = Console.ReadLine();
            Teacher listTeacher = teacherList.SingleOrDefault(t => t.Username == username && t.Password == password);

            if (listTeacher != null)
            {
                //TEACHER LOGS IN
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Welcome teacher {listTeacher.FullName}!");
                Console.ResetColor();
                Console.WriteLine("List of Students: ");

                //var teacher = new Teacher();
                //teacher.ListOfStudents();
                foreach (var student in studentList)
                {
                    student.Grade = QuestionsDataBase.GetGrade();
                    if (Student.loggedStudentsList.Contains(student.Username))
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine($"Student {student.FullName}, with grade of {student.Grade}");
                        Console.ResetColor();
                    }
                    else if (!(Student.loggedStudentsList.Contains(student.Username)))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(student.FullName);
                        Console.ResetColor();
                    }
                }
            }
            else if (listTeacher == null)
            {
                Console.WriteLine("Incorrect username or password, please try again.");
            }
        }
Exemple #2
0
        public static void StudentLogsIn()
        {
            var studentList = DataBase.AllStudent();
            var teacherList = DataBase.AllTeachers();

            Console.WriteLine("Please enter the username for students:");
            var usernameS = Console.ReadLine();

            Console.WriteLine("Please enter the password for students:");
            var passwordS = Console.ReadLine();

            Student listStudent = studentList.SingleOrDefault(s => s.Username == usernameS && s.Password == passwordS);

            if (listStudent != null)
            {
                if (!Student.loggedStudentsList.Contains(listStudent.Username))
                {
                    //STUDENT LOGS IN

                    QuestionsDataBase.DisplayAndCheckQuestions();
                    listStudent.Grade = QuestionsDataBase.GetGrade();

                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.WriteLine($"{listStudent.FullName}, your final grade is:{listStudent.Grade}");
                    Console.ResetColor();

                    listStudent.DoneTest(listStudent.Username, listStudent.Logged, listStudent.Grade);
                }
                else if (Student.loggedStudentsList.Contains(listStudent.Username))
                {
                    Console.WriteLine("Sorry, but you already did the quiz!");
                }
            }
            else if (listStudent == null)
            {
                Console.WriteLine("No such Student.Try again.");
            }
            ;
        }