ENCOA-307

This commit is contained in:
Carlos-Mesquita
2025-01-05 17:46:11 +00:00
parent af9f70880a
commit 0739e044a1
5 changed files with 135 additions and 129 deletions

View File

@@ -1,4 +1,3 @@
import useExamEditorStore from "@/stores/examEditor";
import ListeningContext from "./listening";
import ReadingContext from "./reading";
@@ -30,7 +29,7 @@ const LevelContext: React.FC<Props> = ({ sectionId }) => {
)}
{(readingSection || listeningSection || hasReadingContext) && (
<div className="space-y-4 mb-4">
{readingSection || hasReadingContext && <ReadingContext sectionId={sectionId} module="level" />}
{(readingSection !== undefined || hasReadingContext) && <ReadingContext sectionId={sectionId} module="level" />}
{listeningSection && <ListeningContext sectionId={sectionId} listeningSection={listeningSection} module="level" level={true} />}
</div>
)}

View File

@@ -11,11 +11,10 @@ import { Module } from "@/interfaces";
interface Props {
module: Module;
sectionId: number;
level?: boolean;
}
const ReadingContext: React.FC<Props> = ({ sectionId, module, level = false }) => {
const ReadingContext: React.FC<Props> = ({ sectionId, module }) => {
const { dispatch } = useExamEditorStore();
const sectionState = useExamEditorStore(
(state) => state.modules[module].sections.find((section) => section.sectionId === sectionId)!
@@ -55,7 +54,7 @@ const ReadingContext: React.FC<Props> = ({ sectionId, module, level = false }) =
}
});
useEffect(()=> {
useEffect(() => {
if (readingPart.text === undefined) {
setTitle('');
setContent('');
@@ -74,7 +73,9 @@ const ReadingContext: React.FC<Props> = ({ sectionId, module, level = false }) =
useEffect(() => {
const passageRes = levelGenResults.find((res) => res.generating === "passage");
const passageRes = [...levelGenResults].reverse()
.find((res) => res.generating === "passage");
if (levelGenResults && passageRes) {
setEditing(true);
setTitle(passageRes.result[0].title);