mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
adding matching suppiort
This commit is contained in:
@@ -8,14 +8,24 @@ public record LocalQuizQuestionAnswer
|
||||
public bool Correct { get; init; }
|
||||
public string Text { get; init; } = string.Empty;
|
||||
|
||||
public string? MatchedText { get; init; }
|
||||
|
||||
public string HtmlText => Markdig.Markdown.ToHtml(Text);
|
||||
|
||||
public static LocalQuizQuestionAnswer ParseMarkdown(string input)
|
||||
public static LocalQuizQuestionAnswer ParseMarkdown(string input, string questionType)
|
||||
{
|
||||
var isCorrect = input[0] == '*' || input[1] == '*';
|
||||
string startingQuestionPattern = @"^(\*?[a-z]\))|\[\s*\]|\[\*\] ";
|
||||
string startingQuestionPattern = @"^(\*?[a-z]\))|\[\s*\]|\[\*\]|\^ ";
|
||||
var text = Regex.Replace(input, startingQuestionPattern, string.Empty).Trim();
|
||||
|
||||
if(questionType == QuestionType.MATCHING)
|
||||
return new LocalQuizQuestionAnswer()
|
||||
{
|
||||
Correct = true,
|
||||
Text = text.Split('-')[0].Trim(),
|
||||
MatchedText = string.Join("", text.Split('-')[1..]).Trim(),
|
||||
};
|
||||
|
||||
return new LocalQuizQuestionAnswer()
|
||||
{
|
||||
Correct = isCorrect,
|
||||
|
||||
Reference in New Issue
Block a user