Skip to content

Grading: Viewable Assessment Briefings #2783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c445d9f
Added briefing (long summary) to Grading (source-academy#2310)
InfinityTwo Feb 7, 2024
c56f548
Added briefing (long summary) to Grading (source-academy#2310)
InfinityTwo Feb 7, 2024
a0e7696
Updated grading briefing to be inline with backend's camelCase
InfinityTwo Feb 9, 2024
1ab2305
Merge branch 'master' of https://github.com/InfinityTwo/sourceacademy…
InfinityTwo Feb 12, 2024
8357342
cleanup code
InfinityTwo Feb 12, 2024
59c98ce
Merge branch 'master' of https://github.com/InfinityTwo/sourceacademy…
InfinityTwo Feb 12, 2024
8195cb1
cleanup code
InfinityTwo Feb 12, 2024
9e9449e
Merge branch 'grading-briefing' of https://github.com/InfinityTwo/sou…
InfinityTwo Feb 12, 2024
21a212b
removal of accidental commit of package-lock and prettierignore
InfinityTwo Feb 12, 2024
4f6cb9c
Update dependency npm-run-all2 to v6 (#2770)
renovate[bot] Feb 9, 2024
8d63df3
Update dependency eslint-plugin-simple-import-sort to v11 (#2769)
renovate[bot] Feb 9, 2024
e01c64f
Enable Stepper for Typed Variant (#2766)
Zenkoh1 Feb 9, 2024
138b215
Update dependency eslint-plugin-simple-import-sort to v12 (#2771)
renovate[bot] Feb 11, 2024
34b8cde
Upgrade to Blueprint v5 (#2718)
RichDom2185 Feb 12, 2024
52d49ff
cleanup code
InfinityTwo Feb 12, 2024
2d4d8e4
cleanup code
InfinityTwo Feb 12, 2024
5e0291e
removal of accidental commit of package-lock and prettierignore
InfinityTwo Feb 12, 2024
b2316aa
Merge branch 'grading-briefing' of https://github.com/InfinityTwo/sou…
InfinityTwo Feb 12, 2024
1c5d47d
resolve on some type conflicts
InfinityTwo Feb 12, 2024
87d2d9e
Merge branch 'source-academy:master' into grading-briefing
InfinityTwo Feb 12, 2024
5eba8e5
Merge branch 'source-academy:master' into grading-briefing
InfinityTwo Feb 13, 2024
26d5e46
fix for TypeError on test action
InfinityTwo Feb 14, 2024
b30299f
Merge branch 'source-academy:master' into grading-briefing
InfinityTwo Feb 14, 2024
1e7cd41
yarn prettier checks
InfinityTwo Feb 14, 2024
dc029b1
Merge branch 'source-academy:master' into grading-briefing
InfinityTwo Feb 14, 2024
4d7bc9b
Merge branch 'master' into grading-briefing
RichDom2185 Feb 14, 2024
ecfa0ae
Merge branch 'master' into grading-briefing
RichDom2185 Feb 18, 2024
1a9799d
Added subtype for GradingQuery with GradingAssessment; added GradingM…
InfinityTwo Feb 19, 2024
0527058
resolved edited export type
InfinityTwo Feb 19, 2024
efdfddb
missing prettier check
InfinityTwo Feb 19, 2024
f978939
Merge branch 'master' into grading-briefing
lhw-1 Feb 21, 2024
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
4 changes: 2 additions & 2 deletions src/commons/application/ApplicationTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Chapter, Language, SourceError, Variant } from 'js-slang/dist/types';
import { AcademyState } from '../../features/academy/AcademyTypes';
import { AchievementState } from '../../features/achievement/AchievementTypes';
import { DashboardState } from '../../features/dashboard/DashboardTypes';
import { Grading } from '../../features/grading/GradingTypes';
import { GradingQuery } from '../../features/grading/GradingTypes';
import { PlaygroundState } from '../../features/playground/PlaygroundTypes';
import { PlaybackStatus, RecordingStatus } from '../../features/sourceRecorder/SourceRecorderTypes';
import { StoriesEnvState, StoriesState } from '../../features/stories/StoriesTypes';
Expand Down Expand Up @@ -508,7 +508,7 @@ export const defaultSession: SessionState = {
sessionId: Date.now(),
githubOctokitObject: { octokit: undefined },
gradingOverviews: undefined,
gradings: new Map<number, Grading>(),
gradings: new Map<number, GradingQuery>(),
notifications: []
};

Expand Down
4 changes: 2 additions & 2 deletions src/commons/application/actions/SessionActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { action } from 'typesafe-actions'; // EDITED

import { Grading, GradingOverview } from '../../../features/grading/GradingTypes';
import { GradingOverview, GradingQuery } from '../../../features/grading/GradingTypes';
import {
Assessment,
AssessmentConfiguration,
Expand Down Expand Up @@ -209,7 +209,7 @@ export const updateGradingOverviews = (overviews: GradingOverview[]) =>
* An extra id parameter is included here because of
* no id for Grading.
*/
export const updateGrading = (submissionId: number, grading: Grading) =>
export const updateGrading = (submissionId: number, grading: GradingQuery) =>
action(UPDATE_GRADING, {
submissionId,
grading
Expand Down
48 changes: 30 additions & 18 deletions src/commons/application/actions/__tests__/SessionActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chapter, Variant } from 'js-slang/dist/types';

import { Grading, GradingOverview } from '../../../../features/grading/GradingTypes';
import { GradingOverview, GradingQuery } from '../../../../features/grading/GradingTypes';
import { Assessment, AssessmentOverview } from '../../../assessment/AssessmentTypes';
import { Notification } from '../../../notificationBadge/NotificationBadgeTypes';
import { GameState, Role, Story } from '../../ApplicationTypes';
Expand Down Expand Up @@ -542,26 +542,38 @@ test('updateGradingOverviews generates correct action object', () => {

test('updateGrading generates correct action object', () => {
const submissionId = 3;
const grading: Grading = [
{
question: jest.genMockFromModule('../../../../features/grading/GradingTypes'),
student: {
name: 'test student',
username: 'E0123456',
id: 234
},
grade: {
xp: 100,
xpAdjustment: 0,
comments: 'Well done.',
grader: {
name: 'HARTIN MENZ',
id: 100
const grading: GradingQuery = {
answers: [
{
question: jest.genMockFromModule('../../../../features/grading/GradingTypes'),
student: {
name: 'test student',
username: 'E0123456',
id: 234
},
gradedAt: '2019-08-16T13:26:32+00:00'
grade: {
xp: 100,
xpAdjustment: 0,
comments: 'Well done.',
grader: {
name: 'HARTIN MENZ',
id: 100
},
gradedAt: '2019-08-16T13:26:32+00:00'
}
}
],
assessment: {
coverPicture: 'https://i.imgur.com/dR7zBPI.jpeg',
id: 1,
number: '5',
reading: 'reading here',
story: 'story here',
summaryLong: 'long summary here',
summaryShort: 'short summary here',
title: 'assessment title here'
}
];
};

const action = updateGrading(submissionId, grading);
expect(action).toEqual({
Expand Down
88 changes: 56 additions & 32 deletions src/commons/application/reducers/__tests__/SessionReducer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chapter, Variant } from 'js-slang/dist/types';

import { Grading, GradingOverview } from '../../../../features/grading/GradingTypes';
import { GradingOverview, GradingQuery } from '../../../../features/grading/GradingTypes';
import {
Assessment,
AssessmentOverview,
Expand Down Expand Up @@ -381,37 +381,61 @@ test('UPDATE_ASSESSMENT_OVERVIEWS works correctly in updating assessment overvie
});

// Test data for UPDATE_GRADING
const gradingTest1: Grading = [
{
question: jest.genMockFromModule('../../../../features/grading/GradingTypes'),
student: {
name: 'test student',
username: 'E0123456',
id: 234
},
grade: {
xp: 100,
xpAdjustment: 0,
comments: 'Well done. Please try the quest!'
const gradingTest1: GradingQuery = {
answers: [
{
question: jest.genMockFromModule('../../../../features/grading/GradingTypes'),
student: {
name: 'test student',
username: 'E0123456',
id: 234
},
grade: {
xp: 100,
xpAdjustment: 0,
comments: 'Well done. Please try the quest!'
}
}
],
assessment: {
coverPicture: 'test string',
id: 1,
number: 'M1A',
reading: 'test string',
story: 'test string',
summaryLong: 'test string',
summaryShort: 'test string',
title: 'test string'
}
];
};

const gradingTest2: Grading = [
{
question: jest.genMockFromModule('../../../../features/grading/GradingTypes'),
student: {
name: 'another test student',
username: 'E0000000',
id: 345
},
grade: {
xp: 500,
xpAdjustment: 20,
comments: 'Good job! All the best for the finals.'
const gradingTest2: GradingQuery = {
answers: [
{
question: jest.genMockFromModule('../../../../features/grading/GradingTypes'),
student: {
name: 'another test student',
username: 'E0000000',
id: 345
},
grade: {
xp: 500,
xpAdjustment: 20,
comments: 'Good job! All the best for the finals.'
}
}
],
assessment: {
coverPicture: 'another test string',
id: 2,
number: 'P2',
reading: 'another test string',
story: 'another test string',
summaryLong: 'another test string',
summaryShort: 'another test string',
title: 'another test string'
}
];
};

test('UPDATE_GRADING works correctly in inserting gradings', () => {
const submissionId = 23;
Expand All @@ -423,14 +447,14 @@ test('UPDATE_GRADING works correctly in inserting gradings', () => {
}
};

const gradingMap: Map<number, Grading> = SessionsReducer(defaultSession, action).gradings;
const gradingMap: Map<number, GradingQuery> = SessionsReducer(defaultSession, action).gradings;
expect(gradingMap.get(submissionId)).toEqual(gradingTest1);
});

test('UPDATE_GRADING works correctly in inserting gradings and retains old data', () => {
const submissionId1 = 45;
const submissionId2 = 56;
const gradings = new Map<number, Grading>();
const gradings = new Map<number, GradingQuery>();
gradings.set(submissionId1, gradingTest1);

const newDefaultSession = {
Expand All @@ -446,14 +470,14 @@ test('UPDATE_GRADING works correctly in inserting gradings and retains old data'
}
};

const gradingMap: Map<number, Grading> = SessionsReducer(newDefaultSession, action).gradings;
const gradingMap: Map<number, GradingQuery> = SessionsReducer(newDefaultSession, action).gradings;
expect(gradingMap.get(submissionId1)).toEqual(gradingTest1);
expect(gradingMap.get(submissionId2)).toEqual(gradingTest2);
});

test('UPDATE_GRADING works correctly in updating gradings', () => {
const submissionId = 23;
const gradings = new Map<number, Grading>();
const gradings = new Map<number, GradingQuery>();
gradings.set(submissionId, gradingTest1);
const newDefaultSession = {
...defaultSession,
Expand All @@ -468,7 +492,7 @@ test('UPDATE_GRADING works correctly in updating gradings', () => {
}
};

const gradingMap: Map<number, Grading> = SessionsReducer(newDefaultSession, action).gradings;
const gradingMap: Map<number, GradingQuery> = SessionsReducer(newDefaultSession, action).gradings;
expect(gradingMap.get(submissionId)).toEqual(gradingTest2);
});

Expand Down
4 changes: 2 additions & 2 deletions src/commons/application/types/SessionTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Octokit } from '@octokit/rest';
import { Chapter, Variant } from 'js-slang/dist/types';

import { Grading, GradingOverview } from '../../../features/grading/GradingTypes';
import { GradingOverview, GradingQuery } from '../../../features/grading/GradingTypes';
import { Device, DeviceSession } from '../../../features/remoteExecution/RemoteExecutionTypes';
import {
Assessment,
Expand Down Expand Up @@ -115,7 +115,7 @@ export type SessionState = {
readonly assessmentOverviews?: AssessmentOverview[];
readonly assessments: Map<number, Assessment>;
readonly gradingOverviews?: GradingOverview[];
readonly gradings: Map<number, Grading>;
readonly gradings: Map<number, GradingQuery>;
readonly notifications: Notification[];
readonly googleUser?: string;
readonly githubAssessment?: MissionRepoData;
Expand Down
16 changes: 11 additions & 5 deletions src/commons/mocks/BackendMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { SagaIterator } from 'redux-saga';
import { call, put, select, takeEvery } from 'redux-saga/effects';

import { FETCH_GROUP_GRADING_SUMMARY } from '../../features/dashboard/DashboardTypes';
import { Grading, GradingOverview, GradingQuestion } from '../../features/grading/GradingTypes';
import {
GradingOverview,
GradingQuery,
GradingQuestion
} from '../../features/grading/GradingTypes';
import {
OverallState,
Role,
Expand Down Expand Up @@ -177,7 +181,7 @@ export function* mockBackendSaga(): SagaIterator {
const accessToken = yield select((state: OverallState) => state.session.accessToken);
const grading = yield call(() => mockFetchGrading(accessToken, submissionId));
if (grading !== null) {
yield put(actions.updateGrading(submissionId, [...grading]));
yield put(actions.updateGrading(submissionId, grading));
}
});

Expand Down Expand Up @@ -217,10 +221,10 @@ export function* mockBackendSaga(): SagaIterator {

const { submissionId, questionId, xpAdjustment, comments } = action.payload;
// Now, update the grade for the question in the Grading in the store
const grading: Grading = yield select((state: OverallState) =>
const grading: GradingQuery = yield select((state: OverallState) =>
state.session.gradings.get(submissionId)
);
const newGrading = grading.slice().map((gradingQuestion: GradingQuestion) => {
const newGrading = grading.answers.slice().map((gradingQuestion: GradingQuestion) => {
if (gradingQuestion.question.id === questionId) {
gradingQuestion.grade = {
xpAdjustment,
Expand All @@ -230,7 +234,9 @@ export function* mockBackendSaga(): SagaIterator {
}
return gradingQuestion;
});
yield put(actions.updateGrading(submissionId, newGrading));
yield put(
actions.updateGrading(submissionId, { answers: newGrading, assessment: grading.assessment })
);
yield call(showSuccessMessage, 'Submitted!', 1000);
};

Expand Down
40 changes: 36 additions & 4 deletions src/commons/mocks/GradingMocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { GradingSummary } from '../../features/dashboard/DashboardTypes';
import { Grading, GradingOverview } from '../../features/grading/GradingTypes';
import {
GradingAnswer,
GradingAssessment,
GradingOverview,
GradingQuery
} from '../../features/grading/GradingTypes';
import { Role } from '../application/ApplicationTypes';
import { Testcase, TestcaseTypes } from '../assessment/AssessmentTypes';
import { mockLibrary } from './AssessmentMocks';
Expand Down Expand Up @@ -102,7 +107,7 @@ export const mockTestcases: Testcase[] = [
{ type: TestcaseTypes.opaque, program: `remainder(17, 23) === 17;`, score: 2, answer: `true` }
];

export const mockGrading: Grading = [
export const mockGradingAnswer: GradingAnswer = [
{
question: {
answer: `function remainder(n, d) {
Expand Down Expand Up @@ -386,20 +391,47 @@ New message from **Avenger**!
}
];

export const mockGradingAssessment: GradingAssessment = {
coverPicture: 'https://i.imgur.com/dR7zBPI.jpeg',
id: 1,
number: '10',
reading:
'This is for you to read. Read it carefully. Perhaps you will find the answer to life here.',
story: `Story:
Start of story.
End of story.
The End.

Credits
Starring: Source Academy`,
summaryLong:
'This is the long summary of the assessment. It is a very very very very long summary',
summaryShort: 'This is short summary',
title: 'Assessment 1: Some Title'
};

export const mockGradingQuery: GradingQuery = {
answers: mockGradingAnswer,
assessment: mockGradingAssessment
};

/**
* Mock for fetching a trainer/admin's student grading information.
* A null value is returned for invalid token or role.
*
* @param accessToken a valid access token for the cadet backend.
*/
export const mockFetchGrading = (accessToken: string, submissionId: number): Grading | null => {
export const mockFetchGrading = (
accessToken: string,
submissionId: number
): GradingQuery | null => {
// mocks backend role fetching
const permittedRoles: Role[] = [Role.Admin, Role.Staff];
const role: Role | null = mockFetchRole(accessToken);
if (role === null || !permittedRoles.includes(role)) {
return null;
} else {
return mockGrading;
return mockGradingQuery;
}
};

Expand Down
Loading