Example #1
0
        public void getStuentExamListView()
        {
            List <rel_exam_student>    allSubmittedExams = getAllSubmittedStuExams();
            List <StudentExamListView> mySlistview       = new List <StudentExamListView>();

            try
            {
                Studentsexams.Items.Clear();
            }
            catch (Exception rt)
            { }
            foreach (var item in allSubmittedExams)
            {
                StudentExamListView stuExam = new StudentExamListView();
                exam exam = (from e in context2.exams
                             where e.ExamCode == item.ExamCode
                             select e).FirstOrDefault();
                student stu = (from s in context2.students
                               where s.StuId == item.StuId
                               select s).FirstOrDefault();
                string courseName = CourseNName;
                float  grade      = 0f;
                stuExam.ExamCode  = exam.ExamCode;
                stuExam.Name      = stu.StuEmail;
                stuExam.Type      = exam.Type;
                stuExam.Branch    = "Not Needed";
                stuExam.Intake    = 0;
                stuExam.Grade     = grade;
                stuExam.MinDegree = exam.MinDegree;
                stuExam.MaxDegree = exam.MaxDegree;
                stuExam.Date      = exam.Date;
                mySlistview.Add(stuExam);
                Studentsexams.Items.Add(stuExam);
            }
        }
Example #2
0
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            try
            {
                StudentExamListView exa = exams.SelectedItem as StudentExamListView;
                exam quet = (from t in context2.exams
                             where t.ExamCode == exa.ExamCode
                             select t).FirstOrDefault();

                context2.exams.Remove(quet);
                context2.SaveChanges();
                exams.Items.Remove(exa);
                Canvas.SetZIndex(exampanel, ++z);
            }
            catch (Exception dds)
            {
            }
        }
Example #3
0
        private void submit_exam(object sender, RoutedEventArgs e)
        {
            try
            {
                CourseNName = IstuctorCourse.SelectedItem.ToString();
                DateTime dateofExam = ExamDate.DisplayDate;
                int      munites    = 0;
                string[] number     = ExamTime.Text.Split(':', ',');
                if (number.Length == 1)
                {
                    munites = 0;
                }
                else if (number.Length > 1)
                {
                    munites = int.Parse(number[1]);
                }
                else
                {
                    MessageBox.Show("please enter the time of exam");
                }
                var      hour = int.Parse(number[0]) + int.Parse(duration.Text.ToString());
                DateTime examDateTimeBegin = new DateTime(dateofExam.Year, dateofExam.Month, dateofExam.Day, int.Parse(number[0]), munites, 0);
                //TimeSpan examDateTimeBegin = new TimeSpan(examDateTime.Day, int.Parse(number[0]), munites, 0);
                DateTime examDateTimeEnd = new DateTime(examDateTimeBegin.Year, examDateTimeBegin.Month, examDateTimeBegin.Day, hour, munites, 0);

                if (int.Parse(sumOfQuestionGrades.Text) == ExamDegree && examDateTimeBegin != null &&
                    SelectedQuestionsss.Count > 0 && int.Parse(duration.Text.ToString()) > 0)
                {
                    //the questions that selected to the exam
                    List <Quesition> questions = new List <Quesition>();
                    questions.AddRange(QuestionWithGrades.Where(r => SelectedQuestionsss.Contains(r.IDeas)));

                    //this list to match from question in class i made to put to the class
                    //the entity framework has made (the elements is added in the foreach t7t)
                    List <exam_qusetion> Exams_questions = new List <exam_qusetion>();

                    //the course of the question
                    //List<course_question> course_qus = new List<course_question>();
                    //course_qus.Add(new course_question { Course_ID = 1, Qust_codr = 4 });

                    //getting the course ID of the selected course
                    var courseId =
                        (from courseID in context2.courses
                         where courseID.Name == CourseNName
                         select courseID.CourseId).FirstOrDefault();

                    List <question>      DBquestions = new List <question>();
                    List <exam_qusetion> DBquesRel   = new List <exam_qusetion>();

                    foreach (var item in questions)
                    {
                        question qus = new question
                        {
                            QustCode = item.IDeas,
                            type     = item.Type
                        };
                        //DBquestions.Add(qus);
                        exam_qusetion rel = new exam_qusetion
                        {
                            Grade    = item.Degree,
                            question = qus
                        };
                        //DBquesRel.Add(rel);
                        Exams_questions.Add(rel);
                    }

                    List <course_exam> courseOfExam = new List <course_exam>();

                    var exams = new exam()
                    {
                        Name          = CourseNName,
                        Type          = comboBoxofexamType.SelectedItem.ToString(), //must be exam of corrective
                        Date          = examDateTimeBegin,
                        EndTime       = examDateTimeEnd,
                        MaxDegree     = (short)ExamDegree,
                        course_exam   = courseOfExam,
                        exam_qusetion = Exams_questions,
                    };
                    context2.exams.Add(exams);

                    context2.course_exam.Add(new course_exam {
                        Course_Id = courseId, exam = exams
                    });

                    context2.SaveChanges();


                    MessageBox.Show("Exam Has been Added");

                    /* ExamDegree // this is the degree of the exam
                     * IstuctorCourse // this is the course of the exam
                     * comboBoxofexamType // this combo box is the
                     * Exams_questions // this is the list of quetions
                     * examDateTimeBegin // this is the begin time for exam
                     * examDateTimeEnd //this is the end time for the exam */
                }
                else
                {
                    totalQgrade.Visibility = Visibility.Visible;
                }
            }
            catch (Exception eee)
            {
                MessageBox.Show(eee.ToString());
            }
        }