public List <CallQuestion> GetCallQuestions() { List <CallQuestion> toReturn = new List <CallQuestion>(); List <question> claimQuestions = LinkedClaim.Questions; foreach (question q in claimQuestions) { toReturn.Add(new CallQuestion(q, this)); } List <choice> callChoices = new List <choice>(); DataTable linkedChoices = Search("SELECT * FROM choices WHERE call_id = " + id + " UNION SELECT * FROM large_choices WHERE call_id = " + id); foreach (DataRow aChoice in linkedChoices.Rows) { choice c = new choice(); c.Load(aChoice); c.LinkedCall = this; CallQuestion cq = FindCallQuestion(c.question_id, toReturn); if (cq != null) { c.LinkedQuestion = cq.Question; cq.Choice = c; } } return(toReturn); }
private CallQuestion FindCallQuestion(int id, List <CallQuestion> list) { foreach (CallQuestion cq in list) { if (cq.Question.id == id) { return(cq); } if (cq.SubQuestions.Count > 0) { CallQuestion subcq = FindCallQuestion(id, cq.SubQuestions); if (subcq != null) { return(subcq); } } } return(null); }
private void AddQuestionToTree(CallQuestion callQuestion, TreeNode parentNode) { CallTreeQuestionNode newNode = new CallTreeQuestionNode(callQuestion.Question); if (callQuestion.IsAnswered) { if (callQuestion.Question.type == question.QuestionTypes.Category) { newNode.ImageIndex = 2; newNode.SelectedImageIndex = 2; } else { newNode.ImageIndex = 4; newNode.SelectedImageIndex = 4; } if (callQuestion.Choice != null) { newNode.Choice = callQuestion.Choice; } else if (callQuestion.Question.type != question.QuestionTypes.Category) { } } else { if (callQuestion.Question.type == question.QuestionTypes.Category) { newNode.ImageIndex = 1; newNode.SelectedImageIndex = 1; } else { newNode.ImageIndex = 3; newNode.SelectedImageIndex = 3; } } newNode.Text = callQuestion.Question.text; if (newNode.Choice != null) { if (newNode.Question.type == question.QuestionTypes.YesNo) { if (newNode.Choice.answer == true.ToString()) { newNode.Text += ": Yes"; } else if (newNode.Choice.answer == false.ToString()) { newNode.Text += ": No"; } } else { newNode.Text += ": " + newNode.Choice.answer; } } newNode.Name = callQuestion.Question.id.ToString(); if (parentNode == null) { tvwCall.Nodes.Add(newNode); } else { parentNode.Nodes.Add(newNode); } foreach (CallQuestion cq in callQuestion.SubQuestions) { if (!String.IsNullOrEmpty(cq.Question.required_answer)) { if (!IsCallInProgress) { if (cq.IsAnswered) { AddQuestionToTree(cq, newNode); } } else { if ((callQuestion.Choice != null) && (callQuestion.Choice.answer == cq.Question.required_answer)) { AddQuestionToTree(cq, newNode); } } } else { if (!IsCallInProgress) { if (cq.IsAnswered == true) { // If the parent question is answered then subquestions must be also // This means a new call will load all questions, but existing calls // will only load questions that have been answered AddQuestionToTree(cq, newNode); } } else { AddQuestionToTree(cq, newNode); } } } }
private void AddQuestionToTree(question question, TreeNode parentNode) { CallQuestion callQuestion = new CallQuestion(question, CurrentCall); AddQuestionToTree(callQuestion, parentNode); }