Пример #1
0
        private void login(int id)
        {
            OnlineExam ent = new OnlineExam();

            try
            {
                var dept = (from d in ent.Departments select d).ToList();

                bool isManager = false;

                foreach (var item in dept)
                {
                    if (id == item.MangerId)
                    {
                        isManager = true;
                    }
                }

                if (!isManager)
                {
                    MessageBox.Show("Access Denaied", "Error");
                    return;
                }

                Manager_Home_Form manager_Home = new Manager_Home_Form(id);
                this.Close();
                manager_Home.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("Not Authroized", "Access Denaied");
            }
        }
Пример #2
0
        private void ShowStudentGrades_Load(object sender, EventArgs e)
        {
            OnlineExam exam   = new OnlineExam();
            var        grades = exam.getStudnetGrades(studentID);

            dataGridView1.DataSource = grades.ToList();
        }
Пример #3
0
        private void questionInfo(int qid)
        {
            OnlineExam ent = new OnlineExam();
            // select Question by ID
            var quest = (from q in ent.Questions
                         where q.QuesId == qid
                         select q).First();

            // Show Quest Info
            qcont.Text    = quest.Qcontent.Trim();
            qdegree.Value = (int)quest.Degree;
            qmodel.Text   = quest.Answer.Trim();

            // Check Type Of Quest To select Display Method
            if (quest.Type.ToLower().Trim() == "tf")
            {
                // case 1: TF
                // don't need ans group

                comboBox3.SelectedIndex = 1;
            }
            else if (quest.Type.ToLower().Trim() == "mcq")
            {
                comboBox3.SelectedIndex = 0;
                List <string> chList = new List <string>(4);
                ansGroup.Show();
                var       choices   = ent.Select_MCQ_Question(quest.QuesId).ToList();
                TextBox[] textBoxes = { ansA, ansB, ansC, ansD };
                for (int i = 0; i < choices.Count; i++)
                {
                    textBoxes[i].Text = choices[i].body;
                }
            }
            viewAnswerGroup();
        }
Пример #4
0
        // Delete
        private void button3_Click(object sender, EventArgs e)
        {
            int examId = 0;

            if (comboBox1.SelectedItem != null)
            {
                examId = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("There Is No Exam Selected");
                return;
            }

            OnlineExam ent  = new OnlineExam();
            var        exam = (from ex in ent.Exams
                               where ex.Enumber == examId
                               select ex).First();

            int crsId = (int)exam.CrsId;

            ent.Exams.Remove(exam);
            ent.SaveChanges();
            comboBox1.Text = comboBox2.Text = string.Empty;

            loadCourse();
            loadExams(crsId);
        }
