/// <summary> /// sets the question stem list. /// </summary> public void SetQuestionStemList() { QuestionStemList = new List <QuestionLineItem>(); QuestionGrid.Wait(3); QuestionContentWebElementList = QuestionContentRows.WaitForElements(5); if (Driver.WrappedDriver.GetType() == typeof(DummyDriver)) { DummyWebElement dummy1 = new DummyWebElement(); dummy1.Text = "banana"; DummyWebElement dummy2 = new DummyWebElement(); dummy2.Text = "carrot"; DummyWebElement dummy3 = new DummyWebElement(); dummy3.Text = "eggplant"; List <IWebElement> list = new List <IWebElement> { dummy1, dummy2, dummy3 }; QuestionContentWebElementList = new ReadOnlyCollection <IWebElement>(list); } int index = 0; foreach (var webElement in QuestionContentWebElementList) { string question = webElement.Text.Trim(); Report.Write("QuestionLineItem index: '" + index + "'; question: '" + question); var questionLineItem = new QuestionLineItem(index, question); QuestionStemList.Add(questionLineItem); index++; } }
private void submitSurvey(object sender, RoutedEventArgs e) { QuestionGrid.ApplyTemplate(); int i = 0; foreach (string s in questions) { var x = s.Replace(" ", "WASASPACE"); var text = (TextBox)this.FindName(x); using (MySqlConnection conn = new MySqlConnection("Server=mysql-509.cs.iastate.edu; Database=db509t03;User Id=dbu509t03;Password = zebr8p@AgEsU;")) { using (MySqlCommand cmd = new MySqlCommand()) { cmd.Connection = conn; conn.Open(); string t = text.Text; if (t == "") { t = "Not Answered"; } cmd.CommandText = "INSERT INTO SurveyAnswers (SurveyQuestionID,SurveyAnswer) VALUES (" + questionIDs[i].ToString() + ",'" + t + "');"; cmd.ExecuteNonQuery(); } } i++; } this.Close(); }
/// <summary> /// sets the question stem list. /// </summary> /// <param name="questionStem">list of question stems</param> public void SetQuestionStemList(List <string> questionStem) { QuestionStemList = new List <QuestionLineItem>(); QuestionGrid.Wait(3); QuestionContentWebElementList = QuestionContentRows.WaitForElements(5); if (Driver.WrappedDriver.GetType() == typeof(DummyDriver)) { DummyWebElement dummy1 = new DummyWebElement(); dummy1.Text = "banana"; DummyWebElement dummy2 = new DummyWebElement(); dummy2.Text = "carrot"; DummyWebElement dummy3 = new DummyWebElement(); dummy3.Text = "eggplant"; List <IWebElement> list = new List <IWebElement> { dummy1, dummy2, dummy3 }; QuestionContentWebElementList = new ReadOnlyCollection <IWebElement>(list); } foreach (var webElement in QuestionContentWebElementList) { string question = webElement.Text.Trim(); if (questionStem.Contains(question)) { int index = 1 + questionStem.IndexOf(question); Report.Write("QuestionLineItem index: '" + index + "'; question: '" + question); var questionLineItem = new QuestionLineItem(index, question); QuestionStemList.Add(questionLineItem); } else { throw new Exception("Expected to find the question: '" + question + "', but it does not exist in the question parts."); } } }