예제 #1
0
    def _get_exploration_data(
            self, exploration_id, apply_draft=False, version=None):
        """Returns a description of the given exploration."""
        try:
            if apply_draft:
                exploration = exp_services.get_exp_with_draft_applied(
                    exploration_id, self.user_id)
            else:
                exploration = exp_services.get_exploration_by_id(
                    exploration_id, version=version)
        except:
            raise self.PageNotFoundException

        states = {}
        for state_name in exploration.states:
            state_dict = exploration.states[state_name].to_dict()
            states[state_name] = state_dict
        exp_user_data = user_models.ExplorationUserDataModel.get(
            self.user_id, exploration_id)
        draft_changes = (exp_user_data.draft_change_list if exp_user_data
                         and exp_user_data.draft_change_list else None)
        is_version_of_draft_valid = (
            exp_services.is_version_of_draft_valid(
                exploration_id, exp_user_data.draft_change_list_exp_version)
            if exp_user_data and exp_user_data.draft_change_list_exp_version
            else None)
        draft_change_list_id = (exp_user_data.draft_change_list_id
                                if exp_user_data else 0)
        exploration_email_preferences = (
            user_services.get_email_preferences_for_exploration(
                self.user_id, exploration_id))
        editor_dict = {
            'auto_tts_enabled': exploration.auto_tts_enabled,
            'category': exploration.category,
            'correctness_feedback_enabled': (
                exploration.correctness_feedback_enabled),
            'draft_change_list_id': draft_change_list_id,
            'exploration_id': exploration_id,
            'init_state_name': exploration.init_state_name,
            'language_code': exploration.language_code,
            'objective': exploration.objective,
            'param_changes': exploration.param_change_dicts,
            'param_specs': exploration.param_specs_dict,
            'rights': rights_manager.get_exploration_rights(
                exploration_id).to_dict(),
            'show_state_editor_tutorial_on_load': (
                self.user_id and not self.has_seen_editor_tutorial),
            'states': states,
            'tags': exploration.tags,
            'title': exploration.title,
            'version': exploration.version,
            'is_version_of_draft_valid': is_version_of_draft_valid,
            'draft_changes': draft_changes,
            'email_preferences': exploration_email_preferences.to_dict()
        }

        return editor_dict
예제 #2
0
파일: editor.py 프로젝트: DSeanLaw/oppia
    def _get_exploration_data(
            self, exploration_id, apply_draft=False, version=None):
        """Returns a description of the given exploration."""
        try:
            if apply_draft:
                exploration = exp_services.get_exp_with_draft_applied(
                    exploration_id, self.user_id)
            else:
                exploration = exp_services.get_exploration_by_id(
                    exploration_id, version=version)
        except:
            raise self.PageNotFoundException

        states = {}
        for state_name in exploration.states:
            state_dict = exploration.states[state_name].to_dict()
            states[state_name] = state_dict
        exp_user_data = user_models.ExplorationUserDataModel.get(
            self.user_id, exploration_id)
        draft_changes = (exp_user_data.draft_change_list if exp_user_data
                         and exp_user_data.draft_change_list else None)
        is_version_of_draft_valid = (
            exp_services.is_version_of_draft_valid(
                exploration_id, exp_user_data.draft_change_list_exp_version)
            if exp_user_data and exp_user_data.draft_change_list_exp_version
            else None)
        exploration_email_preferences = (
            user_services.get_email_preferences_for_exploration(
                self.user_id, exploration_id))
        editor_dict = {
            'category': exploration.category,
            'exploration_id': exploration_id,
            'init_state_name': exploration.init_state_name,
            'language_code': exploration.language_code,
            'objective': exploration.objective,
            'param_changes': exploration.param_change_dicts,
            'param_specs': exploration.param_specs_dict,
            'rights': rights_manager.get_exploration_rights(
                exploration_id).to_dict(),
            'show_state_editor_tutorial_on_load': (
                self.user_id and not self.has_seen_editor_tutorial),
            'skin_customizations': exploration.skin_instance.to_dict()[
                'skin_customizations'],
            'states': states,
            'tags': exploration.tags,
            'title': exploration.title,
            'version': exploration.version,
            'is_version_of_draft_valid': is_version_of_draft_valid,
            'draft_changes': draft_changes,
            'email_preferences': exploration_email_preferences.to_dict()
        }

        return editor_dict
예제 #3
0
    def _get_exploration_data(
            self, exploration_id, apply_draft=False, version=None):
        """Returns a description of the given exploration."""
        try:
            if apply_draft:
                exploration = exp_services.get_exp_with_draft_applied(
                    exploration_id, self.user_id)
            else:
                exploration = exp_services.get_exploration_by_id(
                    exploration_id, version=version)
        except:
            raise self.PageNotFoundException

        states = {}
        for state_name in exploration.states:
            state_dict = exploration.states[state_name].to_dict()
            state_dict['unresolved_answers'] = (
                stats_services.get_top_unresolved_answers_for_default_rule(
                    exploration_id, state_name))
            states[state_name] = state_dict
        exp_user_data = user_models.ExplorationUserDataModel.get(
            self.user_id, exploration_id)
        draft_changes = (exp_user_data.draft_change_list if exp_user_data
                         and exp_user_data.draft_change_list else None)
        is_version_of_draft_valid = (
            exp_services.is_version_of_draft_valid(
                exploration_id, exp_user_data.draft_change_list_exp_version)
            if exp_user_data and exp_user_data.draft_change_list_exp_version
            else None)
        editor_dict = {
            'category': exploration.category,
            'exploration_id': exploration_id,
            'init_state_name': exploration.init_state_name,
            'language_code': exploration.language_code,
            'objective': exploration.objective,
            'param_changes': exploration.param_change_dicts,
            'param_specs': exploration.param_specs_dict,
            'rights': rights_manager.get_exploration_rights(
                exploration_id).to_dict(),
            'show_state_editor_tutorial_on_load': (
                self.user_id and not self.has_seen_editor_tutorial),
            'skin_customizations': exploration.skin_instance.to_dict()[
                'skin_customizations'],
            'states': states,
            'tags': exploration.tags,
            'title': exploration.title,
            'version': exploration.version,
            'is_version_of_draft_valid': is_version_of_draft_valid,
            'draft_changes': draft_changes
        }

        return editor_dict