diff --git a/src/lib/components/AssessmentFeedback.svelte b/src/lib/components/AssessmentFeedback.svelte index 4598a12..517bb20 100644 --- a/src/lib/components/AssessmentFeedback.svelte +++ b/src/lib/components/AssessmentFeedback.svelte @@ -1,10 +1,11 @@ @@ -12,10 +13,11 @@

AI Assessment Feedback

Grade: {grade}
Strengths: {strengths}
-
Areas for Improvement: {areas_for_improvement}
-
Individualized Activity: {individualized_activity}
-
Reflection Question: {reflection_question}
-
Teacher Suggestion: {teacher_suggestion}
+
Areas for Improvement: {areasForImprovement}
+
Individualized Activity: {individualizedActivity}
+
Reflection Question: {reflectionQuestion}
+
Teacher Suggestion: {teacherSuggestion}
+
Spelling and Grammar: {spellingAndGrammar}
Show AI Reasoning
{reasoning}
diff --git a/src/lib/components/AssessmentHistory.svelte b/src/lib/components/AssessmentHistory.svelte index 737e315..04f92fd 100644 --- a/src/lib/components/AssessmentHistory.svelte +++ b/src/lib/components/AssessmentHistory.svelte @@ -35,10 +35,11 @@
Submission: {entry.submission}
Strengths: {entry.strengths}
-
Areas for Improvement: {entry.areas_for_improvement}
-
Individualized Activity: {entry.individualized_activity}
-
Reflection Question: {entry.reflection_question}
-
Teacher Suggestion: {entry.teacher_suggestion}
+
Areas for Improvement: {entry.areasForImprovement}
+
Individualized Activity: {entry.individualizedActivity}
+
Reflection Question: {entry.reflectionQuestion}
+
Teacher Suggestion: {entry.teacherSuggestion}
+
Spelling and Grammar: {entry.spellingAndGrammar}
Show AI Reasoning
{entry.reasoning}
diff --git a/src/lib/utils/ai.ts b/src/lib/utils/ai.ts index e74ad37..82bb72c 100644 --- a/src/lib/utils/ai.ts +++ b/src/lib/utils/ai.ts @@ -1,6 +1,7 @@ import { client, agent } from '../agent/services/agentService'; import type { MessageTextContentOutput, ToolOutput } from '@azure/ai-projects'; import { PARTYKIT_BASE_URL } from '$env/static/private'; +import type { OpenAIResponse } from './types'; // Prompt template for grading and feedback export function buildGradingPrompt(submission: string, task: string) { @@ -27,12 +28,13 @@ Follow these steps: RESPONSE FORMAT (respond with a single JSON object, no extra text): { - "grade": "", + "grade": "", "strengths": "", - "areas_for_improvement": "", - "individualized_activity": "", - "reflection_question": "", - "teacher_suggestion": "", + "areasForImprovement": "", + "individualizedActivity": "", + "reflectionQuestion": "", + "teacherSuggestion": "", + "spellingAndGrammar": "", "reasoning": "" } @@ -40,25 +42,16 @@ Respond ONLY with the JSON object, with no preamble or explanation. `; } -export type OpenAIResponse = { - grade: string; - strengths: string; - areas_for_improvement: string; - individualized_activity: string; - reflection_question: string; - teacher_suggestion: string; - reasoning: string; -}; - function fallbackGrade(submission: string, task: string): OpenAIResponse { console.log('using fallback'); return { grade: '7/10', strengths: 'Clear argument and good evidence (in response to the task: ' + task + ").", - areas_for_improvement: 'Needs deeper analysis and more examples.', - individualized_activity: 'Write a paragraph expanding on your main point and provide two additional examples to support your argument.', - reflection_question: 'What was the most challenging part of this assignment for you, and why?', - teacher_suggestion: 'In the next lesson, review how to develop arguments with supporting evidence and provide a model answer for comparison.', + areasForImprovement: 'Needs deeper analysis and more examples.', + individualizedActivity: 'Write a paragraph expanding on your main point and provide two additional examples to support your argument.', + reflectionQuestion: 'What was the most challenging part of this assignment for you, and why?', + teacherSuggestion: 'In the next lesson, review how to develop arguments with supporting evidence and provide a model answer for comparison.', + spellingAndGrammar: 'Everything was spelled correctly', reasoning: 'The submission demonstrates a good structure and evidence, but lacks depth and breadth of analysis. The activity and suggestions are designed to target this gap.' }; } @@ -189,10 +182,11 @@ export async function gradeSubmissionWithAgent(submission: string, task: string, return { grade: '', strengths: '', - areas_for_improvement: '', - individualized_activity: '', - reflection_question: '', - teacher_suggestion: '', + areasForImprovement: '', + individualizedActivity: '', + reflectionQuestion: '', + teacherSuggestion: '', + spellingAndGrammar: '', reasoning: text || 'No feedback generated.' }; } catch (err) { diff --git a/src/lib/utils/types.ts b/src/lib/utils/types.ts index e4d40bb..063f426 100644 --- a/src/lib/utils/types.ts +++ b/src/lib/utils/types.ts @@ -1,9 +1,10 @@ export interface OpenAIResponse { grade: string; strengths: string; - areas_for_improvement: string; - individualized_activity: string; - reflection_question: string; - teacher_suggestion: string; + areasForImprovement: string; + individualizedActivity: string; + reflectionQuestion: string; + teacherSuggestion: string; + spellingAndGrammar: string; reasoning: string; } diff --git a/src/routes/api/grade/+server.ts b/src/routes/api/grade/+server.ts index cd6aa26..7f8e667 100644 --- a/src/routes/api/grade/+server.ts +++ b/src/routes/api/grade/+server.ts @@ -35,7 +35,7 @@ export const POST: RequestHandler = async (event: RequestEvent) => { return new Response(JSON.stringify({ success: true, task: task.trim(), - feedback: `Grade: ${aiResult.grade}\nStrengths: ${aiResult.strengths}\nAreas for Improvement: ${aiResult.areas_for_improvement}\nIndividualized Activity: ${aiResult.individualized_activity}\nReasoning: ${aiResult.reasoning}`, + feedback: `Grade: ${aiResult.grade}\nStrengths: ${aiResult.strengths}\nAreas for Improvement: ${aiResult.areasForImprovement}\nIndividualized Activity: ${aiResult.individualizedActivity}\nSpelling and Grammar: ${aiResult.spellingAndGrammar}\nReasoning: ${aiResult.reasoning}`, ...aiResult }), { status: 200,