<commit_before>React = require 'react'
BS = require 'react-bootstrap'
classnames = require 'classnames'
_ = require 'underscore'

{ExerciseActions, ExerciseStore} = require '../stores/exercise'
Exercise = require './exercise'


ExerciseWrapper = React.createClass

  getInitialState: ->
    {}

  publishExercise: ->
    if confirm('Are you sure you want to publish?')
      ExerciseActions.save(@state.exerciseId)
      ExerciseActions.publish(@state.exerciseId)

  addNew: ->
    id = ExerciseStore.freshLocalId()
    template = ExerciseStore.getTemplate()
    ExerciseActions.loaded(template, id)
    @setState({exerciseId: id })
<commit_msg>Load exercise id if it's in url<commit_after>React = require 'react'
BS = require 'react-bootstrap'
classnames = require 'classnames'
_ = require 'underscore'

{ExerciseActions, ExerciseStore} = require '../stores/exercise'
Exercise = require './exercise'


ExerciseWrapper = React.createClass

  getInitialState: ->
    {}

  componentDidMount: ->
    if @props.exerciseId
      this.refs.exerciseId.getDOMNode().value = @props.exerciseId
      @loadExercise()

  publishExercise: ->
    if confirm('Are you sure you want to publish?')
      ExerciseActions.save(@state.exerciseId)
      ExerciseActions.publish(@state.exerciseId)

  addNew: ->
    id = ExerciseStore.freshLocalId()
    template = ExerciseStore.getTemplate()
    ExerciseActions.loaded(template, id)
    @setState({exerciseId: id })

{'fraction_non_alphanumeric': 0.11894882434301521, 'fraction_numerical': 0.0, 'mean_word_length': 4.077192982456141, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '3936134', 'n_tokens_mistral': 450, 'n_tokens_neox': 419, 'n_words': 94}