private void cmdDelete_Click(object sender, EventArgs e) { if (lstAnswerList.SelectedIndex > -1) { ((multiple_choice_answer)lstAnswerList.SelectedItem).Delete(); lstAnswerList.Items.Remove(lstAnswerList.SelectedItem); InitializeAnswers(); ForceAnswerReorder(); _lastAnswer = null; } }
private void ShowAnswer() { if (lstAnswerList.SelectedIndex < 0) { txtAnswerText.Enabled = false; } else { _lastAnswer = (multiple_choice_answer)lstAnswerList.SelectedItem; txtAnswerText.Text = _lastAnswer.answer_text; txtAnswerText.Focus(); txtAnswerText.Enabled = true; } }
private void GenerateMultipleChoiceAnswers(string answersToParse, int questionID) { string[] answers = answersToParse.Split(",".ToCharArray()); multiple_choice_answer mca = new multiple_choice_answer(); mca.question_id = questionID; for (int i = 0; i < answers.Length; i++) { mca.order_id = i; mca.answer_text = CommonFunctions.TrimSpaces(answers[i]); mca.Save(); } }
private void AddNew() { multiple_choice_answer toAdd = new multiple_choice_answer(); toAdd.question_id = _formQuestion.id; toAdd.order_id = lstAnswerList.Items.Count; toAdd.answer_text = "Enter your text here..."; toAdd.Save(); lstAnswerList.Items.Add(toAdd); lstAnswerList.SelectedItem = toAdd; ForceAnswerReorder(); txtAnswerText.Focus(); }
/// <summary> /// /// </summary> public List <multiple_choice_answer> GetMultipleChoiceAnswers() { List <multiple_choice_answer> toReturn = new List <multiple_choice_answer>(); DataTable linkedNotes = Search("SELECT * FROM multiple_choice_answers WHERE question_id = " + id + " order by order_id"); foreach (DataRow aAnswer in linkedNotes.Rows) { multiple_choice_answer m = new multiple_choice_answer(); m.Load(aAnswer); toReturn.Add(m); } toReturn.Sort(); _multipleChoiceAnswers = toReturn; return(toReturn); }