Skip to content

Revert "Grading: Viewable Assessment Briefings" #2

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 { GradingQuery } from '../../features/grading/GradingTypes';
import { Grading } 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 @@ -491,7 +491,7 @@ export const defaultSession: SessionState = {
sessionId: Date.now(),
githubOctokitObject: { octokit: undefined },
gradingOverviews: undefined,
gradings: new Map<number, GradingQuery>(),
gradings: new Map<number, Grading>(),
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 { GradingOverview, GradingQuery } from '../../../features/grading/GradingTypes';
import { Grading, GradingOverview } from '../../../features/grading/GradingTypes';
import {
Assessment,
AssessmentConfiguration,
Expand Down Expand Up @@ -220,7 +220,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: GradingQuery) =>
export const updateGrading = (submissionId: number, grading: Grading) =>
action(UPDATE_GRADING, {
submissionId,
grading
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 { GradingOverview, GradingQuery } from '../../../features/grading/GradingTypes';
import { Grading, GradingOverview } from '../../../features/grading/GradingTypes';
import { Device, DeviceSession } from '../../../features/remoteExecution/RemoteExecutionTypes';
import {
Assessment,
Expand Down Expand Up @@ -122,7 +122,7 @@ export type SessionState = {
readonly assessmentOverviews?: AssessmentOverview[];
readonly assessments: Map<number, Assessment>;
readonly gradingOverviews?: GradingOverview[];
readonly gradings: Map<number, GradingQuery>;
readonly gradings: Map<number, Grading>;
readonly notifications: Notification[];
readonly googleUser?: string;
readonly githubAssessment?: MissionRepoData;
Expand Down
10 changes: 5 additions & 5 deletions src/commons/mocks/BackendMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SagaIterator } from 'redux-saga';
import { call, put, select, takeEvery } from 'redux-saga/effects';

import { FETCH_GROUP_GRADING_SUMMARY } from '../../features/dashboard/DashboardTypes';
import { GradingOverview, GradingQuery, GradingQuestion } from '../../features/grading/GradingTypes';
import { Grading, GradingOverview, GradingQuestion } from '../../features/grading/GradingTypes';
import {
OverallState,
Role,
Expand Down Expand Up @@ -177,7 +177,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 +217,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: GradingQuery = yield select((state: OverallState) =>
const grading: Grading = yield select((state: OverallState) =>
state.session.gradings.get(submissionId)
);
const newGrading = grading.answers.slice().map((gradingQuestion: GradingQuestion) => {
const newGrading = grading.slice().map((gradingQuestion: GradingQuestion) => {
if (gradingQuestion.question.id === questionId) {
gradingQuestion.grade = {
xpAdjustment,
Expand All @@ -230,7 +230,7 @@ export function* mockBackendSaga(): SagaIterator {
}
return gradingQuestion;
});
yield put(actions.updateGrading(submissionId, {"answers": newGrading, "assessment": grading.assessment}));
yield put(actions.updateGrading(submissionId, newGrading));
yield call(showSuccessMessage, 'Submitted!', 1000);
};

Expand Down
10 changes: 5 additions & 5 deletions src/commons/sagas/BackendSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
FETCH_GROUP_GRADING_SUMMARY,
GradingSummary
} from '../../features/dashboard/DashboardTypes';
import { GradingOverview, GradingQuery, GradingQuestion } from '../../features/grading/GradingTypes';
import { Grading, GradingOverview, GradingQuestion } from '../../features/grading/GradingTypes';
import {
CHANGE_DATE_ASSESSMENT,
DELETE_ASSESSMENT,
Expand Down Expand Up @@ -438,7 +438,7 @@ function* BackendSaga(): SagaIterator {
const tokens: Tokens = yield selectTokens();
const id = action.payload;

const grading: GradingQuery | null = yield call(getGrading, id, tokens);
const grading: Grading | null = yield call(getGrading, id, tokens);
if (grading) {
yield put(actions.updateGrading(id, grading));
}
Expand Down Expand Up @@ -500,10 +500,10 @@ function* BackendSaga(): SagaIterator {
yield call(showSuccessMessage, 'Submitted!', 1000);

// Now, update the grade for the question in the Grading in the store
const grading: GradingQuery = yield select((state: OverallState) =>
const grading: Grading = yield select((state: OverallState) =>
state.session.gradings.get(submissionId)
);
const newGrading = grading.answers.slice().map((gradingQuestion: GradingQuestion) => {
const newGrading = grading.slice().map((gradingQuestion: GradingQuestion) => {
if (gradingQuestion.question.id === questionId) {
gradingQuestion.grade = {
xpAdjustment,
Expand All @@ -514,7 +514,7 @@ function* BackendSaga(): SagaIterator {
return gradingQuestion;
});

yield put(actions.updateGrading(submissionId, {"answers": newGrading, "assessment": grading.assessment}));
yield put(actions.updateGrading(submissionId, newGrading));
};

const sendGradeAndContinue = function* (
Expand Down
8 changes: 4 additions & 4 deletions src/commons/sagas/RequestsSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GoalProgress
} from '../../features/achievement/AchievementTypes';
import { GradingSummary } from '../../features/dashboard/DashboardTypes';
import { Grading, GradingOverview, GradingQuery, GradingQuestion } from '../../features/grading/GradingTypes';
import { Grading, GradingOverview, GradingQuestion } from '../../features/grading/GradingTypes';
import {
Device,
WebSocketEndpointInformation
Expand Down Expand Up @@ -665,7 +665,7 @@ export const getGradingOverviews = async (
/**
* GET /courses/{courseId}/admin/grading/{submissionId}
*/
export const getGrading = async (submissionId: number, tokens: Tokens): Promise<GradingQuery | null> => {
export const getGrading = async (submissionId: number, tokens: Tokens): Promise<Grading | null> => {
const resp = await request(`${courseId()}/admin/grading/${submissionId}`, 'GET', {
...tokens
});
Expand All @@ -675,7 +675,7 @@ export const getGrading = async (submissionId: number, tokens: Tokens): Promise<
}

const gradingResult = await resp.json();
const grading: Grading = gradingResult.answers.map((gradingQuestion: any) => {
const grading: Grading = gradingResult.map((gradingQuestion: any) => {
const { student, question, grade } = gradingQuestion;
const result = {
question: {
Expand Down Expand Up @@ -709,7 +709,7 @@ export const getGrading = async (submissionId: number, tokens: Tokens): Promise<
return result;
});

return {"answers": grading, "assessment": gradingResult.assessment};
return grading;
};

/**
Expand Down
14 changes: 0 additions & 14 deletions src/features/grading/GradingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,6 @@ export type GradingOverviewWithNotifications = {
*/
export type Grading = GradingQuestion[];

export type GradingQuery = {
answers: Grading,
assessment: {
coverPicture: string;
id: number;
number: string;
reading: string;
story: string;
summaryLong: string;
summaryShort: string;
title: string;
}
}

/**
* Encapsulates information regarding grading a
* particular question in a submission.
Expand Down
50 changes: 21 additions & 29 deletions src/pages/academy/grading/subcomponents/GradingWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
}

let questionId = props.questionId;
if (props.questionId >= grading.answers.length) {
questionId = grading.answers.length - 1;
if (props.questionId >= grading.length) {
questionId = grading.length - 1;
}

const question: AnsweredQuestion = grading.answers[questionId].question;
const question: AnsweredQuestion = grading[questionId].question;
let answer: string = '';

if (question.type === QuestionTypes.programming) {
Expand Down Expand Up @@ -212,7 +212,7 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
* as the function to move to the next question does not check
* if that question exists
*/
if (grading.answers[questionId] === undefined) {
if (grading[questionId] === undefined) {
navigate(`/courses/${courseId}/grading`);
} else {
checkWorkspaceReset(props);
Expand All @@ -233,7 +233,7 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
if (storedSubmissionId === submissionId && storedQuestionId === questionId) {
return;
}
const question = grading!.answers[questionId].question as Question;
const question = grading![questionId].question as Question;

let autogradingResults: AutogradingResult[] = [];
let editorValue: string = '';
Expand Down Expand Up @@ -298,22 +298,22 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
/* Render an editor with the xp given to the current question. */
body: (
<GradingEditor
solution={grading!.answers[questionId].question.solution}
questionId={grading!.answers[questionId].question.id}
solution={grading![questionId].question.solution}
questionId={grading![questionId].question.id}
submissionId={props.submissionId}
initialXp={grading!.answers[questionId].grade.xp}
xpAdjustment={grading!.answers[questionId].grade.xpAdjustment}
maxXp={grading!.answers[questionId].question.maxXp}
studentName={grading!.answers[questionId].student.name}
studentUsername={grading!.answers[questionId].student.username}
comments={grading!.answers[questionId].grade.comments ?? ''}
initialXp={grading![questionId].grade.xp}
xpAdjustment={grading![questionId].grade.xpAdjustment}
maxXp={grading![questionId].question.maxXp}
studentName={grading![questionId].student.name}
studentUsername={grading![questionId].student.username}
comments={grading![questionId].grade.comments ?? ''}
graderName={
grading!.answers[questionId].grade.grader
? grading!.answers[questionId].grade.grader!.name
grading![questionId].grade.grader
? grading![questionId].grade.grader!.name
: undefined
}
gradedAt={
grading!.answers[questionId].grade.grader ? grading!.answers[questionId].grade.gradedAt! : undefined
grading![questionId].grade.grader ? grading![questionId].grade.gradedAt! : undefined
}
/>
),
Expand All @@ -322,7 +322,7 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
{
label: `Question ${questionId + 1}`,
iconName: IconNames.NINJA,
body: <Markdown content={grading!.answers[questionId].question.content} />,
body: <Markdown content={grading![questionId].question.content} />,
id: SideContentType.questionOverview
},
{
Expand All @@ -337,17 +337,9 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
/>
),
id: SideContentType.autograder
},
{
label: `Briefing`,
iconName: IconNames.BRIEFCASE,
body: (
grading ? <Markdown content={grading.assessment.summaryLong} /> : <Markdown content="Briefing Unavailable. Try refreshing the page." />
),
id: SideContentType.briefing
}
];
const externalLibrary = grading!.answers[questionId].question.library.external;
const externalLibrary = grading![questionId].question.library.external;
const functionsAttached = externalLibrary.symbols;
if (functionsAttached.includes('get_matrix')) {
tabs.push({
Expand Down Expand Up @@ -383,7 +375,7 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
const controlBarProps: (q: number) => ControlBarProps = (questionId: number) => {
const listingPath = `/courses/${courseId}/grading`;
const gradingWorkspacePath = listingPath + `/${props.submissionId}`;
const questionProgress: [number, number] = [questionId + 1, grading!.answers.length];
const questionProgress: [number, number] = [questionId + 1, grading!.length];

const onClickPrevious = () =>
navigate(gradingWorkspacePath + `/${(questionId - 1).toString()}`);
Expand Down Expand Up @@ -458,9 +450,9 @@ const GradingWorkspace: React.FC<GradingWorkspaceProps> = props => {
}

/* If questionId is out of bounds, set it to the max. */
const questionId = props.questionId >= grading.answers.length ? grading.answers.length - 1 : props.questionId;
const questionId = props.questionId >= grading.length ? grading.length - 1 : props.questionId;
/* Get the question to be graded */
const question = grading.answers[questionId].question as Question;
const question = grading[questionId].question as Question;
const workspaceProps: WorkspaceProps = {
controlBarProps: controlBarProps(questionId),
editorContainerProps:
Expand Down