mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
refactoring files to be located by feature
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { QuestionType } from "../localQuizQuestion";
|
||||
import { LocalQuizQuestionAnswer } from "../localQuizQuestionAnswer";
|
||||
|
||||
const parseMatchingAnswer = (input: string) => {
|
||||
const matchingPattern = /^\^?/;
|
||||
const textWithoutMatchDelimiter = input.replace(matchingPattern, "");
|
||||
const [text, ...matchedParts] = textWithoutMatchDelimiter.split(" - ");
|
||||
const answer: LocalQuizQuestionAnswer = {
|
||||
correct: true,
|
||||
text: text.trim(),
|
||||
matchedText: matchedParts.join("-").trim(),
|
||||
};
|
||||
return answer;
|
||||
};
|
||||
|
||||
export const quizQuestionAnswerMarkdownUtils = {
|
||||
// getHtmlText(): string {
|
||||
// return MarkdownService.render(this.text);
|
||||
// }
|
||||
|
||||
parseMarkdown(input: string, questionType: string): LocalQuizQuestionAnswer {
|
||||
const isCorrect = input.startsWith("*") || input[1] === "*";
|
||||
|
||||
if (questionType === QuestionType.MATCHING) {
|
||||
return parseMatchingAnswer(input);
|
||||
}
|
||||
|
||||
const startingQuestionPattern = /^(\*?[a-z]?\))|\[\s*\]|\[\*\]|\^ /;
|
||||
|
||||
let replaceCount = 0;
|
||||
const text = input
|
||||
.replace(startingQuestionPattern, (m) => (replaceCount++ === 0 ? "" : m))
|
||||
.trim();
|
||||
|
||||
const answer: LocalQuizQuestionAnswer = {
|
||||
correct: isCorrect,
|
||||
text: text,
|
||||
};
|
||||
return answer;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user