Пример #1
0
        // get availabe exams for student without course type
        public static ExamCollection GetAvailabeExams(int id)
        {
            ExamCollection result = new ExamCollection();
            string         s      = String.Format(
                " select  DISTINCT * from Exam, ExamSession " +
                " where {0} not in (select Student_Exam.FK_StudID from Student_Exam where Exam.id " +
                " <> Student_Exam.FK_ExamID) and Exam.flag <> 0 " +
                " and Exam.id in (Select ExamSession.FK_ExamID from ExamSession) " +
                " and Exam.id in (select Exam_Course_Instructor.FK_ExamID " +
                "from Exam_Course_Instructor,Course_Student " +
                "where Course_Student.FK_CourseID = Exam_Course_Instructor.FK_CourseID) " +
                " and Exam.id = ExamSession.FK_ExamID ", id);
            DataTable dt = DBLayer.ExecuteQuery(s);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Admin       admin       = new Admin(int.Parse(dt.Rows[i]["FK_AdminID"].ToString()));
                int         ids         = int.Parse(dt.Rows[i]["session_ID"].ToString());
                ExamSession examSession = new ExamSession(ids, DateTime.Parse(dt.Rows[i]["session_date"].ToString()), new Exam(int.Parse(dt.Rows[i]["id"].ToString()), true, admin), admin);
                Exam        exam        = new Exam(Convert.ToInt32(dt.Rows[i]["id"]), (bool)dt.Rows[i]["flag"], admin);
                exam.ExamSessions = new ExamSessionCollection();
                exam.ExamSessions.Add(examSession);
                result.Add(exam);
            }
            result = RearangeExams(result);
            result = getExamCourse(result);
            return(result);
        }
Пример #2
0
        private static ExamCollection RearangeExams(ExamCollection exams)
        {
            ExamCollection result = new ExamCollection();

            for (int i = 0; i < exams.Count; i++)
            {
                for (int j = 0; j < exams.Count; j++)
                {
                    if ((exams[i].ExamSessions.Count != 0 && exams[j].ExamSessions.Count != 0) && exams[i].ExamSessions[0].Id != exams[j].ExamSessions[0].Id &&
                        exams[i].Id == exams[j].Id)
                    {
                        exams[i].ExamSessions.Add(exams[j].ExamSessions[0]);
                        exams[j].ExamSessions.RemoveAt(0);
                    }
                }
            }
            for (int i = 0; i < exams.Count; i++)
            {
                if (exams[i].ExamSessions.Count == 0)
                {
                    exams.RemoveAt(i);
                }
            }
            result = exams;
            return(result);
        }
Пример #3
0
 private static ExamCollection getExamCourse(ExamCollection exams)
 {
     for (int i = 0; i < exams.Count; i++)
     {
         Course    c  = new Course();
         string    s  = String.Format("select Course.course_Name , Course.id from Course , Exam_Course_Instructor where  Exam_Course_Instructor.FK_ExamID = {0} and Course.id = Exam_Course_Instructor.FK_CourseID", exams[i].Id);
         DataTable dt = DBLayer.ExecuteQuery(s);
         if (dt.Rows.Count > 0)
         {
             c.Id   = int.Parse(dt.Rows[0]["id"].ToString());
             c.Name = dt.Rows[0]["course_Name"].ToString();
         }
         exams[i].Course = c;
     }
     return(exams);
 }
Пример #4
0
        public static ExamCollection getAll(Admin adm)
        {
            DataTable      dt     = database.DBLayer.ExecuteQuery("select * from Exam");
            ExamCollection result = new ExamCollection();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int  examId = Convert.ToInt32(dt.Rows[i]["id"]);
                bool flag   = Convert.ToBoolean(dt.Rows[i]["flag"]);
                adm.Id = Convert.ToInt32(dt.Rows[i]["FK_AdminID"]);

                Exam exam = new Exam(examId, flag, adm);
                result.Add(exam);
            }
            return(result);
        }
Пример #5
0
        public ExamGeneration()
        {
            InitializeComponent();

            course = new Course();
            adm    = new Admin();
            adm.Id = 1;
            exam   = new Exam(false, adm);

            courses = CourseDAL.SelectAll();

            for (int i = 0; i < courses.Count; i++)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = courses[i].Name;
                item.Value = courses[i].Id;
                CourseNameComboBox.Items.Add(item);
                CourseNameComboBox.SelectedIndex = 0;
            }
            updateCourse();

            exams = ExamDAL.getAll(adm);
            for (int i = 0; i < exams.Count; i++)
            {
                ComboboxItem item = new ComboboxItem();
                item.Text  = exams[i].Id.ToString();
                item.Value = exams[i].Id;
                ExamsComboBox.Items.Add(item);
                ExamsComboBox.SelectedIndex = 0;
            }

            QuestionCollection col = QuestionDAL.GetByType(1);

            MCQnumLabel.Text = col.Count.ToString();
            QuestionCollection col2 = QuestionDAL.GetByType(2);

            TFnumLabel.Text = col2.Count.ToString();
            QuestionCollection col3 = QuestionDAL.GetByType(3);

            EssaynumLabel.Text = col3.Count.ToString();

            updateExamSessions();
        }
        private void Student_Profile_Load(object sender, EventArgs e)
        {
            //if (MyStudent.Student == null)
            //{
            //    MessageBox.Show("You Shoul Login as a stuent");
            //    MyStudent.Student = null;
            //    this.Close();
            //    Login login = new Login();
            //    login.Show();
            //    return;
            //}
            dataGridView1.Hide();
            dataGridView2.Hide();
            student          = MyStudent.Student;
            MyAdmin.Admin    = new Admin();
            MyAdmin.Admin.Id = 1;

            exams   = StudentDAL.GetAvailabeExams(student.Id);
            grades1 = StudentDAL.getStudentGrades(student.Id);
        }
Пример #7
0
        private void Instructor_Profile_Load(object sender, EventArgs e)
        {
            ins = MyInstructor.Instructor;

            //just for test
            MyAdmin.Admin    = new Admin();
            MyAdmin.Admin.Id = 1;

            ExamCollection exams = ExamDAL.getAll(MyAdmin.Admin);

            if (exams.Count != 0)
            {
                examsCombobox.Items.Clear();
                for (int i = 0; i < exams.Count; i++)
                {
                    ComboboxItem item = new ComboboxItem();
                    item.Text  = exams[i].Id.ToString();
                    item.Value = exams[i].Id;
                    examsCombobox.Items.Add(item);
                    examsCombobox.SelectedIndex = 0;
                }
            }
        }