当前位置: 首页>>代码示例>>Python>>正文


Python UserQuestionnaireService.answer_version方法代码示例

本文整理汇总了Python中questionnaire.services.users.UserQuestionnaireService.answer_version方法的典型用法代码示例。如果您正苦于以下问题:Python UserQuestionnaireService.answer_version方法的具体用法?Python UserQuestionnaireService.answer_version怎么用?Python UserQuestionnaireService.answer_version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在questionnaire.services.users.UserQuestionnaireService的用法示例。


在下文中一共展示了UserQuestionnaireService.answer_version方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_user_knows_answer_version_of_questionnaire_is_the_same_as_draft_if_draft_exists

# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import answer_version [as 别名]
    def test_user_knows_answer_version_of_questionnaire_is_the_same_as_draft_if_draft_exists(self):
        data = self.data

        old_primary = MultiChoiceAnswer.objects.create(response=self.option1, question=self.question1, **self.initial)
        old_answer_1 = NumericalAnswer.objects.create(response=int(data['Number-0-response']), question=self.question2, **self.initial)
        old_answer_2 = NumericalAnswer.objects.create(response=int(data['Number-1-response']), question=self.question3, **self.initial)

        answer_group = AnswerGroup.objects.create(grouped_question=self.question_group)
        answer_group.answer.add(old_primary, old_answer_1, old_answer_2)

        user_service = UserQuestionnaireService(self.user, self.questionnaire)
        self.assertEqual(self.initial['version'], user_service.answer_version())
开发者ID:testvidya11,项目名称:ejrf,代码行数:14,代码来源:test_users_service.py

示例2: test_user_knows_answer_version_of_questionnaire_is_plus_1_of_the_latest_submitted_answers

# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import answer_version [as 别名]
    def test_user_knows_answer_version_of_questionnaire_is_plus_1_of_the_latest_submitted_answers(self):
        data = self.data.copy()

        old_primary = MultiChoiceAnswer.objects.create(response=self.option1, question=self.question1, **self.initial)
        old_answer_1 = NumericalAnswer.objects.create(response=int(data['Number-0-response']), question=self.question2, **self.initial)
        old_answer_2 = NumericalAnswer.objects.create(response=int(data['Number-1-response']), question=self.question3, **self.initial)

        answer_group = AnswerGroup.objects.create(grouped_question=self.question_group)
        answer_group.answer.add(old_primary, old_answer_1, old_answer_2)

        user_service = UserQuestionnaireService(self.user, self.questionnaire)
        user_service.submit()

        self.assertEqual(self.initial['version']+1, user_service.answer_version())
开发者ID:testvidya11,项目名称:ejrf,代码行数:16,代码来源:test_users_service.py

示例3: post

# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import answer_version [as 别名]
    def post(self, request, *args, **kwargs):
        questionnaire = Questionnaire.objects.get(id=self.kwargs['questionnaire_id'])
        section = Section.objects.get(id=self.kwargs['section_id'])
        user_questionnaire_service = UserQuestionnaireService(self.request.user, questionnaire)
        initial = {'country': self.request.user.user_profile.country, 'status': 'Draft',
                   'version': user_questionnaire_service.answer_version()}
        formsets = QuestionnaireEntryFormService(section, initial=initial, data=request.POST)

        context = {'questionnaire': questionnaire, 'section': section,
                   'formsets': formsets, 'ordered_sections': Section.objects.order_by('order')}

        if formsets.is_valid():
            return self._form_valid(request, formsets, user_questionnaire_service, context)
        return self._form_invalid(request, context)
开发者ID:testvidya11,项目名称:ejrf,代码行数:16,代码来源:questionnaires.py

示例4: test_user_knows_answer_version_of_questionnaire_is_1_if_no_answer_exist_yet

# 需要导入模块: from questionnaire.services.users import UserQuestionnaireService [as 别名]
# 或者: from questionnaire.services.users.UserQuestionnaireService import answer_version [as 别名]
 def test_user_knows_answer_version_of_questionnaire_is_1_if_no_answer_exist_yet(self):
     user_service = UserQuestionnaireService(self.user, self.questionnaire)
     self.assertEqual(1, user_service.answer_version())
     self.assertEqual(1, user_service.POST_version)
     self.assertEqual(1, user_service.GET_version)
开发者ID:remo4sam,项目名称:ejrf,代码行数:7,代码来源:test_users_service.py


注:本文中的questionnaire.services.users.UserQuestionnaireService.answer_version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。