<commit_before>import React           from 'react';
import _               from 'lodash';
import AssessmentItems from './assessment_items';
import NewItem         from './new_item_form';
import AddQuestion     from './add_question_button';

export default class AssessmentForm extends React.Component {
  static propTypes = {
    items: React.PropTypes.oneOfType(
      [React.PropTypes.shape({}), React.PropTypes.arrayOf(React.PropTypes.shape({}))]
    ),
    name: React.PropTypes.string,
    updateAssessment: React.PropTypes.func.isRequired,
    updateItemOrder: React.PropTypes.func.isRequired,
    publishedAndOffered: React.PropTypes.bool.isRequired,
    createItem: React.PropTypes.func,
    updateItem: React.PropTypes.func.isRequired,
    updateSingleItemOrPage: React.PropTypes.func.isRequired,
    updateChoice: React.PropTypes.func.isRequired,
    deleteAssessmentItem: React.PropTypes.func,
  };

  constructor() {
    super();
    this.state = {
      addingItem: false,
      activeItem: '',
      reorderActive: false,
      title: 'start'
    };
  }<commit_msg>Sets a new item to be active (#239)<commit_after>import React           from 'react';
import _               from 'lodash';
import AssessmentItems from './assessment_items';
import NewItem         from './new_item_form';
import AddQuestion     from './add_question_button';

export default class AssessmentForm extends React.Component {
  static propTypes = {
    items: React.PropTypes.oneOfType(
      [React.PropTypes.shape({}), React.PropTypes.arrayOf(React.PropTypes.shape({}))]
    ),
    name: React.PropTypes.string,
    updateAssessment: React.PropTypes.func.isRequired,
    updateItemOrder: React.PropTypes.func.isRequired,
    publishedAndOffered: React.PropTypes.bool.isRequired,
    createItem: React.PropTypes.func,
    updateItem: React.PropTypes.func.isRequired,
    updateSingleItemOrPage: React.PropTypes.func.isRequired,
    updateChoice: React.PropTypes.func.isRequired,
    deleteAssessmentItem: React.PropTypes.func,
  };

  constructor() {
    super();
    this.state = {
      addingItem: false,
      activeItem: '',
      reorderActive: false,
      title: 'start'
    };
  }
  componentWillUpdate(nextProps) {
    if (this.props.items && this.props.items.length + 1 === nextProps.items.length) {
      this.setState({ activeItem: _.last(nextProps.items).id });
    }
  }
{'fraction_non_alphanumeric': 0.11616161616161616, 'fraction_numerical': 0.0016835016835016834, 'mean_word_length': 3.4182156133828996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4228289', 'n_tokens_mistral': 707, 'n_tokens_neox': 697, 'n_words': 134}