Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
be85663
Add Grading comment selector basic UI
EugeneOYZ1203n Jan 27, 2025
05b449a
Connect to backend
EugeneOYZ1203n Feb 4, 2025
780a269
Content changes not found but are showing up as changed
EugeneOYZ1203n Feb 4, 2025
3ae34a0
Hide generate comment button if no LLM prompt
EugeneOYZ1203n Mar 18, 2025
b41843a
Input field for API key during Course creation
EugeneOYZ1203n Mar 18, 2025
05b1a9e
Add input field for enabling LLM Grading
EugeneOYZ1203n Mar 20, 2025
2d54115
Disable comment selector if llm grading not enabled
EugeneOYZ1203n Mar 20, 2025
928633d
Added LLM API Key input and integration with backend
EugeneOYZ1203n Mar 26, 2025
73703b1
Add to the course editing panel for llm grading and api key
EugeneOYZ1203n Mar 26, 2025
730cb35
Update localStorage.ts
EugeneOYZ1203n Apr 5, 2025
fb4f15d
Add save chosen and final comment feature
EugeneOYZ1203n Apr 6, 2025
44a583e
Add Spinner when generating comments
EugeneOYZ1203n Apr 6, 2025
580644a
Update to show API Key as password field
EugeneOYZ1203n Apr 6, 2025
774fc2d
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 Apr 17, 2025
a0512bd
Fix format
RichDom2185 Apr 17, 2025
b3f5ca7
Revert "Content changes not found but are showing up as changed"
RichDom2185 Apr 17, 2025
a91b128
Merge branch 'master' into eugene-grading-comment-selector
martin-henz Jun 10, 2025
509b3a3
Merge branch 'master' into eugene-grading-comment-selector
RichDom2185 Jun 16, 2025
aa3bfd8
Edit frontend to load previous AI comments by default
Tkaixiang Sep 28, 2025
7248aae
Moves api key, api url, llm model and course prompt to course level
Tkaixiang Sep 30, 2025
27fac47
Add tooltip about formatting instructions
Tkaixiang Oct 7, 2025
09376be
style
Tkaixiang Oct 7, 2025
412bfd8
Add view "composed prompt" in the grading editor view
Tkaixiang Oct 7, 2025
0628c81
Remove un-used 'save comments'
Tkaixiang Oct 7, 2025
1226a2f
typo
Tkaixiang Oct 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/commons/application/types/SessionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export type SessionState = {
readonly enableAchievements?: boolean;
readonly enableSourcecast?: boolean;
readonly enableStories?: boolean;
readonly enableLlmGrading?: boolean;
readonly llmApiKey?: string;
readonly llmModel?: string;
readonly llmApiUrl?: string;
readonly llmCourseLevelPrompt?: string;
readonly sourceChapter?: Chapter;
readonly sourceVariant?: Variant;
readonly moduleHelpText?: string;
Expand Down Expand Up @@ -105,10 +110,15 @@ export type CourseConfiguration = {
enableAchievements: boolean;
enableSourcecast: boolean;
enableStories: boolean;
enableLlmGrading?: boolean;
sourceChapter: Chapter;
sourceVariant: Variant;
moduleHelpText: string;
assetsPrefix: string;
llmApiKey?: string;
llmModel?: string;
llmApiUrl?: string;
llmCourseLevelPrompt?: string;
};

export type AdminPanelCourseRegistration = {
Expand Down
2 changes: 2 additions & 0 deletions src/commons/assessment/AssessmentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export interface IProgrammingQuestion extends BaseQuestion {
prepend: string;
postpend: string;
solutionTemplate: string;
llm_prompt?: string | null;
testcases: Testcase[];
testcasesPrivate?: Testcase[]; // For mission control
type: 'programming';
Expand Down Expand Up @@ -279,6 +280,7 @@ export const programmingTemplate = (): IProgrammingQuestion => {
prepend: '',
solutionTemplate: '//This is a mock solution template',
postpend: '',
llm_prompt: null,
testcases: [],
testcasesPrivate: [],
type: 'programming',
Expand Down
37 changes: 35 additions & 2 deletions src/commons/dropdown/DropdownCreateCourse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ const DropdownCreateCourse: React.FC<Props> = props => {
enableAchievements: true,
enableSourcecast: true,
enableStories: false,
enableLlmGrading: false,
sourceChapter: Chapter.SOURCE_1,
sourceVariant: Variant.DEFAULT,
moduleHelpText: ''
moduleHelpText: '',
llmApiKey: ''
});

const [courseHelpTextSelectedTab, setCourseHelpTextSelectedTab] =
Expand Down Expand Up @@ -222,7 +224,8 @@ const DropdownCreateCourse: React.FC<Props> = props => {
})
}
/>

</div>
<div>
<Switch
checked={courseConfig.enableStories}
inline
Expand All @@ -234,6 +237,18 @@ const DropdownCreateCourse: React.FC<Props> = props => {
})
}
/>

