diff --git a/Management.Web/Pages/QuizForm/QuizPreview.razor b/Management.Web/Pages/QuizForm/QuizPreview.razor index bf114e5..b85e8b2 100644 --- a/Management.Web/Pages/QuizForm/QuizPreview.razor +++ b/Management.Web/Pages/QuizForm/QuizPreview.razor @@ -61,7 +61,6 @@ @foreach(var question in Quiz.Questions) { -
{ + const delay = 500; + const handler = setTimeout(() => { + if (quizMarkdownUtils.toMarkdown(quiz) !== quizText) { + // handle when parsing does not work + try { + const updatedQuiz = quizMarkdownUtils.parseMarkdown(quizText); + updateQuizMutation.mutate({ + quiz: updatedQuiz, + moduleName, + quizName, + }); + } catch (e: any) { + setError(e.toString()); + } + } + }, delay); + + return () => { + clearTimeout(handler); + }; + }, [moduleName, quiz, quizName, quizText, updateQuizMutation]); + return ( -
+
{quiz.name} - +
+ +
+
+ + {error && error} +
+ +
+
); } diff --git a/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/QuizPreview.tsx b/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/QuizPreview.tsx new file mode 100644 index 0000000..2209f4d --- /dev/null +++ b/nextjs/src/app/course/[courseName]/modules/[moduleName]/quiz/[quizName]/QuizPreview.tsx @@ -0,0 +1,10 @@ +import { LocalQuiz } from "@/models/local/quiz/localQuiz"; + +export default function QuizPreview({quiz}: {quiz: LocalQuiz}) { + return ( +
+ +
{quiz.description}
+
+ ) +} diff --git a/nextjs/src/app/globals.css b/nextjs/src/app/globals.css index b7b24e8..6170d8a 100644 --- a/nextjs/src/app/globals.css +++ b/nextjs/src/app/globals.css @@ -9,3 +9,8 @@ text-wrap: balance; } } + +/* monaco editor */ +.monaco-editor-background, .monaco-editor .margin { + background-color: black !important; +} \ No newline at end of file diff --git a/nextjs/src/components/editor/InnerMonacoEditor.tsx b/nextjs/src/components/editor/InnerMonacoEditor.tsx index c7a99c9..d43ddc0 100644 --- a/nextjs/src/components/editor/InnerMonacoEditor.tsx +++ b/nextjs/src/components/editor/InnerMonacoEditor.tsx @@ -15,8 +15,6 @@ export default function InnerMonacoEditor({ const editorRef = useRef(null); const divRef = useRef(null); - // const monacoRef = useRef(null); - useEffect(() => { if (divRef.current && !editorRef.current) { loader.init().then((monaco) => { @@ -47,12 +45,13 @@ export default function InnerMonacoEditor({ }); } }, [onChange, value]); + return (
); }