Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            int correctAnswerCount = 0;

            foreach (KeyValuePair <MyQuestion, Answer> item in result)
            {
                if (item.Value.CorrectAnswer == true)
                {
                    correctAnswerCount++;
                }
            }
            int markPercents = (correctAnswerCount * 100) / myQuestions.Count;

            using (ExamTestSystemEntities ExamDB = new ExamTestSystemEntities())
            {
                Mark mark = new Mark()
                {
                    ID_exam    = currentExam.ID,
                    ID_student = student.ID,
                    Mark1      = markPercents
                };
                ExamDB.Marks.Add(mark);
                ExamDB.SaveChanges();
            }
            MessageBox.Show("Exam completed! Your result is " + markPercents + "%.");

            this.Owner.Owner.Show();
            this.Owner.Close();
            this.Close();
        }
Example #2
0
        private void ExamProcessForm_Load(object sender, EventArgs e)
        {
            using (ExamTestSystemEntities ExamDB = new ExamTestSystemEntities())
            {
                pageCounter        = 0;
                ExamNameLabel.Text = currentExam.Name;
                result             = new Dictionary <MyQuestion, Answer>();

                var questions = from req in ExamDB.RelationExamsQuestions
                                from ex in ExamDB.Exams
                                from q in ExamDB.Questions
                                where ex.ID == req.ID_exam && q.ID == req.ID_Question && ex.ID == currentExam.ID
                                select new MyQuestion //класс-контейнер
                {
                    QuestionID   = q.ID,
                    QuestionText = q.Name
                };
                List <Answer> answers = new List <Answer>();
                questions.ToList();
                foreach (var question in questions)
                {
                    answers.AddRange(ExamDB.Answers.Where(a => a.ID_question == question.QuestionID));
                }

                QuestionTextLabel.Text = questions.First().QuestionText;
                checkBox1.Text         = answers[0].QuestionText;
                checkBox2.Text         = answers[1].QuestionText;

                myQuestions = new List <MyQuestion>(questions);
                myAnswers   = new List <Answer>(answers);
            }
        }
Example #3
0
        private void PassExamButton_Click(object sender, EventArgs e)
        {
            Exam currentExam = new Exam();
            bool success     = false;

            using (ExamTestSystemEntities ExamDB = new ExamTestSystemEntities())
            {
                foreach (var exam in ExamDB.Exams)
                {
                    if (exam.ID == Int32.Parse(IncompletedExamsGridView.CurrentRow.Cells["ID"].Value.ToString()))
                    {
                        currentExam = exam;
                        success     = true;
                    }
                }
            }
            if (success == true)
            {
                ExamProcessForm examProcessForm = new ExamProcessForm(student, currentExam);
                examProcessForm.Show(this);
                this.Hide();
            }
            else
            {
                MessageBox.Show("Something went wrong!");
            }
        }
Example #4
0
 private void IncompletedExamsForm_Load(object sender, EventArgs e)
 {
     using (ExamTestSystemEntities ExamDB = new ExamTestSystemEntities())
     {
         var currentStudentMarks = from marks in ExamDB.Marks  //запрос содержит оценки студента
                                   where marks.ID_student == student.ID
                                   select new
         {
             marks.ID,
             marks.ID_exam,
             marks.ID_student,
             marks.Mark1
         };
         var incompletedExams = from ex in ExamDB.Exams                          //экзамены текущего студента,
                                where currentStudentMarks.Select(m => m.ID_exam) //по которым нет
                                .Contains(ex.ID) == false                        //оценок
                                from sub in ExamDB.Subjects
                                where ex.ID_subjects == sub.ID
                                select new
         {
             ex.Name,
             Subject = sub.Name,
             ex.Exam_date,
             ex.ID
         };
         IncompletedExamsGridView.DataSource = incompletedExams.ToList();
     }
 }
 private void ComletedExamsForm_Load(object sender, EventArgs e)
 {
     using (ExamTestSystemEntities ExamDB = new ExamTestSystemEntities())
     {
         var query = from ex in ExamDB.Exams
                     from su in ExamDB.Subjects
                     from mar in ExamDB.Marks
                     where mar.ID_exam == ex.ID &&
                     ex.ID_subjects == su.ID &&
                     mar.ID_student == student.ID
                     select new
         {
             Subject_Name = su.Name,
             Exam_Name    = ex.Name,
             Mark         = mar.Mark1
         };
         CompletedExamsGridView.DataSource = query.ToList();
     }
 }
Example #6
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            using (ExamTestSystemEntities ExamDB = new ExamTestSystemEntities())
            {
                //IQueryable<User> CurrentUser = ExamDB.Users.Where(u => u.Login == LoginTextBox.Text);
                //if (CurrentUser.FirstOrDefault() == null)
                //{
                //    MessageBox.Show("Login is incorrect!");
                //}
                //else if (CurrentUser.FirstOrDefault().Password != PasswordTextBox.Text)
                //{
                //    MessageBox.Show("Password is incorrect!");
                //}
                //else if (CurrentUser.FirstOrDefault().ID_roles == 1)
                //{
                //    this.Hide();
                //    AdminMenuForm adminMenuForm = new AdminMenuForm(CurrentUser);
                //    adminMenuForm.Show();
                //}
                //else if (CurrentUser.FirstOrDefault().ID_roles == 3)
                //{
                //    this.Hide();
                //    StudentMenuForm studentMenuForm = new StudentMenuForm(CurrentUser);
                //    studentMenuForm.Show();
                //}

                User CurrentUser = null;
                foreach (User user in ExamDB.Users)
                {
                    if (user.Login == LoginTextBox.Text)
                    {
                        CurrentUser = user;
                    }
                }
                if (CurrentUser == null)
                {
                    MessageBox.Show("Login is incorrect!");
                }
                else if (CurrentUser.Password != PasswordTextBox.Text)
                {
                    MessageBox.Show("Password is incorrect!");
                }
                else if (CurrentUser.ID_roles == 1)
                {
                    AdminMenuForm adminMenuForm = new AdminMenuForm(CurrentUser);
                    adminMenuForm.Show(this);
                    this.Hide();
                }
                else if (CurrentUser.ID_roles == 3)
                {
                    StudentMenuForm studentMenuForm = new StudentMenuForm(CurrentUser);
                    studentMenuForm.Show(this);
                    this.Hide();
                }
                else if (CurrentUser.ID_roles == 2)
                {
                    TeacherMenuForm teacherMenuForm = new TeacherMenuForm(CurrentUser);
                    teacherMenuForm.Show(this);
                    this.Hide();
                }
            }
        }