/// <summary> /// 透過特定Key組合法取得單一Question /// </summary> /// <param name="qPkey"></param> /// <param name="QType"></param> /// <returns></returns> public XElement GetQsQByKey1(QuestionPKey qPkey) { XElement retVal = null; if (_SubjectDict.ContainsKey(qPkey.SubjectLabel)) { foreach (XElement elm in _SubjectDict[qPkey.SubjectLabel].Elements("QG")) { if (elm.Attribute("label") != null) { if (elm.Attribute("label").Value == qPkey.QGLabel) { foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { if (elmQ.Attribute("label").Value == qPkey.QLabel && elmQ.Attribute("type").Value == qPkey.QType) { retVal = elmQ; } } } } } } return(retVal); }
/// <summary> /// 透過 SubjectLabel 取得題目 /// </summary> /// <param name="SubjectLabel"></param> /// <returns></returns> public List <QuestionPKey> GetQuestionListBySubjectLabel(string SubjectLabel) { List <QuestionPKey> retVal = new List <QuestionPKey>(); if (_SubjectDict.ContainsKey(SubjectLabel)) { foreach (XElement elm in _SubjectDict[SubjectLabel].Elements("QG")) { if (elm.Attribute("label") != null) { foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { QuestionPKey QPK = new QuestionPKey(); QPK.dataElement = elmQ; QPK.Q_Name = elmQ.Attribute("name").Value; QPK.QGLabel = elm.Attribute("label").Value; QPK.QLabel = elmQ.Attribute("label").Value; QPK.QType = elmQ.Attribute("type").Value; QPK.TemplateID = _TemplateIDDict[SubjectLabel]; QPK.SubjectLabel = SubjectLabel; retVal.Add(QPK); } } } } return(retVal); }
/// <summary> /// 取得所有題目 /// </summary> /// <returns></returns> public List <QuestionPKey> GetAllQuestionList() { List <string> ChoiceTmp = new List <string> (); List <QuestionPKey> retVal = new List <QuestionPKey>(); foreach (string SubjectLabel in _SubjectDict.Keys) { foreach (XElement elm in _SubjectDict[SubjectLabel].Elements("QG")) { ChoiceTmp.Clear(); if (elm.Element("Choices") != null) { foreach (XElement elmCho in elm.Element("Choices").Elements("Item")) { ChoiceTmp.Add(elmCho.Attribute("label").Value); } } if (elm.Attribute("label") != null) { foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { QuestionPKey QPK = new QuestionPKey(); QPK.dataElement = elmQ; QPK.Q_Name = elmQ.Attribute("name").Value; QPK.QGLabel = elm.Attribute("label").Value; QPK.QLabel = elmQ.Attribute("label").Value; QPK.QType = elmQ.Attribute("type").Value; QPK.TemplateID = _TemplateIDDict[SubjectLabel]; QPK.SubjectLabel = SubjectLabel; QPK.Q_Choice = ""; if (ChoiceTmp.Count > 0) { QPK.Q_Choice = string.Join(";", ChoiceTmp.ToArray()); } retVal.Add(QPK); } } } } return(retVal); }
/// <summary> /// 透過特定Key組合法存入Question /// </summary> /// <param name="qPkey"></param> /// <param name="QType"></param> /// <param name="data"></param> public void SetQsQElement(QuestionPKey qPkey) { if (_SubjectDict.ContainsKey(qPkey.SubjectLabel)) { foreach (XElement elm in _SubjectDict[qPkey.SubjectLabel].Elements("QG")) { if (elm.Attribute("label") != null) { if (elm.Attribute("label").Value == qPkey.QGLabel) { foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { if (elmQ.Attribute("label").Value == qPkey.QLabel && elmQ.Attribute("type").Value == qPkey.QType) { elm.Remove(); } } elm.Element("Qs").Add(qPkey.dataElement); } } } } }
/// <summary> /// 取得所有題目 /// </summary> /// <returns></returns> public List<QuestionPKey> GetAllQuestionList() { List<string> ChoiceTmp = new List<string> (); List<QuestionPKey> retVal = new List<QuestionPKey>(); foreach(string SubjectLabel in _SubjectDict.Keys) { foreach (XElement elm in _SubjectDict[SubjectLabel].Elements("QG")) { ChoiceTmp.Clear(); if(elm.Element("Choices")!=null) { foreach(XElement elmCho in elm.Element("Choices").Elements("Item")) ChoiceTmp.Add(elmCho.Attribute("label").Value); } if (elm.Attribute("label") != null) foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { QuestionPKey QPK = new QuestionPKey(); QPK.dataElement = elmQ; QPK.Q_Name = elmQ.Attribute("name").Value; QPK.QGLabel = elm.Attribute("label").Value; QPK.QLabel = elmQ.Attribute("label").Value; QPK.QType = elmQ.Attribute("type").Value; QPK.TemplateID = _TemplateIDDict[SubjectLabel]; QPK.SubjectLabel = SubjectLabel; QPK.Q_Choice = ""; if (ChoiceTmp.Count > 0) QPK.Q_Choice = string.Join(";", ChoiceTmp.ToArray()); retVal.Add(QPK); } } } return retVal; }
/// <summary> /// 透過特定Key組合法存入Question /// </summary> /// <param name="qPkey"></param> /// <param name="QType"></param> /// <param name="data"></param> public void SetQsQElement(QuestionPKey qPkey) { if (_SubjectDict.ContainsKey(qPkey.SubjectLabel)) { foreach (XElement elm in _SubjectDict[qPkey.SubjectLabel].Elements("QG")) { if (elm.Attribute("label") != null) if (elm.Attribute("label").Value == qPkey.QGLabel) { foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { if (elmQ.Attribute("label").Value == qPkey.QLabel && elmQ.Attribute("type").Value == qPkey.QType) { elm.Remove(); } } elm.Element("Qs").Add(qPkey.dataElement); } } } }
/// <summary> /// 透過 SubjectLabel 取得題目 /// </summary> /// <param name="SubjectLabel"></param> /// <returns></returns> public List<QuestionPKey> GetQuestionListBySubjectLabel(string SubjectLabel) { List<QuestionPKey> retVal = new List<QuestionPKey>(); if (_SubjectDict.ContainsKey(SubjectLabel)) { foreach (XElement elm in _SubjectDict[SubjectLabel].Elements("QG")) { if (elm.Attribute("label") != null) foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { QuestionPKey QPK = new QuestionPKey(); QPK.dataElement = elmQ; QPK.Q_Name = elmQ.Attribute("name").Value; QPK.QGLabel = elm.Attribute("label").Value; QPK.QLabel = elmQ.Attribute("label").Value; QPK.QType = elmQ.Attribute("type").Value; QPK.TemplateID = _TemplateIDDict[SubjectLabel]; QPK.SubjectLabel = SubjectLabel; retVal.Add(QPK); } } } return retVal; }
/// <summary> /// 透過特定Key組合法取得單一Question /// </summary> /// <param name="qPkey"></param> /// <param name="QType"></param> /// <returns></returns> public XElement GetQsQByKey1(QuestionPKey qPkey) { XElement retVal = null; if (_SubjectDict.ContainsKey(qPkey.SubjectLabel)) { foreach (XElement elm in _SubjectDict[qPkey.SubjectLabel].Elements("QG")) { if(elm.Attribute("label") !=null ) if (elm.Attribute("label").Value == qPkey.QGLabel) { foreach (XElement elmQ in elm.Element("Qs").Elements("Q")) { if (elmQ.Attribute("label").Value == qPkey.QLabel && elmQ.Attribute("type").Value == qPkey.QType) { retVal = elmQ; } } } } } return retVal; }