def get_state_rules_stats(exploration_id, state_name):
 exploration = exp_services.get_exploration_by_id(exploration_id)
 state = exploration.states[state_name]
 rule_keys = []
 for group in state.interaction.answer_groups:
  for rule in group.rule_specs:
   rule_keys.append((_OLD_SUBMIT_HANDLER_NAME, rule.stringify_classified_rule()))
 if state.interaction.default_outcome:
  rule_keys.append((_OLD_SUBMIT_HANDLER_NAME, exp_domain.DEFAULT_RULESPEC_STR))
 answer_logs = stats_domain.StateRuleAnswerLog.get_multi(exploration_id, [{'state_name': state_name, 'rule_str': rule_key[1]} for rule_key in rule_keys])
 results = {}
 for (ind, answer_log) in enumerate(answer_logs):
  results['.'.join(rule_keys[ind])] = {'answers': answer_log.get_top_answers(5), 'rule_hits': answer_log.total_answer_count}
 return results

def get_state_rules_stats ( exploration_id , state_name ) : exploration = exp_services . get_exploration_by_id ( exploration_id ) state = exploration . states [ state_name ] rule_keys = [ ] for group in state . interaction . answer_groups : for rule in group . rule_specs : rule_keys . append ( ( _OLD_SUBMIT_HANDLER_NAME , rule . stringify_classified_rule ( ) ) ) if state . interaction . default_outcome : rule_keys . append ( ( _OLD_SUBMIT_HANDLER_NAME , exp_domain . DEFAULT_RULESPEC_STR ) ) answer_logs = stats_domain . StateRuleAnswerLog . get_multi ( exploration_id , [ { 'state_name' : state_name , 'rule_str' : rule_key [ 1 ] } for rule_key in rule_keys ] ) results = { } for ( ind , answer_log ) in enumerate ( answer_logs ) : results [ '.' . join ( rule_keys [ ind ] ) ] = { 'answers' : answer_log . get_top_answers ( 5 ) , 'rule_hits' : answer_log . total_answer_count } return results
gets statistics for the answer groups and rules of this state .