コード例 #1
0
    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(),
        }
コード例 #2
0
ファイル: editor.py プロジェクト: sunu/oh-missions-oppia-beta
    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(),
        }
コード例 #3
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', 1, 'sid', self.SUBMIT_HANDLER, self.DEFAULT_RULESPEC, 'a1')
        self.assertEquals(
            stats_services.get_unresolved_answers_for_default_rule(
                'eid', 'sid'), {'a1': 1})

        stats_services.EventHandler.record_answer_submitted(
            'eid', 1, 'sid', self.SUBMIT_HANDLER, self.DEFAULT_RULESPEC, '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'), {})
コード例 #4
0
ファイル: stats_services_test.py プロジェクト: aldeka/oppia
    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'), {})