def _get_exploration_data(self, exploration_id):
        """Returns a description of the given exploration."""
        exploration = exp_services.get_exploration_by_id(exploration_id)

        states = {}
        for state_name in exploration.states:
            state_frontend_dict = exploration.export_state_to_frontend_dict(
                state_name)
            state_frontend_dict['unresolved_answers'] = (
                stats_services.get_unresolved_answers_for_default_rule(
                    exploration_id, state_name))
            states[state_name] = state_frontend_dict

        return {
            'exploration_id': exploration_id,
            'init_state_name': exploration.init_state_name,
            'category': exploration.category,
            'title': exploration.title,
            'states': states,
            'param_changes': exploration.param_change_dicts,
            'param_specs': exploration.param_specs_dict,
            'version': exploration.version,
            'rights': rights_manager.get_exploration_rights(
                exploration_id).to_dict(),
        }
Exemple #2
0
    def test_get_unresolved_answers(self):
        self.assertEquals(
            stats_services.get_unresolved_answers_for_default_rule(
                'eid', 'sid'), {})

        stats_services.EventHandler.record_answer_submitted(
            'eid', 'sid', self.SUBMIT_HANDLER, self.DEFAULT_RULESPEC_STR, 'a1')
        self.assertEquals(
            stats_services.get_unresolved_answers_for_default_rule(
                'eid', 'sid'), {'a1': 1})

        stats_services.EventHandler.record_answer_submitted(
            'eid', 'sid', self.SUBMIT_HANDLER, self.DEFAULT_RULESPEC_STR, 'a1')
        self.assertEquals(
            stats_services.get_unresolved_answers_for_default_rule(
                'eid', 'sid'), {'a1': 2})

        stats_services.EventHandler.resolve_answers_for_default_rule(
            'eid', 'sid', self.SUBMIT_HANDLER, ['a1'])
        self.assertEquals(
            stats_services.get_unresolved_answers_for_default_rule(
                'eid', 'sid'), {})