Example #1
0
 public bool noEmptyAnswer()
 {
     foreach (Control ctl in pnlAnswerGroup.Controls)
     {
         UCAnswerBox uc = (UCAnswerBox)ctl;
         if (string.IsNullOrEmpty(uc.Content))
         {
             return(false);
         }
     }
     return(true);
 }
Example #2
0
 public bool checkHasAnswerCorrect()
 {
     foreach (Control ctl in pnlAnswerGroup.Controls)
     {
         UCAnswerBox uc = (UCAnswerBox)ctl;
         if (uc.isAnswerCorrect)
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
        public bool checkOnlyOneAnswerCorrect()
        {
            int count = 0;

            foreach (Control ctl in pnlAnswerGroup.Controls)
            {
                UCAnswerBox uc = (UCAnswerBox)ctl;
                if (uc.isAnswerCorrect)
                {
                    count++;
                }
            }
            return(count == 1);
        }
Example #4
0
        public void setDataToForm(Question question)
        {
            txtId.Text      = question.Id;
            txtContent.Text = question.Content;
            int i = 0;

            foreach (Control ctl in pnlAnswerGroup.Controls)    //get data answers from 4 UCAnswerBox in pnlAnswerGroup
            {
                UCAnswerBox uc = (UCAnswerBox)ctl;
                uc.Content = question.listAnswer[i++];
                if (uc.Content == question.AnswerCorrect)
                {
                    uc.isAnswerCorrect = true;
                }
            }
            txtTopicInfor.Text = question.TopicInfor;
        }
Example #5
0
 /// <summary>
 /// Get information question EDIT from form input
 /// </summary>
 /// <returns></returns>
 public Question getQuestionEdit()
 {
     if (checkInputEdit())
     {
         Question question = new Question();
         question.Id      = txtId.Text;
         question.Content = txtContent.Text;
         foreach (Control ctl in pnlAnswerGroup.Controls)    //get data answers from 4 UCAnswerBox in pnlAnswerGroup
         {
             UCAnswerBox uc = (UCAnswerBox)ctl;
             if (uc.isAnswerCorrect)
             {
                 question.AnswerCorrect = uc.Content;
             }
             question.listAnswer.Add(uc.Content);
         }
         question.TopicInfor = txtTopicInfor.Text;
         return(question);
     }
     return(null);
 }