-
Notifications
You must be signed in to change notification settings - Fork 174
Add Grading API calls #238
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
Conversation
Pull Request Test Coverage Report for Build 527
💛 - Coveralls |
@ningyuansg will do |
g: number, | ||
s: string, | ||
i: number | undefined | ||
) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full param names (since prettier put them on separate lines already). I think abbreviated param names is acceptable just for stuff like the tests.
type State = { | ||
mdeState: ReactMdeTypes.MdeState | ||
XPInput: number | undefined | ||
adjustmentInput: number | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be number | null
, like that time with the editorValue
gradingXP: state.workspaces.grading.gradingXP | ||
} | ||
} | ||
const mapStateToProps: MapStateToProps<{}, {}, IState> = state => ({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass null
to connect
in lieu of an empty mapStateToProps
.
src/sagas/backend.ts
Outdated
errorMessage = 'Invalid or missing parameter(s) or submission and/or question not found' | ||
break | ||
case 401: | ||
errorMessage = 'Got 403 response. Only staff can save gradings.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here (should be '403'). Also, can you help me change this line to case 401
?
Anyways I think this case clause can be omitted. Anyone using the site properly would be a staff by the point they reach here, so it doesn't make sense to remind them that only a staff can save gradings. This should fall in the default clause of 'oops we don't know what happened, here's the error code, go open an issue please'.
src/sagas/backend.ts
Outdated
refreshToken: tokens.refreshToken, | ||
shouldRefresh: true | ||
}) | ||
if (response && response.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (response)
is sufficient. Non-null response implies response.ok
. Reference.
src/sagas/backend.ts
Outdated
refreshToken: tokens.refreshToken, | ||
shouldRefresh: true | ||
}) | ||
if (response && response.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (response)
@@ -0,0 +1,15 @@ | |||
import { ExternalLibraryName, Library } from '../components/assessment/assessmentShape' | |||
|
|||
export const castLibrary = (lib: any): Library => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to document differences in frontend and backend data, like here.
There was a problem with typing, as the input as a number was stored. I've stored the input as a string, and parse it whenever this data leaves the component (submission) |
And a helper file castBackend.ts to help cast thigs like the Library
It does not need to be stored in the state anymore
this is undefined in the constructor for some reason, but props can be used directly from paramters.
Param names, and using null
src/sagas/backend.ts
Outdated
refreshToken: state.session.refreshToken | ||
})) | ||
const resp = yield postGrading(submissionId, questionId, grade, comment, adjustment, tokens) | ||
if (resp !== null && resp.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use resp && resp.ok
for consistency
src/sagas/backend.ts
Outdated
let errorMessage: string | ||
switch (resp.status) { | ||
case 400: | ||
errorMessage = 'Invalid or missing parameter(s) or submission and/or question not found' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These error messages are for the end user. If they're not providing useful end-user-type information I think just let them be caught in the default case.
src/sagas/backend.ts
Outdated
errorMessage = 'Invalid or missing parameter(s) or submission and/or question not found' | ||
break | ||
case 403: | ||
errorMessage = 'Got 403 response. Only staff can save gradings.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check role before sending the POST instead of based on the POST response (see SUBMIT_ANSWER)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but I think it's good to note that in a normal case the student would not be able to reach the UI to submit the grading anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the codes to match the new ones too
Bumps [distillery](https://github.com/bitwalker/distillery) from 2.0.3 to 2.0.4. - [Release notes](https://github.com/bitwalker/distillery/releases) - [Changelog](https://github.com/bitwalker/distillery/blob/master/docs/changelog.md) - [Commits](bitwalker/distillery@2.0.3...2.0.4) Signed-off-by: dependabot[bot] <support@dependabot.com>
Awaiting source-academy/backend#167.
Features
graded
option (to be added once backend endpoint is available)TODO