Skip to content
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

Teacher Feedback: Don't load tab until we have all the content from network #27900

Merged
merged 6 commits into from Apr 9, 2019

Conversation

dmcavoy
Copy link
Contributor

@dmcavoy dmcavoy commented Apr 5, 2019

There was a bug in an eyes test that drove this investigation which led to some larger refactoring of the network requests for TeacherFeedback content.

Background

The bug in the eyes test was that when the student was viewing feedback from a teacher with a rubric the rubric would be expanded by default (which is not supposed to happen). We tracked this down to being the result of when we initially rendered the TeacherFeedback tab in this instance the network hadn't gotten back the student's feedback data so it would initially render as a Key Concept tab and then re-render to the Feedback tab but never reset the state which controls if the details tag start open.

Screen Shot 2019-04-03 at 1 31 29 PM

Fix

Dave helped me work to determine that the best way to fix this was probably to wait on rendering the TeacherFeedback component until we have all the network requests in TopInstructions. I updated this but then felt like we should also move the network requests out of TeacherFeedback (specifically the one where it gets the feedback when a Teacher is viewing a student's work) so that in all cases we are waiting to render until we have the data.

This does fix the initial bug from above (see below):

Screen Shot 2019-04-05 at 12 45 12 PM

And I tested that all the cases in and out of experiment remain consistent.

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

Looks great, Dani! Consolidating the networks requests was a great call. I know it seems like a lot of work for a little tooltip... but in the bigger picture I think this is a good example of when a small change tips the scales and makes it time to do a larger refactoring that will have the added benefit of making other future changes easier too. Thank you for your perseverance in working toward a great solution on this!

if (this.state.teacherViewingStudentWork) {
promises.push(
$.ajax({
url: `/api/v1/teacher_feedbacks/get_feedback_from_teacher?student_id=${studentId}&level_id=${serverLevelId}&teacher_id=${user}`,
Copy link
Member

Choose a reason for hiding this comment

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

nice lift! it is always great to see these network requests getting moved farther up the rendering chain. and since moving them all the way up and out of react sounds like a headache, consolidating them into this one location seems like an excellent alternative.

@@ -109,57 +111,30 @@ export class TeacherFeedback extends Component {
this.onRubricChange = this.onRubricChange.bind(this);

this.state = {
comment: '',
performance: null,
comment:
Copy link
Contributor

Choose a reason for hiding this comment

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

mapping a component's props to state like this is usually an anti-pattern in react, but, after reading this blog post, it seems okay to do in this context.

i usually get around this by moving the handlers that change state for these props into the parent like this:

class Parent extends React.Component {
  state = {
    comment: ''
  }

  onChangeComment = (event) => {
    this.setState({comment: event.target.value});
  }

  render() {
    return <Child comment={this.state.comment} onChangeComment={this.onChangeComment} />;
  }
}

class Child extends React.Component {
  render() {
    return (
      <input value={this.props.comment} onChange={this.props.onChangeComment} />
    );
  }
}

then, the parent component fully controls the state and the child is basically just rendering and calling methods that control state on the parent

@dmcavoy dmcavoy merged commit 2647fb3 into staging Apr 9, 2019
@dmcavoy dmcavoy deleted the student-expand-bug branch April 9, 2019 14:07
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.

None yet

3 participants