more fixes for matching

This commit is contained in:
2023-12-12 12:13:25 -07:00
parent a4b260941f
commit fd582b4e19
2 changed files with 31 additions and 5 deletions

View File

@@ -15,17 +15,22 @@ public record LocalQuizQuestionAnswer
public static LocalQuizQuestionAnswer ParseMarkdown(string input, string questionType)
{
var isCorrect = input[0] == '*' || input[1] == '*';
string startingQuestionPattern = @"^(\*?[a-z]?\))|\[\s*\]|\[\*\]|\^ ";
var text = Regex.Replace(input, startingQuestionPattern, string.Empty).Trim();
if(questionType == QuestionType.MATCHING)
if (questionType == QuestionType.MATCHING)
{
string matchingPattern = @"^\^ ?";
var textWithoutMatchDelimiter = Regex.Replace(input, matchingPattern, string.Empty).Trim();
return new LocalQuizQuestionAnswer()
{
Correct = true,
Text = text.Split('-')[0].Trim(),
MatchedText = string.Join("-", text.Split('-')[1..]).Trim(),
Text = textWithoutMatchDelimiter.Split('-')[0].Trim(),
MatchedText = string.Join("-", textWithoutMatchDelimiter.Split('-')[1..]).Trim(),
};
}
string startingQuestionPattern = @"^(\*?[a-z]?\))|\[\s*\]|\[\*\]|\^ ";
var text = Regex.Replace(input, startingQuestionPattern, string.Empty).Trim();
return new LocalQuizQuestionAnswer()
{
Correct = isCorrect,