Skip to content

Commit 2425d4b

Browse files
committed
Re-format ai_comments to reference answer_id instead
1 parent 445a266 commit 2425d4b

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

src/commons/sagas/RequestsSaga.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,9 @@ export const getGrading = async (
10301030

10311031
const gradingResult = await resp.json();
10321032
const grading: GradingAnswer = gradingResult.answers.map((gradingQuestion: any) => {
1033-
const { student, question, grade, team } = gradingQuestion;
1033+
const { id, student, question, grade, team } = gradingQuestion;
10341034
const result = {
1035+
id,
10351036
question: {
10361037
answer: question.answer,
10371038
lastModifiedAt: question.lastModifiedAt,
@@ -1555,20 +1556,15 @@ export const removeAssessmentConfig = async (
15551556
};
15561557

15571558
/**
1558-
* POST /courses/{courseId}/admin/generate-comments/{submissionId}/{questionId}
1559+
* POST /courses/{courseId}/admin/generate-comments/{answer_id}/
15591560
*/
15601561
export const postGenerateComments = async (
15611562
tokens: Tokens,
1562-
submission_id: number,
1563-
question_id: number
1563+
answer_id: number
15641564
): Promise<{ comments: string[] } | null> => {
1565-
const resp = await request(
1566-
`${courseId()}/admin/generate-comments/${submission_id}/${question_id}`,
1567-
'POST',
1568-
{
1569-
...tokens
1570-
}
1571-
);
1565+
const resp = await request(`${courseId()}/admin/generate-comments/${answer_id}`, 'POST', {
1566+
...tokens
1567+
});
15721568
if (!resp || !resp.ok) {
15731569
return null;
15741570
}
@@ -1578,18 +1574,13 @@ export const postGenerateComments = async (
15781574

15791575
export const saveFinalComment = async (
15801576
tokens: Tokens,
1581-
submission_id: number,
1582-
question_id: number,
1577+
answer_id: number,
15831578
comment: string
15841579
): Promise<Response | null> => {
1585-
const resp = await request(
1586-
`${courseId()}/admin/save-final-comment/${submission_id}/${question_id}`,
1587-
'POST',
1588-
{
1589-
body: { comment: comment },
1590-
...tokens
1591-
}
1592-
);
1580+
const resp = await request(`${courseId()}/admin/save-final-comment/${answer_id}`, 'POST', {
1581+
body: { comment: comment },
1582+
...tokens
1583+
});
15931584

15941585
return resp;
15951586
};

src/features/grading/GradingTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export type IGradingTableProperties = {
170170
* particular question in a submission.
171171
*/
172172
export type GradingQuestion = {
173+
id: number;
173174
question: AnsweredQuestion;
174175
team?: Array<{
175176
username: any;

src/pages/academy/grading/subcomponents/GradingEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type GradingSaveFunction = (
4141
) => void;
4242

4343
type Props = {
44+
answer_id: number;
4445
solution: number | string | null;
4546
questionId: number;
4647
submissionId: number;
@@ -119,7 +120,7 @@ const GradingEditor: React.FC<Props> = props => {
119120
}, [props.submissionId, props.questionId]);
120121

121122
const getCommentSuggestions = async () => {
122-
const resp = await postGenerateComments(tokens, props.submissionId, props.questionId);
123+
const resp = await postGenerateComments(tokens, props.answer_id);
123124
return resp;
124125
};
125126

@@ -132,7 +133,7 @@ const GradingEditor: React.FC<Props> = props => {
132133
};
133134

134135
const postSaveFinalComment = async (comment: string) => {
135-
const resp = await saveFinalComment(tokens, props.submissionId, props.questionId, comment);
136+
const resp = await saveFinalComment(tokens, props.answer_id, comment);
136137
return resp;
137138
};
138139

src/pages/academy/grading/subcomponents/GradingWorkspace.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ const GradingWorkspace: React.FC<Props> = props => {
304304
/* Render an editor with the xp given to the current question. */
305305
body: (
306306
<GradingEditor
307+
answer_id={grading!.answers[questionId].id}
307308
ai_comments={grading!.answers[questionId].ai_comments || []}
308309
solution={grading!.answers[questionId].question.solution}
309310
questionId={grading!.answers[questionId].question.id}

0 commit comments

Comments
 (0)