mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 23:58:31 -06:00
testing markdown storage and retrieval
This commit is contained in:
25
Management/Models/Local/Quiz/LocalQuizQuestionAnswer.cs
Normal file
25
Management/Models/Local/Quiz/LocalQuizQuestionAnswer.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace LocalModels;
|
||||
|
||||
public record LocalQuizQuestionAnswer
|
||||
{
|
||||
//correct gets a weight of 100 in canvas
|
||||
public bool Correct { get; init; }
|
||||
public string Text { get; init; } = string.Empty;
|
||||
|
||||
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