/// <summary> /// This method stores the question and its responses provided by the user in the object of TestQuestion class. /// </summary> private void StoreQuestionResponses() { TestQuestion ques = new TestQuestion(); ques.QuestionText = quesTxt.Text; ques.Number = quesCount; if (selectedQuesType == QuesTypeVal.MCQ.ToString()) { ques.Type = "MCQ"; var option1 = new TestQuestionOption1 { Answer = "No", Value = textBox2.Text }; var option2 = new TestQuestionOption2 { Answer = "No", Value = textBox3.Text }; var option3 = new TestQuestionOption3 { Answer = "No", Value = textBox4.Text }; var option4 = new TestQuestionOption4 { Answer = "No", Value = textBox5.Text }; if (radioButton1.Checked == true) { option1.Answer = "Yes"; } else if (radioButton2.Checked == true) { option2.Answer = "Yes"; } else if (radioButton3.Checked == true) { option3.Answer = "Yes"; } else if (radioButton4.Checked == true) { option4.Answer = "Yes"; } ques.Option1 = option1; ques.Option2 = option2; ques.Option3 = option3; ques.Option4 = option4; } else if (selectedQuesType == QuesTypeVal.Text.ToString()) { ques.Type = "Text"; TestQuestionAnswer ans = new TestQuestionAnswer(); ans.Text = textTypeAnswerTxt.Text; ques.Answer = ans; } else if (selectedQuesType == QuesTypeVal.EssayText.ToString()) { ques.Type = "EssayText"; ques.NumberOfParagraphs = Convert.ToInt32(textTypeAnswerTxt.Text); ques.TotalNumberOfWords = Convert.ToInt32(noOfKeywordsTxt.Text); TestQuestionAnswer essayAns = new TestQuestionAnswer(); List<string> keywordList = new List<string>(); keywordList = essayAnsTxt.Text.Split(';').ToList<string>(); essayAns.Keyword = new string[keywordList.Count]; int i = 0; foreach (string k in keywordList) { essayAns.Keyword[i] = k; i++; } ques.Answer = essayAns; } testQuesList.Add(ques); }