From 967541a4924a635ccef8107bd5ce7ccd88717bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B3=E4=BD=A9=E5=BA=AD?= Date: Sun, 12 Oct 2025 00:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B8=AC=E9=A9=97=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/home/page.tsx | 273 +++++++++++++++++----------------------------- 1 file changed, 103 insertions(+), 170 deletions(-) diff --git a/app/home/page.tsx b/app/home/page.tsx index b3e1105..8a6c472 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -21,6 +21,11 @@ export default function HomePage() { combined: false }) const [isLoadingTests, setIsLoadingTests] = useState(true) + const [questionCounts, setQuestionCounts] = useState({ + logic: 0, + creative: 0, + total: 0 + }) const dropdownRef = useRef(null) const handleLogout = () => { @@ -28,6 +33,29 @@ export default function HomePage() { router.push("/") } + // 獲取題目數量 + const fetchQuestionCounts = async () => { + try { + // 獲取邏輯題目數量 + const logicResponse = await fetch('/api/logic-questions') + const logicData = await logicResponse.json() + const logicCount = logicData.success ? logicData.count || logicData.questions?.length || 0 : 0 + + // 獲取創意題目數量 + const creativeResponse = await fetch('/api/creative-questions') + const creativeData = await creativeResponse.json() + const creativeCount = creativeData.success ? creativeData.questions?.length || 0 : 0 + + setQuestionCounts({ + logic: logicCount, + creative: creativeCount, + total: logicCount + creativeCount + }) + } catch (error) { + console.error('Error fetching question counts:', error) + } + } + // 檢查用戶測驗完成狀態 const checkTestCompletionStatus = async () => { if (!user) return @@ -62,8 +90,9 @@ export default function HomePage() { } } - // 檢查測驗完成狀態 + // 獲取題目數量和檢查測驗完成狀態 useEffect(() => { + fetchQuestionCounts() if (user) { checkTestCompletionStatus() } @@ -290,180 +319,84 @@ export default function HomePage() {
{user?.role === "admin" ? ( // 管理者看到的介紹卡片 -
- {/* 邏輯思維測試介紹 */} - - -
- -
- 邏輯思維測試 - 評估邏輯推理、分析判斷和問題解決能力 -
- -
-
- 題目數量 - 10題 +
+
+ {/* 綜合測試介紹 */} + + +
+
-
- 題目類型 - 單選題 + 綜合測試 + + 綜合測試包含邏輯思維和創意能力,附有完整分析報告,
+ 全卷設定作答時間 30 分鐘。 +
+ + +
+
+ 總題目數 + {questionCounts.total}題 +
+
+ 預計時間 + 30分鐘 +
-
- 預計時間 - 15-20分鐘 -
-
- -
- - {/* 創意能力測試介紹 */} - - -
- -
- 創意能力測試 - 評估創新思維、想像力和創造性解決問題的能力 -
- -
-
- 題目數量 - 20題 -
-
- 題目類型 - 5級量表 -
-
- 預計時間 - 25-30分鐘 -
-
-
-
- - {/* 綜合測試介紹 */} - - -
- -
- 綜合測試 - 完整的邏輯思維 + 創意能力雙重評估,獲得全面的能力報告 -
- -
-
- 總題目數 - 30題 -
-
- 預計時間 - 45分鐘 -
-
-
-
+ + +
) : ( // 一般用戶看到的測試功能 -
- {/* Logic Test */} - - -
- -
- 邏輯思維測試 - 評估邏輯推理能力 -
- - {isLoadingTests ? ( - - ) : testCompletionStatus.logic ? ( - - ) : ( - - )} - -
- - {/* Creative Test */} - - -
- -
- 創意能力測試 - 評估創新思維能力 -
- - {isLoadingTests ? ( - - ) : testCompletionStatus.creative ? ( - - ) : ( - - )} - -
- - {/* Combined Test */} - - -
- -
- 綜合測試 - 完整能力評估 -
- - {isLoadingTests ? ( - - ) : testCompletionStatus.combined ? ( - - ) : ( - - )} - -
+
+
+ {/* Combined Test */} + + +
+ +
+ 綜合測試 + + 全卷設定作答時間 30 分鐘,
+ 請誠實反映您平常的思考方式與感受,不需刻意迎合特定答案。 +
+
+ +
+
+ 總題目數 + {questionCounts.total}題 +
+
+ 預計時間 + 30分鐘 +
+
+
+ {isLoadingTests ? ( + + ) : testCompletionStatus.combined ? ( + + ) : ( + + )} +
+
+
+
)}