<commit_before>_ = require 'underscore'
flux = require 'flux-react'
{CrudConfig, makeSimpleStore, extendConfig} = require './helpers'
{AnswerActions, AnswerStore} = require './answer'

QuestionConfig = {
  _loaded: (obj, id) ->
    for answer in obj?.answers
      AnswerActions.loaded(answer, answer.id)

    obj

  sync: (id) ->
    answers = _.map @_local[id]?.answers, (answer) ->
      AnswerStore.get(answer.id)
    @_change(id, {answers})
    
  addNewAnswer: (id) ->
    newAnswer =<commit_msg>sorting answers by id in edit view<commit_after>_ = require 'underscore'
flux = require 'flux-react'
{CrudConfig, makeSimpleStore, extendConfig} = require './helpers'
{AnswerActions, AnswerStore} = require './answer'

QuestionConfig = {
  _loaded: (obj, id) ->
    obj.answers = _.sortBy obj?.answers, (answer) ->
      parseInt(answer.id)

    for answer in obj?.answers
      AnswerActions.loaded(answer, answer.id)

    obj

  sync: (id) ->
    answers = _.map @_local[id]?.answers, (answer) ->
      AnswerStore.get(answer.id)
    @_change(id, {answers})
    
  addNewAnswer: (id) ->
    newAnswer =
{'fraction_non_alphanumeric': 0.14751131221719457, 'fraction_numerical': 0.0, 'mean_word_length': 3.388888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '487634', 'n_tokens_mistral': 390, 'n_tokens_neox': 369, 'n_words': 87}