mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
started to test markdown quiz format
This commit is contained in:
@@ -4,12 +4,37 @@ public record LocalQuizQuestion
|
||||
{
|
||||
public ulong? CanvasId { get; set; }
|
||||
public string Id { get; set; } = "";
|
||||
public string Text { get; init; } = string.Empty;
|
||||
public string Text { get; init; } = string.Empty;
|
||||
public string HtmlText => Markdig.Markdown.ToHtml(Text);
|
||||
public string QuestionType { get; init; } = string.Empty;
|
||||
public int Points { get; init; }
|
||||
public IEnumerable<LocalQuizQuestionAnswer> Answers { get; init; } =
|
||||
Enumerable.Empty<LocalQuizQuestionAnswer>();
|
||||
public string ToMarkdown()
|
||||
{
|
||||
var answerArray = Answers.Select((answer, i) =>
|
||||
{
|
||||
var questionLetter = (char)(i + 97);
|
||||
var isMultipleChoice = QuestionType == "multiple_choice";
|
||||
|
||||
var correctIndicator = answer.Correct ? "*" : isMultipleChoice ? "" : " ";
|
||||
|
||||
|
||||
var questionTypeIndicator = isMultipleChoice
|
||||
? $"{correctIndicator}{questionLetter}) "
|
||||
: $"[{correctIndicator}] ";
|
||||
|
||||
var textWithSpecificNewline = answer.Text.Replace(Environment.NewLine, Environment.NewLine + " ");
|
||||
return $"{questionTypeIndicator}{textWithSpecificNewline}";
|
||||
});
|
||||
var answersText = string.Join(Environment.NewLine, answerArray);
|
||||
|
||||
return $@"Points: {Points}
|
||||
{Text}
|
||||
{answersText}
|
||||
---
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
public static class QuestionType
|
||||
|
||||
Reference in New Issue
Block a user