better matching

This commit is contained in:
2024-08-26 12:52:55 -06:00
parent 884e465df6
commit cafe04faf6
15 changed files with 232 additions and 33 deletions

View File

@@ -19,13 +19,21 @@ public record LocalQuizQuestionAnswer
if (questionType == QuestionType.MATCHING)
{
string matchingPattern = @"^\^ ?";
var textWithoutMatchDelimiter = Regex.Replace(input, matchingPattern, string.Empty).Trim();
string matchingPattern = @"^\^";
var textWithoutMatchDelimiter = Regex.Replace(input, matchingPattern, string.Empty);
var leftRightDelimiter = " - ";
return new LocalQuizQuestionAnswer()
{
Correct = true,
Text = textWithoutMatchDelimiter.Split('-')[0].Trim(),
MatchedText = string.Join("-", textWithoutMatchDelimiter.Split('-')[1..]).Trim(),
Text = textWithoutMatchDelimiter.Split(leftRightDelimiter)[0].Trim(),
MatchedText = string.Join(
leftRightDelimiter,
textWithoutMatchDelimiter
.Split(leftRightDelimiter)[1..]
.Select(a => a.Trim())
.Where(a => a != "")
).Trim(),
};
}