Skip to content

Commit 7d42b11

Browse files
Merge pull request #175 from guillermoscript/student-dashboard-change
++Refactor Course Dashboard and Lesson Components
2 parents bcdf03d + aa83e4e commit 7d42b11

File tree

23 files changed

+1681
-887
lines changed

23 files changed

+1681
-887
lines changed

actions/dashboard/AI/TaskAiActions.tsx

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ export async function continueTaskAiConversation(
6666
.messages.find((message) => message.role === 'system')
6767

6868
const result = await streamUI({
69-
model: google('models/gemini-1.5-pro-latest'),
69+
model: google('gemini-1.5-pro-002'),
7070
messages: [
7171
...aiState.get().messages.map((message: any) => ({
7272
role: message.role,
7373
content: message.content,
7474
name: message.name,
7575
})),
7676
],
77-
temperature: 0.9,
77+
temperature: 0.6,
7878
initial: (
7979
<Message
8080
sender={'assistant'}
@@ -135,15 +135,11 @@ export async function continueTaskAiConversation(
135135
tools: {
136136
makeUserAssigmentCompleted: {
137137
description:
138-
'Function to mark the assignment as completed, you must only call it when the student code is correct and working properly satisfying the requirements of the assignment.',
138+
'Function to mark the assignment as completed, you must only call it when the student code is correct and working properly satisfying the requirements of the assignment. Respond using the language of the student.',
139139
parameters: z.object({
140-
assignmentId: z
141-
.string()
142-
.describe(
143-
'The ID of the assignment to mark as completed.'
144-
),
140+
feedback: z.string().describe('Feedback for the student. Tell them what they did right and what they can improve, if needed.'),
145141
}),
146-
generate: async function ({ assignmentId }) {
142+
generate: async function ({ feedback }) {
147143
const toolCallId = generateId()
148144

149145
aiState.done({
@@ -161,7 +157,7 @@ export async function continueTaskAiConversation(
161157
args: {
162158
status: 'success',
163159
message:
164-
'Assignment marked as completed.',
160+
feedback,
165161
},
166162
},
167163
],
@@ -176,15 +172,24 @@ export async function continueTaskAiConversation(
176172
toolCallId,
177173
result: {
178174
status: 'success',
179-
message:
180-
'Assignment marked as completed.',
175+
message: feedback
181176
},
182177
},
183178
],
184179
},
185180
],
186181
})
187182

183+
const message = await supabase
184+
.from('lessons_ai_task_messages')
185+
.insert({
186+
lesson_id: +aiState.get().lessonId,
187+
message: feedback,
188+
sender: 'assistant',
189+
user_id: aiState.get().userId,
190+
created_at: new Date().toISOString(),
191+
})
192+
188193
const task = await supabase
189194
.from('lesson_completions')
190195
.insert({
@@ -193,17 +198,32 @@ export async function continueTaskAiConversation(
193198
})
194199

195200
return (
196-
<Message
197-
sender={'assistant'}
198-
time={dayjs().format('dddd, MMMM D, YYYY h:mm A')}
199-
isUser={false}
200-
>
201-
<SuccessMessage
202-
status="success"
203-
message="Assignment marked as completed."
204-
fire
205-
/>
206-
</Message>
201+
<>
202+
<Message
203+
sender={'assistant'}
204+
time={dayjs().format('dddd, MMMM D, YYYY h:mm A')}
205+
isUser={false}
206+
>
207+
<MessageContentWrapper
208+
role="assistant"
209+
view={<ViewMarkdown markdown={feedback} />}
210+
edit={<></>}
211+
212+
regenerate={<></>}
213+
/>
214+
</Message>
215+
<Message
216+
sender={'assistant'}
217+
time={dayjs().format('dddd, MMMM D, YYYY h:mm A')}
218+
isUser={false}
219+
>
220+
<SuccessMessage
221+
status="success"
222+
message="Assignment marked as completed."
223+
fire
224+
/>
225+
</Message>
226+
</>
207227
)
208228
},
209229
},

actions/dashboard/lessonsAction.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,5 @@ export async function studentResetAiTaskConversation({
376376
if (deleteCompletionData.error) return createResponse('error', 'Error deleting lesson completion', null, 'Error deleting lesson completion')
377377
}
378378

379-
revalidatePath('/dashboard/student/courses/[courseId]/lessons/[lessonId]')
380379
return createResponse('success', 'Message updated successfully', null, null)
381380
}

app/[locale]/dashboard/student/courses/[courseId]/exams/[examId]/page.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,27 @@ export default async function StudentExamCoursePage ({
6868

6969
return (
7070
<>
71-
<BreadcrumbComponent
72-
links={[
73-
{ href: '/dashboard', label: t('BreadcrumbComponent.dashboard') },
74-
{ href: '/dashboard/student', label: t('BreadcrumbComponent.student') },
75-
{ href: '/dashboard/student/courses/', label: t('BreadcrumbComponent.course') },
76-
{
77-
href: `/dashboard/student/courses/${exams.data?.course_id}`,
78-
label: exams.data?.courses?.title
79-
},
80-
{
81-
href: `/dashboard/student/courses/${exams.data?.course_id}/exams`,
82-
label: t('BreadcrumbComponent.exam')
83-
},
84-
{
85-
href: `/dashboard/student/courses/${exams.data?.course_id}/exams/${exams.data?.exam_id}`,
86-
label: exams.data?.title
87-
}
88-
]}
89-
/>
71+
<div className='container'>
72+
<BreadcrumbComponent
73+
links={[
74+
{ href: '/dashboard', label: t('BreadcrumbComponent.dashboard') },
75+
{ href: '/dashboard/student', label: t('BreadcrumbComponent.student') },
76+
{ href: '/dashboard/student/courses/', label: t('BreadcrumbComponent.course') },
77+
{
78+
href: `/dashboard/student/courses/${exams.data?.course_id}`,
79+
label: exams.data?.courses?.title
80+
},
81+
{
82+
href: `/dashboard/student/courses/${exams.data?.course_id}/exams`,
83+
label: t('BreadcrumbComponent.exam')
84+
},
85+
{
86+
href: `/dashboard/student/courses/${exams.data?.course_id}/exams/${exams.data?.exam_id}`,
87+
label: exams.data?.title
88+
}
89+
]}
90+
/>
91+
</div>
9092
<div className="grid gap-8 container">
9193
<div>
9294
<h1 className="text-3xl font-bold">

0 commit comments

Comments
 (0)