This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Quiz) : student quiz result view
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
app/routes/_procted+/lectures+/$lectureId+/_layout/QuizResultModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Modal from "~/components/Modal"; | ||
import styles from "./modal.module.css"; | ||
import formStyles from "~/components/common/form.module.css"; | ||
import TextInput from "~/components/Input/TextInput"; | ||
import { useParams } from "@remix-run/react"; | ||
import { useEffect, useState } from "react"; | ||
import { useAuth } from "~/contexts/AuthContext"; | ||
import { getQuizWithUserId } from "~/API/practice"; | ||
|
||
interface Props { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const QuizResultModal = ({ isOpen, onClose }: Props) => { | ||
const auth = useAuth(); | ||
const [isLoading, setIsLoading] = useState(true); | ||
const params = useParams(); | ||
const [quizResult, setQuizResult] = useState< | ||
{ | ||
gain_score: number | null; | ||
id: number; | ||
max_score: number; | ||
title: string; | ||
}[] | ||
>([]); | ||
useEffect(() => { | ||
async function getData() { | ||
const { data } = await getQuizWithUserId( | ||
params.lectureId!, | ||
auth.userId, | ||
auth.token | ||
); | ||
setQuizResult(data); | ||
setIsLoading(false); | ||
} | ||
getData(); | ||
}, []); | ||
return isLoading ? null : ( | ||
<Modal | ||
title="퀴즈 결과 조회" | ||
subtitle="사용자의 퀴즈 결과를 확인합니다" | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
> | ||
<form className={styles["modal-body"]}> | ||
{quizResult.map((result, idx) => ( | ||
<TextInput | ||
title={`Q${idx + 1}`} | ||
name="" | ||
value={`${ | ||
result.gain_score == null ? "점수없음" : result.gain_score | ||
}/${result.max_score}`} | ||
/> | ||
))} | ||
</form> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default QuizResultModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters