<commit_before>import React from 'react';
import LoadingSpinner from '../../shared/loading_indicator.jsx';
import _ from 'underscore';
import { requestGet, requestPost } from '../../../../../modules/request';
import Pusher from 'pusher-js';
import RecommendationsTableCell from './recommendations_table_cell';
import LessonsRecommendations from './lessons_recommendations';
import RecommendationOverview from './recommendation_overview';

export default class Recommendations extends React.Component {

  constructor(props) {
    super(props)

    this.state = {
      loading: true,
      recommendations: [],
      previouslyAssignedRecommendations: [],
      previouslyAssignedLessonsRecommendations: [],
      lessonsRecommendations: [],
      selections: [],
      students: [],
      assigning: false,
      assigned: false,
    }
  }

  componentDidMount() {
    const { params, } = this.props
    this.getRecommendationData(params.classroomId, params.activityId);
    this.getPreviouslyAssignedRecommendationData(params.classroomId, params.activityId, false);
    this.assignToWholeClass(params.unitTemplateId);
  }

  componentWillReceiveProps(nextProps) {
    this.setState({
      loading: true,
      assigning: false,
      assigned: false,
    });
    this.getRecommendationData(nextProps.params.classroomId, nextProps.params.activityId);
    this.getPreviouslyAssignedRecommendationData(nextProps.params.classroomId, nextProps.params.activityId, false);
    this.assignToWholeClass(nextProps.params.unitTemplateId);
  }

  setAssignedToFalseAfterFiveSeconds = () => {
    setTimeout(() => this.setState({ assigned: false, }), 5000);
  }

  getRecommendationData = (classroomId, activityId) => {
    const { params, } = this.props
    const that = this;
    requestGet(`/teachers/progress_reports/recommendations_for_classroom/${params.unitId}/${classroomId}/activity/${activityId}`, (data) => {
      that.setState({
        recommendations: JSON.parse(JSON.stringify(data.recommendations)),
        students: data.students,
        loading: false,
      }, that.getPreviouslyAssignedRecommendationData(classroomId, activityId, false));
    });
    requestGet(`/teachers/progress_reports/lesson_recommendations_for_classroom/u/${params.unitId}/c/${classroomId}/a/${activityId}`, (data) => {
      that.setState({ lessonsRecommendations: data.lessonsRecommendations, });
    });
  }

  getPreviouslyAssignedRecommendationData = (classroomId, activityId, assigned) => {
    const that = this;
    requestGet(`/teachers/progress_reports/previously_assigned_recommendations/${classroomId}/activity/${activityId}`, ((data) => {
      that.setState({
        previouslyAssignedRecommendations: data.previouslyAssignedRecommendations,
        previouslyAssignedLessonsRecommendations: data.previouslyAssignedLessonsRecommendations,
      }, that.setSelections(assigned, data.previouslyAssignedLessonsRecommendations));
    }));
  }<commit_msg>remove unneeded lines<commit_after>import React from 'react';
import LoadingSpinner from '../../shared/loading_indicator.jsx';
import _ from 'underscore';
import { requestGet, requestPost } from '../../../../../modules/request';
import Pusher from 'pusher-js';
import RecommendationsTableCell from './recommendations_table_cell';
import LessonsRecommendations from './lessons_recommendations';
import RecommendationOverview from './recommendation_overview';

export default class Recommendations extends React.Component {

  constructor(props) {
    super(props)

    this.state = {
      loading: true,
      recommendations: [],
      previouslyAssignedRecommendations: [],
      previouslyAssignedLessonsRecommendations: [],
      lessonsRecommendations: [],
      selections: [],
      students: [],
      assigning: false,
      assigned: false,
    }
  }

  componentDidMount() {
    const { params, } = this.props
    this.getRecommendationData(params.classroomId, params.activityId);
    this.getPreviouslyAssignedRecommendationData(params.classroomId, params.activityId, false);
  }

  componentWillReceiveProps(nextProps) {
    this.setState({
      loading: true,
      assigning: false,
      assigned: false,
    });
    this.getRecommendationData(nextProps.params.classroomId, nextProps.params.activityId);
    this.getPreviouslyAssignedRecommendationData(nextProps.params.classroomId, nextProps.params.activityId, false);
  }

  setAssignedToFalseAfterFiveSeconds = () => {
    setTimeout(() => this.setState({ assigned: false, }), 5000);
  }

  getRecommendationData = (classroomId, activityId) => {
    const { params, } = this.props
    const that = this;
    requestGet(`/teachers/progress_reports/recommendations_for_classroom/${params.unitId}/${classroomId}/activity/${activityId}`, (data) => {
      that.setState({
        recommendations: JSON.parse(JSON.stringify(data.recommendations)),
        students: data.students,
        loading: false,
      }, that.getPreviouslyAssignedRecommendationData(classroomId, activityId, false));
    });
    requestGet(`/teachers/progress_reports/lesson_recommendations_for_classroom/u/${params.unitId}/c/${classroomId}/a/${activityId}`, (data) => {
      that.setState({ lessonsRecommendations: data.lessonsRecommendations, });
    });
  }

  getPreviouslyAssignedRecommendationData = (classroomId, activityId, assigned) => {
    const that = this;
    requestGet(`/teachers/progress_reports/previously_assigned_recommendations/${classroomId}/activity/${activityId}`, ((data) => {
      that.setState({
        previouslyAssignedRecommendations: data.previouslyAssignedRecommendations,
        previouslyAssignedLessonsRecommendations: data.previouslyAssignedLessonsRecommendations,
      }, that.setSelections(assigned, data.previouslyAssignedLessonsRecommendations));
    }));
  }
{'fraction_non_alphanumeric': 0.12232574189095928, 'fraction_numerical': 0.0013802622498274672, 'mean_word_length': 4.468867924528302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5049745', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1663, 'n_words': 250}