<Switch
checked={courseConfig.enableLlmGrading}
inline
label="Enable LLM Grading"
onChange={e =>
setCourseConfig({
...courseConfig,
enableLlmGrading: (e.target as HTMLInputElement).checked
})
}
/>
</div>
</div>
<div>
Expand Down Expand Up @@ -273,6 +288,24 @@ const DropdownCreateCourse: React.FC<Props> = props => {
fill
/>
</FormGroup>
<FormGroup
helperText="API Key for LLM comment generation for grading. Will not be enabled if not provided"
label={'LLM API Key'}
labelInfo="(optional)"
labelFor="llmApiKey"
>
<InputGroup
id="llmApiKey"
type="password"
value={courseConfig.llmApiKey}
onChange={e =>
setCourseConfig({
...courseConfig,
llmApiKey: e.target.value
})
}
/>
</FormGroup>
</div>
<div className="create-course-button-container">
<Button text="Create Course" onClick={submitHandler} />
Expand Down
44 changes: 43 additions & 1 deletion src/commons/sagas/RequestsSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ export const getGrading = async (
solutionTemplate: question.solutionTemplate,
prepend: question.prepend || '',
postpend: question.postpend || '',
llm_prompt: question.llm_prompt || null,
testcases: question.testcases || [],
type: question.type as QuestionType,
maxXp: question.maxXp
Expand All @@ -894,7 +895,8 @@ export const getGrading = async (
xp: grade.xp,
xpAdjustment: grade.xpAdjustment,
comments: grade.comments
}
},
ai_comments: gradingQuestion.ai_comments?.response.split('|||') || []
} as GradingQuestion;

if (gradingQuestion.grade.grader !== null) {
Expand Down Expand Up @@ -1331,6 +1333,46 @@ export const removeAssessmentConfig = async (
return resp;
};

/**
* POST /courses/{courseId}/admin/generate-comments/{submissionId}/{questionId}
*/
export const postGenerateComments = async (
tokens: Tokens,
submission_id: integer,
question_id: integer
): Promise<{ comments: string[] } | null> => {
const resp = await request(
`${courseId()}/admin/generate-comments/${submission_id}/${question_id}`,
'POST',
{
...tokens
}
);
if (!resp || !resp.ok) {
return null;
}

return await resp.json();
};

export const saveFinalComment = async (
tokens: Tokens,
submission_id: integer,
question_id: integer,
comment: string
): Promise<Response | null> => {
const resp = await request(
`${courseId()}/admin/save-final-comment/${submission_id}/${question_id}`,
'POST',
{
body: { comment: comment },
...tokens
}
);

return resp;
};

/**
* GET /courses/{courseId}/admin/users
*/
Expand Down
4 changes: 4 additions & 0 deletions src/features/grading/GradingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export type GradingAssessment = {
summaryLong: string;
summaryShort: string;
title: string;
llm_assessment_prompt: string | null;
};

export type GradingQuery = {
Expand Down Expand Up @@ -189,6 +190,9 @@ export type GradingQuestion = {
};
gradedAt?: string;
};
autogradingResults: AutogradingResult[];
autoGradingStatus: string;
ai_comments?: string[];
};

/**
Expand Down
21 changes: 18 additions & 3 deletions src/pages/academy/adminPanel/AdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ const defaultCourseConfig: UpdateCourseConfiguration = {
enableAchievements: true,
enableSourcecast: true,
enableStories: false,
moduleHelpText: ''
enableLlmGrading: false,
moduleHelpText: '',
llmApiKey: '',
llmModel: '',
llmApiUrl: '',
llmCourseLevelPrompt: ''
};

const AdminPanel: React.FC = () => {
Expand Down Expand Up @@ -62,7 +67,12 @@ const AdminPanel: React.FC = () => {
enableAchievements: session.enableAchievements,
enableSourcecast: session.enableSourcecast,
enableStories: session.enableStories,
moduleHelpText: session.moduleHelpText
enableLlmGrading: session.enableLlmGrading,
moduleHelpText: session.moduleHelpText,
llmApiKey: session.llmApiKey,
llmModel: session.llmModel,
llmApiUrl: session.llmApiUrl,
llmCourseLevelPrompt: session.llmCourseLevelPrompt
});
}, [
session.courseName,
Expand All @@ -71,8 +81,13 @@ const AdminPanel: React.FC = () => {
session.enableGame,
session.enableSourcecast,
session.enableStories,
session.enableLlmGrading,
session.moduleHelpText,
session.viewable
session.viewable,
session.llmApiKey,
session.llmModel,
session.llmApiUrl,
session.llmCourseLevelPrompt
]);

const tableRef = useRef<ImperativeAssessmentConfigPanel>(null);
Expand Down
Loading