public static List <Question> GetQuestions(string sourceFile) { string fileFormat = GetFileFormat(sourceFile); // make questions (List<Question>) from xml file List <Question> qList = new List <Question>(); if (fileFormat == "qantasXML") { qList = Qantas.ReadFile(sourceFile); } if (fileFormat == "moodleXML") { qList = Moodle.ReadFile(sourceFile); } if (fileFormat == "lplusExcel") { qList = LPlus.ReadFile(sourceFile); } if (fileFormat == "pelesysXML") { qList = PelesysXML.ReadFile(sourceFile); } return(qList); }
public static List <Question> ReadFile(string xmlFile) { List <Question> qList = new List <Question>(); XmlDocument doc = JwXML.Load(xmlFile); string currentCategory = ""; XmlNodeList questionNodes = JwXML.GetNodes(doc, "/quiz/question"); for (int i = 0; i < questionNodes.Count; i++) { string type = JwXML.GetNodeAttribute(questionNodes[i], "type"); if (type == "category") { currentCategory = JwString.CleanCategory(questionNodes[i].InnerText); } else if (type == "multichoice" || type == "multichoiceset" || type == "truefalse") { Question q = Moodle.GetQuestionMultichoice(questionNodes[i]); q.category = currentCategory; qList.Add(q); } else if (type == "cloze") { Question q = Moodle.GetQuestionCloze(questionNodes[i]); q.category = currentCategory; qList.Add(q); } else if (type == "ddwtos") { Question q = Moodle.GetQuestionDragDropText(questionNodes[i]); q.category = currentCategory; qList.Add(q); } else if (type == "hotspot") { Question q = Moodle.GetQuestionHotspot(questionNodes[i]); q.category = currentCategory; qList.Add(q); } else { // default option - don't know what to do with question Question q = Moodle.GetQuestionUnknown(questionNodes[i]); q.category = currentCategory; qList.Add(q); } } return(qList); }