Пример #5
0
        private void deleteQuestion()
        {
            int questId = 0;

            if (comboBox2.SelectedItem != null)
            {
                questId = int.Parse(comboBox2.Text.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("Please select course id", "Waring");
                return;
            }

            OnlineExam ent  = new OnlineExam();
            var        ques = (from q in ent.Questions
                               where q.QuesId == questId
                               select q).First();
            int courseId = (int)ques.CrsId;

            try
            {
                ent.Delete_Question(questId);
            }
            catch (Exception)
            {
            }


            loadCourse();
            loadQuestions(courseId);
        }
Пример #6
0
        private void insertChoicesForQuestById(int questID)
        {
            OnlineExam ent = new OnlineExam();

            if (!isChoiceDataValid())
            {
                MessageBox.Show("Please Enter All Data Rrequired", "Waring");
                return;
            }

            Dictionary <string, TextBox> choices = new Dictionary <string, TextBox>(4);

            choices.Add("a", ansA);
            choices.Add("b", ansB);
            choices.Add("c", ansC);
            choices.Add("d", ansD);
            foreach (var item in choices)
            {
                Ques_Choices ques_Choices = new Ques_Choices()
                {
                    QuesId  = questID,
                    choices = item.Key,
                    body    = item.Value.Text.Trim()
                };

                ent.Ques_Choices.Add(ques_Choices);
            }
            ent.SaveChanges();

            ansA.Text = ansB.Text = ansC.Text = ansD.Text = string.Empty;
        }
Пример #7
0
        private void deletePrevGradeIfExist()
        {
            OnlineExam exam = new OnlineExam();
            var        msg  = exam.deletePrevGrade(studentID, examID);

            exam.SaveChanges();
        }
Пример #8
0
        private void Manager_Home_Form_Load(object sender, EventArgs e)
        {
            OnlineExam ent  = new OnlineExam();
            var        inst = (from n in ent.Instructors where n.InsId == managerID select n).First();


            label2.Text = inst.InsId.ToString();
            label4.Text = inst.InsName;
        }
Пример #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            int questID = 0;
            int crsID   = 0;

            if (comboBox2.SelectedItem != null)
            {
                questID = int.Parse(comboBox2.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("Please select quest id", "Waring");
            }

            if (comboBox1.SelectedItem != null)
            {
                crsID = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("Please select course id", "Waring");
                return;
            }

            if (!isQuestDataValid())
            {
                MessageBox.Show("Please Enter Valid Data", "Waring");
                return;
            }

            string qbody    = qcont.Text.Trim();
            int    qdeg     = (int)qdegree.Value;
            string modelAns = qmodel.Text.Trim();

            OnlineExam ent   = new OnlineExam();
            var        quest = (from q in ent.Questions
                                where q.QuesId == questID
                                select q).First();

            quest.Qcontent = qbody;
            quest.Answer   = modelAns;
            quest.Degree   = qdeg;

            if (quest.Type.ToLower().Trim() == "mcq")
            {
                updateChoice(questID);
            }

            ent.SaveChanges();
            loadCourse();
            loadQuestions(crsID);
            questionInfo(questID);
            qcont.Text     = qmodel.Text = string.Empty;
            qdegree.Value  = 1;
            comboBox3.Text = string.Empty;
        }
Пример #10
0
        private void Courses_List_Load(object sender, EventArgs e)
        {
            OnlineExam ent     = new OnlineExam();
            var        student = (from s in ent.Students
                                  where s.Sid == studentID
                                  select s).First();

            var list = ent.getCoursesByDeptID(student.DeptId).ToList();

            dataGridView1.DataSource = list;
        }
Пример #11
0
        private void loadCourse()
        {
            OnlineExam ent = new OnlineExam();
            var        crs = ent.getInsCourses(instructorID);

            comboBox1.Items.Clear();
            foreach (var item in crs)
            {
                comboBox1.Items.Add($"{item.CrsId}, {item.CrsName}");
            }
        }
Пример #12
0
 private void checkIfNotFirstExam()
 {
     try
     {
         OnlineExam exam = new OnlineExam();
         var        msg  = exam.deleteStudentExam(studentID, examID);
     }
     catch (Exception)
     {
         return;
     }
 }
Пример #13
0
        private void Instructor_operations_Load(object sender, EventArgs e)
        {
            OnlineExam ent  = new OnlineExam();
            var        inst = ent.Select_Instructor(instructorID).First();
            var        dept = (from d in ent.Departments
                               where d.DeptId == inst.Department_ID
                               select d).First();

            label2.Text = inst.Instructor_ID.ToString();
            label4.Text = inst.Instructor_name;
            label6.Text = dept.DeptName;
        }
Пример #14
0
        private bool isNumberOfTFRange(int crsId, int numOfTF)
        {
            OnlineExam online  = new OnlineExam();
            var        mcqList = from mcq in online.Questions
                                 where mcq.CrsId == crsId && mcq.Type == "mcq"
                                 select mcq;

            if (numOfTF > mcqList.Count())
            {
                return(true);
            }

            return(false);
        }
Пример #15
0
        // add
        private void button1_Click(object sender, EventArgs e)
        {
            OnlineExam ent   = new OnlineExam();
            int        crsId = 0;
            string     desc  = textBox2.Text;

            if (comboBox2.SelectedItem != null)
            {
                crsId = int.Parse(comboBox2.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("invalid Course ID entred", "Waring");
                return;
            }
            int nMcq = (int)numericUpDown1.Value;

            if (isNumberOfMcqOutOfRange(crsId, nMcq))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }

            int nTF = (int)numericUpDown2.Value;

            if (isNumberOfTFRange(crsId, nTF))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }


            int  duration = (int)numericUpDown3.Value;
            Exam exam     = new Exam()
            {
                CrsId        = crsId,
                Edescription = desc,
                NumOfMcq     = nMcq,
                NumOfTF      = nTF,
                Eduration    = duration,
                Edate        = DateTime.Now
            };

            ent.Exams.Add(exam);
            ent.SaveChanges();
            comboBox1.Text       = comboBox2.Text = textBox2.Text = string.Empty;
            numericUpDown1.Value = numericUpDown2.Value = numericUpDown3.Value = 0;
            loadCourse();
            loadExams(crsId);
        }
Пример #16
0
        private void LoadCoureses()
        {
            OnlineExam ent     = new OnlineExam();
            var        student = (from s in ent.Students
                                  where s.Sid == studentID
                                  select s).First();

            var Courses = ent.getCoursesByDeptID(student.DeptId);

            listBox1.Items.Clear();
            foreach (var item in Courses)
            {
                listBox1.Items.Add(item.CrsName);
            }
        }
