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();
        }
        public static string CreateAnswerData(string researchIdName, int skip)
        {
            StringBuilder sb = new StringBuilder();
            GoocaBoocaDataModels.GoocaBoocaDataBase gb = new GoocaBoocaDataBase();
            var research = gb.GetResearch(researchIdName);
            TsvBuilder tsvBuilder = new TsvBuilder();

            foreach (var user in gb.UserAnswerCompleted.Where(n => n.Research.ResearchId == research.ResearchId).OrderBy(n => n.UserAnswerCompletedId).Select(n => n.User).Skip(skip))
            {
                foreach (var questionAnsweres in user.QuestionAnswer)
                {
                    tsvBuilder.Add("q_" + questionAnsweres.Question.QuestionId, questionAnsweres.QuestionChoice.QuestionChoiceId);
                }
                foreach (var item in user.FreeAnswer)
                {
                    tsvBuilder.Add("q_" + item.Question.QuestionId, item.FreeTest);
                }
                foreach (var item in user.ItemAnswer.GroupBy(n => n.Item.Category).Select(n => new { n.Key, Count = n.Where(m => m.ItemAnswerChoice.Tag == "Key").Select(m=>m.Item).Distinct().Count() }))
                {
                    tsvBuilder.Add("c_" + item.Key.ItemCategoryId, item.Count);
                }
                foreach (var item in user.ItemAnswer)
                {
                    if (item.ItemAnswerChoice.Tag == "Key")
                    {
                        tsvBuilder.Add("i_" + item.Item.ItemId, 1);
                    }
                }
                Dictionary<string, attributeCount> countDic = new Dictionary<string, attributeCount>();
                foreach (var item in user.ItemAnswer)
                {
                    bool flag = false;
                    if (item.ItemAnswerChoice.Tag == "Key")
                    {
                        flag = true;
                    }
                    foreach (var attribute in item.Item.ItemAttribute)
                    {
                        var key = attribute.AttributeName + "_" + attribute.Value;
                        if (countDic.ContainsKey(key))
                        {
                            countDic[key].AllCount++;
                        }
                        else
                        {
                            countDic.Add(key, new attributeCount() { AllCount = 1, Group = attribute.AttributeName, Value = attribute.Value });
                        }
                        if (flag)
                        {
                            countDic[key].Count++;
                        }

                    }
                }
                foreach (var item in countDic)
                {
                    tsvBuilder.Add("attribute_" + item.Key, (item.Value.Rate).ToString());
                }
                tsvBuilder.NextLine();
            }
            return tsvBuilder.ToString();
        }