|
|
|
@ -11,6 +11,7 @@ import { APP_BASE_URL } from '@/utils/constants'; |
|
|
|
|
import { defaultFetcher } from '@/helpers/fetch.helper'; |
|
|
|
|
import { getEduConnectAccessToken } from '@/helpers/token.helper'; |
|
|
|
|
import { useToast } from '@/hooks/use-toast'; |
|
|
|
|
import { usePathname } from 'next/navigation'; |
|
|
|
|
|
|
|
|
|
interface Course { |
|
|
|
|
id: number; |
|
|
|
@ -49,15 +50,18 @@ const QuizGenerator: React.FC<QuizGeneratorProps> = ({ |
|
|
|
|
current_page, |
|
|
|
|
course_uuid ,
|
|
|
|
|
}) => { |
|
|
|
|
|
|
|
|
|
const pathname = usePathname() |
|
|
|
|
const id = pathname.split('/')?.at(-1) |
|
|
|
|
const { data: completedQuizzes, error: completedError } = useSWR<any>( |
|
|
|
|
`${APP_BASE_URL}/api/quiz/get/allComplete?course_uuid=${course_uuid}`, |
|
|
|
|
`${APP_BASE_URL}/api/quiz/get/allComplete?course_id=${id}`, |
|
|
|
|
defaultFetcher |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const { toast } = useToast() |
|
|
|
|
|
|
|
|
|
const { data: uncompletedQuizzes, error: uncompletedError , mutate } = useSWR<any>( |
|
|
|
|
`${APP_BASE_URL}/api/quiz/get/personalIncomplete?course_uuid=${course_uuid}`, |
|
|
|
|
`${APP_BASE_URL}/api/quiz/get/personalIncomplete?course_id=${id}`, |
|
|
|
|
defaultFetcher |
|
|
|
|
); |
|
|
|
|
|
|
|
|
@ -110,7 +114,7 @@ const QuizGenerator: React.FC<QuizGeneratorProps> = ({ |
|
|
|
|
try{ |
|
|
|
|
const formData = new FormData(); |
|
|
|
|
|
|
|
|
|
formData.append('course_uuid' , course_uuid); |
|
|
|
|
formData.append('course_id' , course_uuid); |
|
|
|
|
formData.append('page' , (current_page + 1)?.toString()) |
|
|
|
|
const res = await fetch(APP_BASE_URL + '/api/quiz/generate' , { |
|
|
|
|
headers : { |
|
|
|
@ -155,8 +159,8 @@ const QuizGenerator: React.FC<QuizGeneratorProps> = ({ |
|
|
|
|
by {quiz.creator.firstName} {quiz.creator.lastName} |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
<div className="text-sm space-y-2"> |
|
|
|
|
{quiz.quizAnswers.map((answer, i) => ( |
|
|
|
|
{/* <div className="text-sm space-y-2"> |
|
|
|
|
{quiz?.quizAnswers && quiz?.quizAnswers?.map((answer, i) => ( |
|
|
|
|
<div
|
|
|
|
|
key={i}
|
|
|
|
|
className={`p-2 rounded flex justify-between items-center ${ |
|
|
|
@ -178,7 +182,7 @@ const QuizGenerator: React.FC<QuizGeneratorProps> = ({ |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
</div> */} |
|
|
|
|
</div> |
|
|
|
|
{index < completedQuizzes?.length - 1 && <Separator className="my-4" />} |
|
|
|
|
</div> |
|
|
|
|