Пример #17
0
        private void StudentDashbord_Load(object sender, EventArgs e)
        {
            OnlineExam ent     = new OnlineExam();
            var        student = ent.Select_Student(id).First();

            IDValue.Text      = student.Student_ID.ToString();
            NameValue.Text    = student.Student_Name;
            addressValue.Text = student.Home_City;

            var deptName = (from d in ent.Departments
                            where d.DeptId == student.Department_ID
                            select d).First();

            dept.Text = deptName.DeptName;
        }
Пример #18
0
        private void loadExams(int crsID)
        {
            OnlineExam ent   = new OnlineExam();
            var        exams = from ex in ent.Exams
                               where ex.CrsId == crsID
                               select ex;


            dataGridView1.DataSource = exams.ToList();
            comboBox1.Items.Clear();
            foreach (var item in exams)
            {
                string exam = $"{item.Enumber}, {item.Edescription}";
                comboBox1.Items.Add(exam);
            }
        }
Пример #19
0
        private void loadSingleExamInfo(int examId)
        {
            OnlineExam ent  = new OnlineExam();
            var        exam = (from e in ent.Exams
                               where e.Enumber == examId
                               select e).First();

            // desc
            textBox2.Text = exam.Edescription;
            // number of Mcq
            numericUpDown1.Value = (int)exam.NumOfMcq;
            // number of Tf
            numericUpDown2.Value = (int)exam.NumOfTF;
            // duration
            numericUpDown3.Value = (int)exam.Eduration;
        }
Пример #20
0
        private void loadQuestions(int crsID)
        {
            OnlineExam ent = new OnlineExam();

            var quesList = from q in ent.Questions
                           where q.CrsId == crsID
                           select q;

            dataGridView1.DataSource = quesList.ToList();
            comboBox2.Items.Clear();
            foreach (var item in quesList)
            {
                string ques = $"{item.QuesId}, {item.Type}";
                comboBox2.Items.Add(ques);
            }
        }
Пример #21
0
        private void loadExam()
        {
            OnlineExam ent = new OnlineExam();

            /// Generate Exam  Quesstions
            var examQuestions = ent.generateExam(examID);

            examBody            = examQuestions.ToList();
            StudentAnswersSheet = new Dictionary <int, string>(examBody.Count);

            // show Exam Info
            var exam = (from e in ent.Exams
                        where e.Enumber == examID
                        select e).First();

            examNameValue.Text = exam.Edescription.Trim();
            timerValue.Text    = exam.Eduration.ToString() + 'M';
        }
Пример #22
0
        private void login(int id, string name)
        {
            OnlineExam ent = new OnlineExam();

            try
            {
                var student = (from s in ent.Students
                               where s.Sid == id && s.Fname == name
                               select s).First();
                this.Close();
                StudentDashbord dashbord = new StudentDashbord(student.Sid);
                dashbord.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("Not Authroized", "Access Denaied");
            }
        }
Пример #23
0
        private void login(int id, string name)
        {
            OnlineExam ent = new OnlineExam();

            try
            {
                var inst = (from s in ent.Instructors
                            where s.InsId == id && s.InsName == name
                            select s).First();
                this.Close();
                Instructor_operations instructor = new Instructor_operations(inst.InsId);
                this.Close();
                instructor.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("Not Authroized", "Access Denaied");
            }
        }
Пример #24
0
        private void updateChoice(int QuestID)
        {
            OnlineExam ent = new OnlineExam();

            if (!isChoiceDataValid())
            {
                MessageBox.Show("Please Enter All Data Rrequired", "Waring");
                return;
            }

            var chlist = ent.Select_MCQ_Question(QuestID).ToList();

            chlist[0].body = ansA.Text;
            chlist[1].body = ansB.Text;
            chlist[2].body = ansC.Text;
            chlist[3].body = ansD.Text;
            ent.SaveChanges();
            ansA.Text = ansB.Text = ansC.Text = ansD.Text = string.Empty;
        }
Пример #25
0
        private void loadMcqChoices(int questionID)
        {
            flowLayoutPanel2.Controls.Clear();
            flowLayoutPanel2.FlowDirection = FlowDirection.TopDown;
            OnlineExam onlineExam   = new OnlineExam();
            var        ques_Choices = from c in onlineExam.Ques_Choices
                                      where c.QuesId == questionID
                                      select c;

            foreach (var item in ques_Choices)
            {
                RadioButton radio  = new RadioButton();
                string      answer = $"{item.choices}) {item.body}";
                radio.Text            = answer;
                radio.Size            = new Size(200, 40);
                radio.Font            = new Font("Microsoft Sans Serif", 16);
                radio.CheckedChanged += new System.EventHandler(getAnswer);
                flowLayoutPanel2.Controls.Add(radio);
            }
        }
