Skip to content

Conversation

remo5000
Copy link
Contributor

@remo5000 remo5000 commented Jul 26, 2018

Awaiting source-academy/backend#167.

Features

  • Add sagas to fetch Grading from backend
  • Use XP instead of grade
  • Remove graded option (to be added once backend endpoint is available)

TODO

  • Add GradingOverview calls and type changes
  • Add Grading calls and type changes
  • Test with an updated staging server
    • Adjustments in grading overview (awating backend)
    • Assessment name and category

@coveralls
Copy link

coveralls commented Jul 26, 2018

Pull Request Test Coverage Report for Build 527

  • 14 of 93 (15.05%) changed or added relevant lines in 8 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.7%) to 24.799%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/actions/session.ts 1 2 50.0%
src/reducers/workspaces.ts 0 1 0.0%
src/utils/castBackend.ts 1 4 25.0%
src/mocks/backend.ts 1 10 10.0%
src/components/academy/grading/GradingEditor.tsx 4 16 25.0%
src/sagas/backend.ts 2 55 3.64%
Files with Coverage Reduction New Missed Lines %
src/reducers/workspaces.ts 1 7.94%
src/components/academy/grading/GradingEditor.tsx 2 14.1%
Totals Coverage Status
Change from base Build 515: -0.7%
Covered Lines: 806
Relevant Lines: 2766

💛 - Coveralls

@remo5000 remo5000 changed the title [WIP] Add Grading API calls Add Grading API calls Jul 27, 2018
@ning-y
Copy link
Member

ning-y commented Jul 29, 2018

@remo5000 You gotta rebase off #240 before you use API call in ./src/sagas/backend.ts because the function request has been changed completely in that PR.

@remo5000
Copy link
Contributor Author

@ningyuansg will do

g: number,
s: string,
i: number | undefined
) => void
Copy link
Member

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
Copy link
Member

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 => ({})
Copy link
Member

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.

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.'
Copy link
Member

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'.

refreshToken: tokens.refreshToken,
shouldRefresh: true
})
if (response && response.ok) {
Copy link
Member

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.

refreshToken: tokens.refreshToken,
shouldRefresh: true
})
if (response && response.ok) {
Copy link
Member

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 => ({
Copy link
Member

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.

@ning-y ning-y added the waiting label Jul 31, 2018
@remo5000 remo5000 removed the waiting label Aug 2, 2018
@remo5000
Copy link
Contributor Author

remo5000 commented Aug 2, 2018

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)

refreshToken: state.session.refreshToken
}))
const resp = yield postGrading(submissionId, questionId, grade, comment, adjustment, tokens)
if (resp !== null && resp.ok) {
Copy link
Member

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

let errorMessage: string
switch (resp.status) {
case 400:
errorMessage = 'Invalid or missing parameter(s) or submission and/or question not found'
Copy link
Member

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.

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.'
Copy link
Member

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)

Copy link
Contributor Author

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

Copy link
Contributor Author

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

@ning-y ning-y merged commit d27e7b9 into master Aug 3, 2018
@ning-y ning-y deleted the grading-api branch August 3, 2018 10:30
Aulud pushed a commit to Aulud/cadet-frontend that referenced this pull request May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants