public bool noEmptyAnswer() { foreach (Control ctl in pnlAnswerGroup.Controls) { UCAnswerBox uc = (UCAnswerBox)ctl; if (string.IsNullOrEmpty(uc.Content)) { return(false); } } return(true); }
public bool checkHasAnswerCorrect() { foreach (Control ctl in pnlAnswerGroup.Controls) { UCAnswerBox uc = (UCAnswerBox)ctl; if (uc.isAnswerCorrect) { return(true); } } return(false); }
public bool checkOnlyOneAnswerCorrect() { int count = 0; foreach (Control ctl in pnlAnswerGroup.Controls) { UCAnswerBox uc = (UCAnswerBox)ctl; if (uc.isAnswerCorrect) { count++; } } return(count == 1); }
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; }
/// <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); }