Skip to content

Commit 4af166c

Browse files
alcengeshuming
authored andcommitted
Comments feature for grading (#789)
* Added comments feature for grading * Comments field added to GradingResult, below Grade and XP * Comments editor added to GradingEditor, using react-mde Markdown editor * react-mde updated to latest version * Optional 'comments' field added to the relevant types * Redux actions updated to handle 'comments' field * Test comments added to the mock assessments and gradings * Updated tests to test for new 'comments' field * Refactor of 'Markdown' component to pass down more props * CSS styles for elements in GradingResult and GradingEditor updated * Added grading drafts feature * Implemented draft saving and loading mechanism using local storage * New buttons for 'Save Draft' and 'Load Draft' * Old 'Save' functionality replaced with 'Submit and Continue' * Unique logic for each button to determine applied CSS styles * Modified CSS styles for editor interface * Fixed issue where submitting would raise a 'You have unsaved changes' dialog box * Confirmation box appears when loading draft will overwrite unsaved changes * Minor fixes to CSS and code * Fix for "<td> cannot appear as a child of <tbody>" warning * Fix grading editor checking for grade and XP boundaries on every state change * Tweaked CSS to clean up grey lines on grading editor interface * Remove drafts feature * 'Save Draft' and 'Load Draft' replaced with 'Save Changes' and 'Discard Changes' * Styles for new buttons updated * 'Submit and Continue' renamed to 'Save and Continue' * New Redux Action to support 'Save and Continue' * Updated CSS stylesheet for grading editor * Added tests for 'Save and Continue'
1 parent eb3b774 commit 4af166c

File tree

22 files changed

+763
-138
lines changed

22 files changed

+763
-138
lines changed

package-lock.json

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"react-dom": "^16.8.6",
6363
"react-dom-factories": "^1.0.2",
6464
"react-hotkeys": "^1.1.4",
65-
"react-mde": "^5.6.0",
65+
"react-mde": "^7.6.2",
6666
"react-redux": "^5.1.0",
6767
"react-router": "^4.2.0",
6868
"react-router-dom": "^4.2.2",

src/actions/__tests__/session.ts

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
submitAnswer,
1919
submitAssessment,
2020
submitGrading,
21+
submitGradingAndContinue,
2122
unsubmitSubmission,
2223
updateAssessment,
2324
updateAssessmentOverviews,
@@ -195,7 +196,25 @@ test('submitGrading generates correct action object with default values', () =>
195196
submissionId,
196197
questionId,
197198
gradeAdjustment: 0,
198-
xpAdjustment: 0
199+
xpAdjustment: 0,
200+
comments: undefined
201+
}
202+
});
203+
});
204+
205+
test('submitGradingAndContinue generates correct action object with default values', () => {
206+
const submissionId = 8;
207+
const questionId = 2;
208+
209+
const action = submitGradingAndContinue(submissionId, questionId);
210+
expect(action).toEqual({
211+
type: actionTypes.SUBMIT_GRADING_AND_CONTINUE,
212+
payload: {
213+
submissionId,
214+
questionId,
215+
gradeAdjustment: 0,
216+
xpAdjustment: 0,
217+
comments: undefined
199218
}
200219
});
201220
});
@@ -205,14 +224,41 @@ test('submitGrading generates correct action object', () => {
205224
const questionId = 3;
206225
const gradeAdjustment = 10;
207226
const xpAdjustment = 100;
208-
const action = submitGrading(submissionId, questionId, gradeAdjustment, xpAdjustment);
227+
const comments = 'my comment';
228+
const action = submitGrading(submissionId, questionId, gradeAdjustment, xpAdjustment, comments);
209229
expect(action).toEqual({
210230
type: actionTypes.SUBMIT_GRADING,
211231
payload: {
212232
submissionId,
213233
questionId,
214234
gradeAdjustment,
215-
xpAdjustment
235+
xpAdjustment,
236+
comments
237+
}
238+
});
239+
});
240+
241+
test('submitGradingAndContinue generates correct action object', () => {
242+
const submissionId = 4;
243+
const questionId = 7;
244+
const gradeAdjustment = 90;
245+
const xpAdjustment = 55;
246+
const comments = 'another comment';
247+
const action = submitGradingAndContinue(
248+
submissionId,
249+
questionId,
250+
gradeAdjustment,
251+
xpAdjustment,
252+
comments
253+
);
254+
expect(action).toEqual({
255+
type: actionTypes.SUBMIT_GRADING_AND_CONTINUE,
256+
payload: {
257+
submissionId,
258+
questionId,
259+
gradeAdjustment,
260+
xpAdjustment,
261+
comments
216262
}
217263
});
218264
});
@@ -329,7 +375,8 @@ test('updateGrading generates correct action object', () => {
329375
grade: 10,
330376
gradeAdjustment: 0,
331377
xp: 100,
332-
xpAdjustment: 0
378+
xpAdjustment: 0,
379+
comments: 'Well done.'
333380
}
334381
}
335382
];

src/actions/actionTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export const SET_USER = 'SET_USER';
9999
export const SUBMIT_ANSWER = 'SUBMIT_ANSWER';
100100
export const SUBMIT_ASSESSMENT = 'SUBMIT_ASSESSMENT';
101101
export const SUBMIT_GRADING = 'SUBMIT_GRADING';
102+
export const SUBMIT_GRADING_AND_CONTINUE = 'SUBMIT_GRADING_AND_CONTINUE';
102103
export const UNSUBMIT_SUBMISSION = 'UNSUBMIT_SUBMISSION';
103104
export const UPDATE_HISTORY_HELPERS = 'UPDATE_HISTORY_HELPERS';
104105
export const UPDATE_ASSESSMENT_OVERVIEWS = 'UPDATE_ASSESSMENT_OVERVIEWS';

src/actions/session.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,33 @@ export const submitGrading: ActionCreator<actionTypes.IAction> = (
8585
submissionId: number,
8686
questionId: number,
8787
gradeAdjustment: number = 0,
88-
xpAdjustment: number = 0
88+
xpAdjustment: number = 0,
89+
comments?: string
8990
) => ({
9091
type: actionTypes.SUBMIT_GRADING,
9192
payload: {
9293
submissionId,
9394
questionId,
9495
gradeAdjustment,
95-
xpAdjustment
96+
xpAdjustment,
97+
comments
98+
}
99+
});
100+
101+
export const submitGradingAndContinue: ActionCreator<actionTypes.IAction> = (
102+
submissionId: number,
103+
questionId: number,
104+
gradeAdjustment: number = 0,
105+
xpAdjustment: number = 0,
106+
comments?: string
107+
) => ({
108+
type: actionTypes.SUBMIT_GRADING_AND_CONTINUE,
109+
payload: {
110+
submissionId,
111+
questionId,
112+
gradeAdjustment,
113+
xpAdjustment,
114+
comments
96115
}
97116
});
98117

0 commit comments

Comments
 (0)