Skip to content

Commit

Permalink
feat: question template에 passage textarea를 추가한다.
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn113 committed Jan 3, 2025
1 parent 85aa0fe commit 40e31a9
Show file tree
Hide file tree
Showing 14 changed files with 828 additions and 2,499 deletions.
3,277 changes: 791 additions & 2,486 deletions web/pnpm-lock.yaml

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions web/src/components/questions/details/QuestionDetailTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TrueOrFalseQuestion from './TrueOrFalseQuestion';
import MultipleChoiceQuestion from './MultipleChoiceQuestion';
import SingleChoiceQuestion from './SingleChoiceQuestion';
import LongAnswerQuestion from './LongAnswerQuestion';
import { Textarea } from '@nextui-org/react';

interface QuestionDetailTemplateProps {
question: QuestionBaseResponse;
Expand All @@ -28,7 +29,17 @@ const QuestionDetailTemplate = ({ question, index }: QuestionDetailTemplateProps
<div className="w-full text-md font-semibold text-gray-800">
{index + 1}. {question.text}
</div>
{question.passage && (
<Textarea
value={question.passage}
className="mt-4"
variant="flat"
isReadOnly
maxRows={30}
/>
)}
<div className="w-full mt-4">{detailMap[question.type]}</div>
<div className="w-full mt-36" />
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const LongAnswerQuestionEditor = () => {
return <div></div>;
return <div className="mt-4"></div>;
};

export default LongAnswerQuestionEditor;
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const MultipleChoiceQuestionEditor = () => {
};

return (
<div className="flex flex-col mt-8">
<div className="flex flex-col mt-4">
<div className="flex items-center gap-2 mb-2 ">
<label className="font-semibold">선택지와 정답</label>
<div>
Expand Down
16 changes: 14 additions & 2 deletions web/src/components/questions/editor/QuestionEditorTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MultipleChoiceQuestionEditor from './MultipleChoiceQuestionEditor';
import TrueOrFalseQuestionEditor from './TrueOrFalseQuestionEditor';
import React from 'react';
import useExamEditorStore from '@/stores/useExamEditorStore';
import { Button, Input } from '@nextui-org/react';
import { Button, Input, Textarea } from '@nextui-org/react';

const QuestionEditorTemplate = () => {
const {
Expand All @@ -31,6 +31,11 @@ const QuestionEditorTemplate = () => {
handleUpdateQuestion(currentIndex, newQuestion);
};

const handleUpdatePassage = (passage: string) => {
const newQuestion = { ...question, passage };
handleUpdateQuestion(currentIndex, newQuestion);
};

const handleDeleteQuestionClick = () => {
if (questions.length === 1) {
setQuestionTypeSelectorActive(true);
Expand All @@ -57,7 +62,14 @@ const QuestionEditorTemplate = () => {
label: 'text-xl font-semibold text-gray-800',
}}
/>

<Textarea
value={question.passage}
placeholder="지문이 필요한 경우 입력하세요. (선택사항)"
onValueChange={handleUpdatePassage}
variant="flat"
className="mt-4"
maxRows={30}
/>
{editorMap[question.type]}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ShortAnswerQuestionEditor = () => {
};

return (
<div className="mt-8">
<div className="mt-4">
<Input
value={question.correctAnswer}
label="정답"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const SingleChoiceQuestionEditor = () => {
};

return (
<div className="flex flex-col mt-8">
<div className="flex flex-col mt-4">
<div className="flex items-center gap-2 mb-2 ">
<label className="font-semibold">선택지와 정답</label>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TrueOrFalseQuestionEditor = () => {
};

return (
<div className="flex flex-col mt-8">
<div className="flex flex-col mt-4">
<label className="mb-2 font-semibold">정답</label>
<div className="flex w-full flex-col">
<div className="flex gap-2">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const LongAnswerQuestionView = () => {
return <div></div>;
return <div className="mt-4"></div>;
};

export default LongAnswerQuestionView;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const MultipleChoiceQuestionView = () => {
const question = questions[currentIndex] as MultipleChoiceQuestionRequest;

return (
<div className="flex flex-col mt-8">
<div className="flex flex-col mt-4">
<label className="mb-2 font-semibold">선택지와 정답</label>
<div>
{question.options.map((option, index) => (
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/questions/view/QuestionViewTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QuestionType } from '@/api/questionAPI';
import useExamEditorStore from '@/stores/useExamEditorStore';
import { Input } from '@nextui-org/react';
import { Input, Textarea } from '@nextui-org/react';
import ShortAnswerQuestionView from './ShortAnswerQuestionView';
import LongAnswerQuestionView from './LongAnswerQuestionView';
import SingleChoiceQuestionView from './SingleChoiceQuestionView';
Expand Down Expand Up @@ -34,6 +34,7 @@ const QuestionViewTemplate = () => {
label: 'text-xl font-semibold text-gray-800',
}}
/>
<Textarea isReadOnly value={question.passage} variant="flat" className="mt-4" />
{viewMap[question.type]}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ShortAnswerQuestionView = () => {
const question = questions[currentIndex] as ShortAnswerQuestionRequest;

return (
<div className="mt-8">
<div className="mt-4">
<Input
isReadOnly
value={question.correctAnswer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SingleChoiceQuestionView = () => {
const question = questions[currentIndex] as SingleChoiceQuestionRequest;

return (
<div className="flex flex-col mt-8">
<div className="flex flex-col mt-4">
<label className="mb-2 font-semibold">선택지와 정답</label>
<RadioGroup value={question.options.findIndex((option) => option.isCorrect).toString()}>
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const TrueOrFalseQuestionView = () => {
const question = questions[currentIndex] as TrueOrFalseQuestionRequest;

return (
<div className="flex flex-col mt-8">
<div className="flex flex-col mt-4">
<label className="mb-2 font-semibold">정답</label>
<div className="flex w-full flex-col">
<div className="flex gap-2">
Expand Down

0 comments on commit 40e31a9

Please sign in to comment.