refactoring files to be located by feature

This commit is contained in:
2025-07-23 09:23:44 -06:00
parent 46e0c36916
commit c95c40f9e7
75 changed files with 279 additions and 303 deletions

View File

@@ -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;
},
};