From 0c5c024098f75a05ce44441862e579b651895b2d Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Sun, 7 Jul 2024 16:43:14 +0100 Subject: [PATCH] Added Match Sentences to Reading Generation --- .../Generation/match.sentences.edit.tsx | 134 +++++++++++++++++- .../(generation)/ListeningGeneration.tsx | 7 +- src/pages/(generation)/ReadingGeneration.tsx | 28 +++- 3 files changed, 159 insertions(+), 10 deletions(-) diff --git a/src/components/Generation/match.sentences.edit.tsx b/src/components/Generation/match.sentences.edit.tsx index a4027a2e..78ab3a95 100644 --- a/src/components/Generation/match.sentences.edit.tsx +++ b/src/components/Generation/match.sentences.edit.tsx @@ -1,7 +1,133 @@ -import React from 'react'; +import React from "react"; +import { MatchSentencesExercise } from "@/interfaces/exam"; +import Input from "@/components/Low/Input"; +import Select from "@/components/Low/Select"; -const MatchSentencesEdit = () => { - return null; +interface Props { + exercise: MatchSentencesExercise; + updateExercise: (data: any) => void; } +const MatchSentencesEdit = (props: Props) => { + const { exercise, updateExercise } = props; -export default MatchSentencesEdit; \ No newline at end of file + const selectOptions = exercise.options.map((option) => ({ + value: option.id, + label: option.id, + })); + + return ( + <> + + updateExercise({ + prompt: value, + }) + } + /> +

Solutions

+
+ {exercise.sentences.map((sentence, index) => ( +
+
+ + updateExercise({ + sentences: exercise.sentences.map((iSol) => + iSol.id === sentence.id + ? { + ...iSol, + sentence: { + ...iSol.sentence, + heading: value, + }, + } + : iSol + ), + }) + } + className="px-2" + /> +
+ + updateExercise({ + options: exercise.options.map((iSol) => + iSol.id === option.id + ? { + ...iSol, + sentence: value, + } + : iSol + ), + }) + } + className="px-2" + /> +
+