94 lines
2.7 KiB
C#
94 lines
2.7 KiB
C#
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<int> GetQuestionIDsByGroup(int value)
|
|
{
|
|
List<int> 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<string,string> GetOptionsByID(int value)
|
|
{
|
|
Dictionary<string, string> optionsDic = new Dictionary<string, string>();
|
|
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<string> GetAnswersByID(int value)
|
|
{
|
|
List<string> answersList = new List<string>();
|
|
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;
|
|
}
|
|
}
|