Beispiel #1
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();
        }
Beispiel #2
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;
        }