mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
can parse at least some markdown quiz questions
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace LocalModels;
|
||||
|
||||
public record LocalQuizQuestionAnswer
|
||||
@@ -11,4 +13,17 @@ public record LocalQuizQuestionAnswer
|
||||
|
||||
public string HtmlText => Markdig.Markdown.ToHtml(Text);
|
||||
|
||||
public static LocalQuizQuestionAnswer ParseMarkdown(string input)
|
||||
{
|
||||
var isCorrect = input[0] == '*' || input[1] == '*';
|
||||
string startingQuestionPattern = @"^(?:\*[a-z]\))|\[\s*\]|\[\*\] ";
|
||||
var text = Regex.Replace(input, startingQuestionPattern, string.Empty).Trim();
|
||||
|
||||
return new LocalQuizQuestionAnswer()
|
||||
{
|
||||
Correct = isCorrect,
|
||||
Text=text,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user