Skip to content

Commit 621d6e2

Browse files
committed
fix og routes
1 parent 0e3eecb commit 621d6e2

File tree

9 files changed

+234
-2
lines changed

9 files changed

+234
-2
lines changed

app/academy/[...slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export async function generateMetadata(props: {
134134

135135
const image = {
136136
alt: 'Banner',
137-
url: `/api/og/course/${params.slug[0]}?${imageParams.toString()}`,
137+
url: `/api/og/academy/${params.slug[0]}?${imageParams.toString()}`,
138138
width: 1200,
139139
height: 630,
140140
};

app/api/og/academy/[slug]/route.tsx

Lines changed: 105 additions & 0 deletions
Large diffs are not rendered by default.
140 KB
Binary file not shown.
140 KB
Binary file not shown.

app/api/og/guide/[slug]/route.tsx

Lines changed: 100 additions & 0 deletions
Large diffs are not rendered by default.

app/docs/[...slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export async function generateMetadata(props: {
103103

104104
const image = {
105105
alt: 'Banner',
106-
url: `/api/og/${params.slug[0]}?${imageParams.toString()}`,
106+
url: `/api/og/docs/${params.slug[0]}?${imageParams.toString()}`,
107107
width: 1200,
108108
height: 630,
109109
};

utils/quizProgress.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { getQuizResponse } from './indexedDB';
2+
3+
interface QuizProgress {
4+
[quizId: string]: boolean;
5+
}
6+
7+
export async function getQuizProgress(quizIds: string[]): Promise<QuizProgress> {
8+
const progress: QuizProgress = {};
9+
10+
for (const quizId of quizIds) {
11+
const response = await getQuizResponse(quizId);
12+
progress[quizId] = response ? response.isCorrect : false;
13+
}
14+
15+
return progress;
16+
}
17+
18+
export function calculateCompletionRate(progress: QuizProgress): number {
19+
const totalQuizzes = Object.keys(progress).length;
20+
const completedQuizzes = Object.values(progress).filter(Boolean).length;
21+
return (completedQuizzes / totalQuizzes) * 100;
22+
}
23+
24+
export function isEligibleForCertificate(progress: QuizProgress, threshold: number = 80): boolean {
25+
const completionRate = calculateCompletionRate(progress);
26+
return completionRate >= threshold;
27+
}

0 commit comments

Comments
 (0)