<commit_before>React = require 'react'
_ = require 'underscore'

Answer = require './answer'
{QuestionActions, QuestionStore} = require '../stores/question'
{AnswerActions, AnswerStore} = require '../stores/answer'

module.exports = React.createClass
  displayName: 'Question'

  getInitialState: -> {}

  changeAnswer: (answerId) ->
    curAnswer = QuestionStore.getCorrectAnswer(@props.id)
    QuestionActions.setCorrectAnswer(@props.id, answerId, curAnswer?.id)

  updateStimulus: (event) -> QuestionActions.updateStimulus(@props.id, event.target?.value)
  updateStem: (event) -> QuestionActions.updateStem(@props.id, event.target?.value)
  updateFeedback: (event) -> QuestionActions.updateFeedback(@props.id, event.target?.value)

  addAnswer:() -> QuestionActions.addNewAnswer(@props.id)
  removeAnswer:(answerId) -> QuestionActions.removeAnswer(@props.id, answerId)

  render: ->
    {id} = @props
    answers = []

    for answer in QuestionStore.getAnswers(id)
      answers.push(<Answer key={answer.id} 
        id={answer.id} 
        removeAnswer={@removeAnswer} changeAnswer={@changeAnswer}/>)

    if QuestionStore.hasFeedback(id)
      feedback = <div>
        <label>Question Feedback</label>
        <textarea onChange={@updateFeedback} defaultValue={QuestionStore.getFeedback(id)}></textarea>
      </div>

    <div>
      <div>
        <label>Question Stem</label>
        <textarea onChange={@updateStem} defaultValue={QuestionStore.getStem(id)}></textarea>
      </div>
      <div>
        <label>Question Stimulus</label>
        <textarea onChange={@updateStimulus} defaultValue={QuestionStore.getStimulus(id)}></textarea>
      </div>
      {feedback}
      <div>
        <label>
          Answers:
        </label>
        <a className="pull-right" onClick={@addAnswer}>Add New</a>
        <ol>
          {answers}
        </ol>
      </div>
    </div>
<commit_msg>update feedback label and fix lint error<commit_after>React = require 'react'
_ = require 'underscore'

Answer = require './answer'
{QuestionActions, QuestionStore} = require '../stores/question'
{AnswerActions, AnswerStore} = require '../stores/answer'

module.exports = React.createClass
  displayName: 'Question'

  getInitialState: -> {}

  changeAnswer: (answerId) ->
    curAnswer = QuestionStore.getCorrectAnswer(@props.id)
    QuestionActions.setCorrectAnswer(@props.id, answerId, curAnswer?.id)

  updateStimulus: (event) -> QuestionActions.updateStimulus(@props.id, event.target?.value)
  updateStem: (event) -> QuestionActions.updateStem(@props.id, event.target?.value)
  updateFeedback: (event) -> QuestionActions.updateFeedback(@props.id, event.target?.value)

  addAnswer: -> QuestionActions.addNewAnswer(@props.id)
  removeAnswer:(answerId) -> QuestionActions.removeAnswer(@props.id, answerId)

  render: ->
    {id} = @props
    answers = []

    for answer in QuestionStore.getAnswers(id)
      answers.push(<Answer key={answer.id} 
        id={answer.id} 
        removeAnswer={@removeAnswer} changeAnswer={@changeAnswer}/>)

    if QuestionStore.hasFeedback(id)
      feedback = <div>
        <label>Detailed Solution</label>
        <textarea onChange={@updateFeedback} defaultValue={QuestionStore.getFeedback(id)}></textarea>
      </div>

    <div>
      <div>
        <label>Question Stem</label>
        <textarea onChange={@updateStem} defaultValue={QuestionStore.getStem(id)}></textarea>
      </div>
      <div>
        <label>Question Stimulus</label>
        <textarea onChange={@updateStimulus} defaultValue={QuestionStore.getStimulus(id)}></textarea>
      </div>
      {feedback}
      <div>
        <label>
          Answers:
        </label>
        <a className="pull-right" onClick={@addAnswer}>Add New</a>
        <ol>
          {answers}
        </ol>
      </div>
    </div>

{'fraction_non_alphanumeric': 0.14672626873520905, 'fraction_numerical': 0.0, 'mean_word_length': 3.397687861271676, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 77, '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': '2618424', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1146, 'n_words': 200}