protected void ParseQuestion(Lesson lesson, IList <string> lines) { const string Separator = "_"; var match = TextParseEnUs.QuestionPattern.Match(lines[0]); var questionOrder = match.Groups[1].Value; lines[0] = lines[0].Substring(match.Value.Length); var questions = TextParseEnUs.GetSubquestions(lines.Where(line => !string.IsNullOrWhiteSpace(line)).ToList()); var count = 1; foreach (var line in questions) { var id = string.Join(Separator, this.Year, lesson.DayQuestions.Count(), questionOrder, count++); this.AddQuestion(lesson, match.Groups[0].Value + line, id); } }
protected void ParseSubquestion(Lesson lesson, IList <string> lines) { const string Separator = "_"; var match = TextParseEnUs.SubQuestionPattern.Match(lines[0]); lines[0] = lines[0].Substring(match.Value.Length); var questions = TextParseEnUs.GetSubquestions(lines.Where(line => !string.IsNullOrWhiteSpace(line)).ToList()); var parts = lesson.DayQuestions.Last().Questions.Last().Id.Split(new[] { Separator }, StringSplitOptions.None).ToList(); var count = int.Parse(parts.Last()); foreach (var line in questions) { var id = string.Join(Separator, parts[0], parts[1], parts[2], ++count); this.AddQuestion(lesson, parts[2] + ". " + match.Groups[0].Value + line, id); } }