mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
added shorter syntax for multipel choice
This commit is contained in:
@@ -49,7 +49,7 @@ public record LocalQuizQuestion
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string[] _validFirstAnswerDelimiters = ["*a)", "a)", "[ ]", "[*]", "^"];
|
||||
private static readonly string[] _validFirstAnswerDelimiters = ["*a)", "a)", "*)", ")", "[ ]", "[*]", "^"];
|
||||
|
||||
public static LocalQuizQuestion ParseMarkdown(string input, int questionIndex)
|
||||
{
|
||||
@@ -115,15 +115,18 @@ public record LocalQuizQuestion
|
||||
return "short_answer";
|
||||
|
||||
var answerLines = getAnswersGroupedByLines(linesWithoutPoints, questionIndex);
|
||||
var firstAnswerLine = answerLines.First();
|
||||
var isMultipleChoice =
|
||||
answerLines.First().StartsWith("a)")
|
||||
|| answerLines.First().StartsWith("*a)");
|
||||
firstAnswerLine.StartsWith("a)")
|
||||
|| firstAnswerLine.StartsWith("*a)")
|
||||
|| firstAnswerLine.StartsWith("*)")
|
||||
|| firstAnswerLine.StartsWith(")");
|
||||
if (isMultipleChoice)
|
||||
return "multiple_choice";
|
||||
|
||||
var isMultipleAnswer =
|
||||
answerLines.First().StartsWith("[ ]")
|
||||
|| answerLines.First().StartsWith("[*]");
|
||||
firstAnswerLine.StartsWith("[ ]")
|
||||
|| firstAnswerLine.StartsWith("[*]");
|
||||
|
||||
if (isMultipleAnswer)
|
||||
return "multiple_answers";
|
||||
@@ -150,7 +153,7 @@ public record LocalQuizQuestion
|
||||
|
||||
var answerLinesRaw = linesWithoutPoints[indexOfAnswerStart..];
|
||||
|
||||
var answerStartPattern = @"^(\*?[a-z]\))|\[\s*\]|\[\*\]|\^";
|
||||
var answerStartPattern = @"^(\*?[a-z]?\))|\[\s*\]|\[\*\]|\^";
|
||||
var answerLines = answerLinesRaw.Aggregate(new List<string>(), (acc, line) =>
|
||||
{
|
||||
var isNewAnswer = Regex.IsMatch(line, answerStartPattern);
|
||||
|
||||
@@ -15,7 +15,7 @@ public record LocalQuizQuestionAnswer
|
||||
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)
|
||||
@@ -23,7 +23,7 @@ public record LocalQuizQuestionAnswer
|
||||
{
|
||||
Correct = true,
|
||||
Text = text.Split('-')[0].Trim(),
|
||||
MatchedText = string.Join("", text.Split('-')[1..]).Trim(),
|
||||
MatchedText = string.Join("-", text.Split('-')[1..]).Trim(),
|
||||
};
|
||||
|
||||
return new LocalQuizQuestionAnswer()
|
||||
|
||||
Reference in New Issue
Block a user