using System.Collections.Generic; public class QuestionChoiceDataModel { readonly ExcelData excelData; public QuestionChoiceDataModel(ExcelData e) { excelData = e; } public string GetName(int value) { return excelData.GetQuestion_Choice(value).name; } public List GetQuestionIDsByGroup(int value) { List list = new(); for (int i = 0; i < excelData.allQuestion_Choice.Count; i++) { if (value == excelData.allQuestion_Choice[i].group) { list.Add(excelData.allQuestion_Choice[i].id); } } return list; } public Dictionary GetOptionsByID(int value) { Dictionary optionsDic = new Dictionary(); foreach (var item in excelData.allQuestion_Choice) { if (item.id == value) { string[] tempStrs = item.options.Replace("\n","").Split("|"); foreach (var itemstr in tempStrs) { string[] tempOStr = itemstr.Split("))"); if (tempOStr.Length>=2) { optionsDic.Add(tempOStr[0], tempOStr[1]); } } } } return optionsDic; } public string GetQuestionByID(int value) { string str = ""; foreach (var item in excelData.allQuestion_Choice) { if (item.id == value) { str= item.question; } } return str; } public string GetAnalysisByID(int value) { string str = ""; foreach (var item in excelData.allQuestion_Choice) { if (item.id == value) { str = item.analysis; } } return str; } public List GetAnswersByID(int value) { List answersList = new List(); foreach (var item in excelData.allQuestion_Choice) { if (item.id == value) { string[] tempStrs = item.answers.Split("|"); foreach (var itemStr in tempStrs) { answersList.Add(itemStr); } } } return answersList; } public string GetAnswerByID(int value) { return excelData.GetQuestion_Choice(value).answers; } public string GetType(int value) { return excelData.GetQuestion_Choice(value).type; } }