From 380950083957a41d218da9d4153dfeeeed4c4d71 Mon Sep 17 00:00:00 2001 From: Suvodip Date: Wed, 31 Jul 2024 22:04:10 +0530 Subject: [PATCH] s1 --- app/components/ClassMates.tsx | 2 +- app/components/ContinueLearning.tsx | 2 +- app/components/KnowledgeQuests.tsx | 2 +- app/components/KnowledgeQuestsPageContent.tsx | 4 +- app/components/ProgressReview copy.tsx | 190 ++++++++++++++++++ app/components/ProgressReview.tsx | 67 +++++- app/components/QuizzesScore.tsx | 2 +- app/components/TopPerformers.tsx | 2 +- app/routes/sign-in.tsx | 2 +- 9 files changed, 262 insertions(+), 11 deletions(-) create mode 100644 app/components/ProgressReview copy.tsx diff --git a/app/components/ClassMates.tsx b/app/components/ClassMates.tsx index 683150e..37cf56e 100644 --- a/app/components/ClassMates.tsx +++ b/app/components/ClassMates.tsx @@ -14,7 +14,7 @@ export default function classMatesDirectory() { useEffect(() => { - fetch('https://iimtt-api.s38.siliconpin.com/api/class-mates') + fetch('https://api.teachertrainingkolkata.in//api/class-mates') .then(res => { if (!res.ok) { throw new Error('Network response was not ok'); diff --git a/app/components/ContinueLearning.tsx b/app/components/ContinueLearning.tsx index ad9dbd3..0c918e7 100644 --- a/app/components/ContinueLearning.tsx +++ b/app/components/ContinueLearning.tsx @@ -14,7 +14,7 @@ export default function ContinueLearning() { useEffect(() => { - fetch('https://iimtt-api.s38.siliconpin.com/api/continue-learning') + fetch('https://api.teachertrainingkolkata.in//api/continue-learning') .then(res => { if (!res.ok) { throw new Error('Network response was not ok'); diff --git a/app/components/KnowledgeQuests.tsx b/app/components/KnowledgeQuests.tsx index 49b61f2..9cc7202 100644 --- a/app/components/KnowledgeQuests.tsx +++ b/app/components/KnowledgeQuests.tsx @@ -14,7 +14,7 @@ export default function KnowledgeQuests() { useEffect(() => { - fetch('https://iimtt-api.s38.siliconpin.com/api/knowledge-quests') + fetch('https://api.teachertrainingkolkata.in//api/knowledge-quests') .then(res => { if (!res.ok) { throw new Error('Network response was not ok'); diff --git a/app/components/KnowledgeQuestsPageContent.tsx b/app/components/KnowledgeQuestsPageContent.tsx index cd82b6f..b69521b 100644 --- a/app/components/KnowledgeQuestsPageContent.tsx +++ b/app/components/KnowledgeQuestsPageContent.tsx @@ -20,8 +20,8 @@ export default function Index() { const fetchData = async () => { try { const [allResponse, completedResponse] = await Promise.all([ - fetch('https://iimtt-api.s38.siliconpin.com/api/all-assesment'), - fetch('https://iimtt-api.s38.siliconpin.com/api/complete-assesment') + fetch('https://api.teachertrainingkolkata.in//api/all-assesment'), + fetch('https://api.teachertrainingkolkata.in//api/complete-assesment') ]); if (!allResponse.ok || !completedResponse.ok) { diff --git a/app/components/ProgressReview copy.tsx b/app/components/ProgressReview copy.tsx new file mode 100644 index 0000000..62ba236 --- /dev/null +++ b/app/components/ProgressReview copy.tsx @@ -0,0 +1,190 @@ +import React, { useState, useEffect } from 'react'; +import { Modal } from 'antd'; + +interface Question { + questionId: string; + questionText: string; + correctAnswer: string; + options: string[]; +} + +interface Quiz { + quizId: string; + quizName: string; + internalMarks: string; + attendance: string; + attendQuestion: string; + totalQuestion: string; + questions: Question[]; +} + +interface Module { + moduleId: string; + type: string; + moduleName: string; + quizzes: Quiz[]; +} + +export default function Index() { + const [isModalOpen, setIsModalOpen] = useState(false); + const [selectedQuiz, setSelectedQuiz] = useState(null); + const [quizModuleData, setQuizModuleData] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + fetch('https://api.teachertrainingkolkata.in//api/quiz-module') + .then((res) => { + if (!res.ok) { + throw new Error('Network response was not ok'); + } + return res.json(); + }) + .then((data) => { + console.log('Fetched data:', data); + // Extract the modules array from the response + if (data && Array.isArray(data.modules)) { + setQuizModuleData(data.modules); + } else { + setError(new Error('Fetched data is not an array')); + } + setLoading(false); + }) + .catch((error) => { + console.error('Error fetching data:', error); + setError(error); + setLoading(false); + }); + }, []); + + if (loading) { + return
Loading...
; + } + + if (error) { + return
Error: {error.message}
; + } + + const showModal = (quiz: Quiz) => { + setSelectedQuiz(quiz); + setIsModalOpen(true); + }; + + const handleOk = () => { + setIsModalOpen(false); + setSelectedQuiz(null); + }; + + const handleCancel = () => { + setIsModalOpen(false); + setSelectedQuiz(null); + }; + + return ( +
+
+ {quizModuleData.length > 0 ? ( + quizModuleData.map((moduleData) => ( +
+
+

{moduleData.type}

+

{moduleData.moduleName}

+

3/8 Quizzes Completed

+
+
+ {moduleData.quizzes.map((quizData) => ( +
showModal(quizData)} className="flex flex-row justify-between place-items-center hover:bg-[#FFF4EA] duration-500 border-b-[1px] border-b-[#CFCFCF] p-6 cursor-pointer" key={quizData.quizId}> +
+

+ #{quizData.quizId} {quizData.quizName} +

+

+ Internal Marks: {quizData.internalMarks} +  •   + Attendance: {quizData.attendance} +

+
+
+

+ {quizData.attendQuestion}/ + {quizData.totalQuestion} +

+ +
+
+ ))} +
+
+ )) + ) : ( +
No quiz modules available.
+ )} +
+ {selectedQuiz && ( + +
+
+
+
+ +
+
+

18/10

+

Attendance

+
+
+
+ +
+
+
+ +
+
+

+ 12 Questions +

+

Attempted

+
+
+
+ +
+
+
+ +
+
+

+ 12 Correct +

+

Attempts

+
+
+
+
+ {selectedQuiz.questions.map((questionData) => ( +
+

+ Q{questionData.questionId}: {questionData.questionText} +

+

Your Answer

+

{questionData.correctAnswer}

+
+

+  Correct +

+

{questionData.correctAnswer}

+
+
    + {/* {questionData.options.map((option, index) => ( +
  • {option}
  • + ))} */} +
+
+ ))} +
+ )} +
+ ); +} diff --git a/app/components/ProgressReview.tsx b/app/components/ProgressReview.tsx index 8e2c68f..185b5b6 100644 --- a/app/components/ProgressReview.tsx +++ b/app/components/ProgressReview.tsx @@ -24,6 +24,16 @@ interface Module { moduleName: string; quizzes: Quiz[]; } +interface QuestionList { + questionId: string; + questionText: string; + correctAnswer: string; + options: string[]; + moduleId: string; +} +interface ModuleList { + moduleId: string; +} export default function Index() { const [isModalOpen, setIsModalOpen] = useState(false); @@ -32,8 +42,59 @@ export default function Index() { const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [questionList, setQuestionList] = useState([]); +const [moduleList, setModuleList] = useState([]); + +useEffect(() => { + fetch(`https://api.teachertrainingkolkata.in/api/question-list`) + .then((res) => { + if (!res.ok) { + throw new Error('Network Response not ok'); + } + return res.json(); + }) + .then((questionData) => { + setQuestionList(questionData); + console.log('Question List', questionData); + }) + .catch((error) => { + console.error('Error fetching question list:', error); + }); +}, []); + +useEffect(() => { + if (questionList.length > 0) { + const fetchModuleList = async () => { + try { + const moduleData = await Promise.all( + questionList.map((question) => + fetch(`https://api.teachertrainingkolkata.in/api/quiz-module-list?module_id=${question.moduleId}`) + .then((res) => { + if (!res.ok) { + throw new Error('Network Response not ok'); + } + return res.json(); + }) + ) + ); + setModuleList(moduleData.flat()); + console.log('Module List', moduleData.flat()); + } catch (error) { + console.error('Error fetching module list:', error); + } + }; + + fetchModuleList(); + } +}, [questionList]); + + + + + + useEffect(() => { - fetch('https://iimtt-api.s38.siliconpin.com/api/quiz-module') + fetch('https://api.teachertrainingkolkata.in/api/quiz-module') .then((res) => { if (!res.ok) { throw new Error('Network response was not ok'); @@ -41,7 +102,7 @@ export default function Index() { return res.json(); }) .then((data) => { - console.log('Fetched data:', data); + // console.log('Fetched data:', data); // Extract the modules array from the response if (data && Array.isArray(data.modules)) { setQuizModuleData(data.modules); @@ -163,7 +224,7 @@ export default function Index() { - {selectedQuiz.questions.map((questionData) => ( + {questionList.map((questionData) => (

Q{questionData.questionId}: {questionData.questionText} diff --git a/app/components/QuizzesScore.tsx b/app/components/QuizzesScore.tsx index 601a0cb..517e311 100644 --- a/app/components/QuizzesScore.tsx +++ b/app/components/QuizzesScore.tsx @@ -14,7 +14,7 @@ export default function quizScoreData() { useEffect(() => { - fetch('https://iimtt-api.s38.siliconpin.com/api/quiz-score') + fetch('https://api.teachertrainingkolkata.in/api/quiz-score') .then(res => { if (!res.ok) { throw new Error('Network response was not ok'); diff --git a/app/components/TopPerformers.tsx b/app/components/TopPerformers.tsx index 6149c5a..83fe6fd 100644 --- a/app/components/TopPerformers.tsx +++ b/app/components/TopPerformers.tsx @@ -16,7 +16,7 @@ export default function TopPerformers() { const [error, setError] = useState(null); useEffect(() => { - fetch('https://iimtt-api.s38.siliconpin.com/api/top-performers') + fetch('https://api.teachertrainingkolkata.in//api/top-performers') .then(res => { if (!res.ok) { throw new Error('Network response was not ok'); diff --git a/app/routes/sign-in.tsx b/app/routes/sign-in.tsx index 1581690..496a085 100644 --- a/app/routes/sign-in.tsx +++ b/app/routes/sign-in.tsx @@ -13,7 +13,7 @@ export default function SignIn() { password, }; try { - const response = await fetch('https://iimtt-api.s38.siliconpin.com/api/sign-in', { + const response = await fetch('https://api.teachertrainingkolkata.in//api/sign-in', { method: 'POST', headers: { 'Content-Type': 'application/json',