public static string CreateQuestionData(string researchIdName) { StringBuilder sb = new StringBuilder(); GoocaBoocaDataModels.GoocaBoocaDataBase gb = new GoocaBoocaDataBase(); var research = gb.GetResearch(researchIdName); sb.AppendLine("Key\tText\tType\tAnswers"); List<QuestionLine> list = new List<QuestionLine>(); foreach (var item in research.Questiones.Where(n => n.IsActive == true)) { QuestionLine ql = new QuestionLine() { Key = "q_" + item.QuestionId.ToString(), Text = item.QuestionText, Type = "順序" }; if (item.QuestionType == "FreeText") { ql.Type = "文字列"; } foreach (var questionChoices in item.QuestionChoices.Where(n => n.IsActive == true)) { ql.AddAnswer(questionChoices.QuestionChoiceId.ToString(), questionChoices.QuestionChoiceText); } list.Add(ql); } foreach (var item in research.ItemCategory.Where(n => n.IsActive == true)) { QuestionLine ql = new QuestionLine() { Key = "c_" + item.ItemCategoryId.ToString(), Text = item.ItemCategoryName, Type = "数値" }; int cc = (research.AnswerCount / research.ItemCategory.Where(n => n.IsActive).Count()); for (int i = 0; i < cc + 1; i++) { ql.AddAnswer(i.ToString(), i.ToString()); } list.Add(ql); } foreach (var itemCategory in research.ItemCategory.Where(n => n.IsActive)) { foreach (var item in itemCategory.Items) { QuestionLine ql = new QuestionLine() { Key = "i_" + item.ItemId.ToString(), Text = item.Category.ItemCategoryName + ":" + item.ItemName + "{" + research.Tag + item.ItemName + "}", Type = "数値" }; list.Add(ql); //foreach (var itemAnswerChoice in research.ItemAnswerChoice.Where(n => n.IsActive)) //{ // ql.AddAnswer(itemAnswerChoice.ItemAnswerChoiceId.ToString(), itemAnswerChoice.AnswerString); //} } } Dictionary<string, List<string>> attribuuteDic = new Dictionary<string, List<string>>(); foreach (var item in gb.ItemAttributes.Where(n => n.Item.Resarch.ResearchId == research.ResearchId && n.IsActive == true)) { if (attribuuteDic.ContainsKey(item.AttributeName)) { attribuuteDic[item.AttributeName].Add(item.Value); } else { attribuuteDic.Add(item.AttributeName, new List<string>() { item.Value }); } } foreach (var item in attribuuteDic) { foreach (var item2 in item.Value.Distinct()) { QuestionLine ql = new QuestionLine() { Key = "attribute_" + item.Key + "_" + item2, Text = "属性:" + item.Key + "_" + item2, Type = "数値", AnswerNumericList = new List<double>() { 0, 0.25, 0.5, 0.75, 1 } }; list.Add(ql); } } foreach (var item in list) { sb.AppendLine(item.ToString()); } return sb.ToString(); }