Skip to content

Conversation

@remo5000
Copy link
Contributor

@remo5000 remo5000 commented Jul 5, 2018

Features

  • Rich-text markdown editor to add comments
  • Slice of state within WorkspaceManager for storing gradingComments
  • Comments updated when component unmounts, as compared to updating on change. This is because
    • The editor requires a local state, so it is simpler to set the local state in the constructor, using StateProps, and update the store when unmounting using a dispatch
    • Comments do not require evaluation. The button to save the comments (and update XP) will be implemented by reading local state, which already has the updated text in it.

TODO

  • number input for XP
  • button to submit comments and XP

@coveralls
Copy link

coveralls commented Jul 5, 2018

Pull Request Test Coverage Report for Build 210

  • 33 of 79 (41.77%) changed or added relevant lines in 12 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.007%) to 31.519%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sagas/index.ts 1 2 50.0%
src/components/assessment/index.tsx 1 2 50.0%
src/components/academy/grading/GradingNavLink.tsx 3 5 60.0%
src/actions/workspaces.ts 4 6 66.67%
src/containers/academy/grading/GradingEditorContainer.ts 7 9 77.78%
src/reducers/workspaces.ts 0 3 0.0%
src/components/academy/grading/index.tsx 1 8 12.5%
src/components/academy/grading/GradingEditor.tsx 8 36 22.22%
Totals Coverage Status
Change from base Build 208: -0.007%
Covered Lines: 1237
Relevant Lines: 3445

💛 - Coveralls

export const UPDATE_CURRENT_SUBMISSION_ID = 'UPDATE_CURRENT_SUBMISSION_ID'
export const UPDATE_GRADING_COMMENTS_VALUE = 'UPDATE_GRADING_COMMENTS_VALUE'
export const UPDATE_GRADING_XP = 'UPDATE_GRADING_XP'
export const SAVE_GRADING_INPUT = 'SAVE_GRADING_INPUT'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I change this to UPLOAD_GRADING_INPUT instead? It's only use is to call a saga.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think save is fine


constructor(props: GradingEditorProps) {
super(props)
this.state = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local state is used to keep track of everything here, because the editor already uses it. Upon unmounting, the values are dispatched.

public componentWillMount() {
const assessmentId = stringParamToInt(this.props.match.params.assessmentId)
const questionId = stringParamToInt(this.props.match.params.questionId)
if (assessmentId === null || questionId === null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a bug that applies for Grading but not Assessment. I changed it for consistency.

The original predicate fails when questionid is null but submissionId is non-null (because we have not assigned 0 to it yet). In the case of assessments, the 0 value is provided by the card, since it must provide a value in the link within.

/* word-wrap and word-break are added to make text wrap. */
word-wrap: break-word;
word-break: break-word;
.grading-editor-input-parent {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move this to another file if needed. I didn't because grading editor is present only inside a side-content

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine

export const UPDATE_CURRENT_SUBMISSION_ID = 'UPDATE_CURRENT_SUBMISSION_ID'
export const UPDATE_GRADING_COMMENTS_VALUE = 'UPDATE_GRADING_COMMENTS_VALUE'
export const UPDATE_GRADING_XP = 'UPDATE_GRADING_XP'
export const SAVE_GRADING_INPUT = 'SAVE_GRADING_INPUT'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think save is fine

/* word-wrap and word-break are added to make text wrap. */
word-wrap: break-word;
word-break: break-word;
.grading-editor-input-parent {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine

remo5000 added 27 commits July 6, 2018 12:55
- ~400 stars
- In Typescript
- Vertical layout for the slightly narrow side-content section
- In actual Markdown

Only caveats are that it is not WYSIWYG and does not have a markdown to html converter.
The main library react-mde runs on.
To convert markdown to HTML and vice-versa
I'll remove this to use blueprint icons instead, later on.
Or else, the styles do not work.
Trying to use componentDidMount and componentWillUnmount to handle
updates.
Alphabetisizing, typos.
The `markdown` value in `mdeState` being undefined causes a runtime
error. So it is easier to just deal with a definite string (since
undefined is not allowed anyway). The typedef for the value allows
undefined though.
The problem is that the current <a href> implementation is a hard
redirect, causing a change in URL (and loss of all state). I'm trying to
get a NavLink
Since it will be set by the default state,
it is never null.
Checks only for submissionId, if it is present then there should be a
questionId as well.
Used to reset the workspace as well.
@remo5000 remo5000 force-pushed the grading-comments branch from 714f3a2 to 4d563dd Compare July 6, 2018 04:58
@remo5000 remo5000 mentioned this pull request Jul 6, 2018
@remo5000 remo5000 merged commit 80482b4 into master Jul 6, 2018
@remo5000 remo5000 mentioned this pull request Jul 6, 2018
@ning-y ning-y deleted the grading-comments branch July 17, 2018 11:16
remo5000 added a commit that referenced this pull request Jul 24, 2018
The issue has been created at the backend cadet repo -- #162.
As triple equality was used to verify if the button should be pressed,
this caused all the equality checks to return false (string is not ===
any number). I've added a workaround to parse the received string.
remo5000 added a commit that referenced this pull request Jul 24, 2018
The issue has been created at the backend cadet repo -- #162.
As triple equality was used to verify if the button should be pressed,
this caused all the equality checks to return false (string is not ===
any number). I've added a workaround to parse the received string.
ning-y pushed a commit that referenced this pull request Jul 25, 2018
* Add handleOptionSelect handler for MCQChooser

* Use handleOptionSelect in Button

Had to use a curried function to get around the "Lambdas forbidden in
rendering method" rule (and consequently save performance)

* Use handleMCQSubmit name instead

* Change mcq question prop -> mcqProps

Thus, anything that calls workspace will have to provide a method to
handle MCQs, if the question is an MCQ question

* Pass correct props for GradingWorkspace

* Use correct props for AssessmentWorkspace

* Remove unused import from workspace

* Format AssessmentWorkspace

* Add localState to remove visual lag of choosing

Before: Option chosen (active momentarily) -> dispatch (button inactive
due to current state) ->
component updated with answer (active)

Now: Constructor takes in current option from state -> Option chosen (active momentarily) -> local state updated (active) and dispatch is sent -> any update from the dispatch will cause constructor to set the state (during render) to the new option

* Pass in chosenOption prop from workspace parents

* Format and update a test

* Add workaround for mcq being passed as string

The issue has been created at the backend cadet repo -- #162.
As triple equality was used to verify if the button should be pressed,
this caused all the equality checks to return false (string is not ===
any number). I've added a workaround to parse the received string.

* Move parsing to the backend saga

* Format files

* Make resetWorkspace accept arguments to set values

* Export IWorkspaceState

* Change reducer for RESET_WORKSPACE

* Modify workspace parent containers

* Modify component handler definitions

* Use handleResetWorkspace to set editorValue

* Dont show save button for mcq question

* Format files

* Remove parsing

* Simplify chosenMCQAnswer expression

* Remove chosenMCQAnswer

I did not realise that this can just be used from the IMCQQuestion
passed in.

* Add mock call for SUBMIT_ANSWER

* Format files
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.

4 participants