Пример #26
0
        private void button1_Click(object sender, EventArgs e)
        {
            int crsID = 0;

            if (comboBox1.SelectedItem != null)
            {
                crsID = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("Please select course id", "Waring");
                return;
            }

            if (!isQuestDataValid())
            {
                MessageBox.Show("Please Enter Valid Data", "Waring");
                return;
            }

            string qbody    = qcont.Text.Trim();
            string qtype    = comboBox3.SelectedItem.ToString();
            int    qdeg     = (int)qdegree.Value;
            string modelAns = qmodel.Text.Trim();

            OnlineExam ent  = new OnlineExam();
            var        last = ent.insertQuest(qtype, qdeg, qbody, modelAns, crsID).First();

            ////////////////////////////////////////////////////////////////////
            if (last.Type.ToLower() == "mcq")
            {
                insertChoicesForQuestById(last.QuesId);
            }


            loadCourse();
            loadQuestions(crsID);
            qcont.Text     = qmodel.Text = string.Empty;
            qdegree.Value  = 1;
            comboBox3.Text = string.Empty;
        }
Пример #27
0
        private void finish_Click(object sender, EventArgs e)
        {
            OnlineExam exam = new OnlineExam();

            checkIfNotFirstExam();

            foreach (var item in StudentAnswersSheet)
            {
                exam.Insert_Std_Answer(studentID, examID, item.Key, item.Value);
            }

            var res = exam.Calc_Student_Exam_Grade(studentID, examID).First();

            deletePrevGradeIfExist();

            exam.saveStudentGrade(studentID, examID, res.grade);

            MessageBox.Show($"Your Grade {res.grade}, and Degree {res.student_answer_degrees}", "Your Resault");
            StudentDashbord dashbord = new StudentDashbord(studentID);

            this.Close();
            dashbord.Show();
        }
Пример #28
0
        private void loadAvialbleExams(string cname)
        {
            OnlineExam ent = new OnlineExam();

            var course = ent.Select_Course_byName(cname).First();
            int cid    = course.Course_ID;
            var exames = from ex in ent.Exams
                         where ex.CrsId == cid
                         select ex;


            if (exames.Count() == 0)
            {
                flowLayoutPanel1.Controls.Clear();
                comboBox1.Items.Clear();
                comboBox1.Text = string.Empty;
                Label nolabel = new Label();
                nolabel.Text      = "There Is No Exams Available";
                nolabel.Size      = new Size(350, 30);
                nolabel.ForeColor = Color.FromArgb(239, 155, 25);
                nolabel.Font      = new Font("Microsoft Sans Serif", 18);
                flowLayoutPanel1.Controls.Add(nolabel);
                ExamID = -1;
                StartButtonStatus();
            }
            else
            {
                flowLayoutPanel1.Controls.Clear();
                comboBox1.Items.Clear();
                foreach (var item in exames)
                {
                    string exam = $"{item.Enumber}, {item.Edescription}";
                    comboBox1.Items.Add(exam);
                }
            }
        }
Пример #29
0
        // update
        private void Update_Click(object sender, EventArgs e)
        {
            int        examId = 0;
            int        crsId  = 0;
            OnlineExam ent    = new OnlineExam();

            if (comboBox2.SelectedItem != null)
            {
                crsId = int.Parse(comboBox2.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("invalid Course ID entred", "Waring");
                return;
            }

            if (comboBox1.SelectedItem != null)
            {
                examId = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("There Is No Exam Selected");
                return;
            }

            if (!isDataValid())
            {
                MessageBox.Show("There is Data Is Missing", "Waring");
                return;
            }

            string desc = textBox2.Text;
            int    nMcq = (int)numericUpDown1.Value;

            if (isNumberOfMcqOutOfRange(crsId, nMcq))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }

            int nTF = (int)numericUpDown2.Value;

            if (isNumberOfTFRange(crsId, nTF))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }


            int duration = (int)numericUpDown3.Value;

            if (duration < 10)
            {
                MessageBox.Show("Mim Duration is 10 Min");
                return;
            }

            var exam = (from ex in ent.Exams
                        where ex.Enumber == examId
                        select ex).First();

            exam.Edescription = desc;
            exam.Eduration    = duration;
            exam.NumOfMcq     = nMcq;
            exam.NumOfTF      = nTF;

            ent.SaveChanges();
            comboBox1.Text       = comboBox2.Text = textBox2.Text = string.Empty;
            numericUpDown1.Value = numericUpDown2.Value = numericUpDown3.Value = 0;
            loadCourse();
            loadExams(crsId);
        }