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


Python Answer.correct方法代码示例

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


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

示例1: save

# 需要导入模块: from models import Answer [as 别名]
# 或者: from models.Answer import correct [as 别名]
 def save(self, commit=True):
     test = super(TestAdminForm, self).save(False)
     file = self.cleaned_data['file']
     questions_count = self.cleaned_data['questions_count']
     
     if file:
         test_name = test.name
         test.save()
         AnswerResult.objects.filter(answer__question__test=test).delete()
         AnswerChoice.objects.filter(question__test=test).delete()
         TestPass.objects.filter(test=test).delete()
         Answer.objects.filter(question__test=test).delete()
         Question.objects.filter(test=test).delete()
         
         questions = parser(file)
         count = 0
         cur_test = test
         
         for i, question in enumerate(questions):
             count += 1
             q = Question(test=cur_test, question=question['question'])
             if question['text_answer']:
                 q.text_answer = question['text_answer']
                 q.save()
             else:
                 q.save()
                 for answer in question['answers']:
                     a = Answer(question=q)
                     a.answer = answer['text']
                     a.correct = answer['correct']
                     a.save()
             
             if questions_count and count >= questions_count:
                 if (len(questions) - i) >= questions_count:
                     cur_test.name = '%s [%s-%s]' % (test_name, i+1-count, i+1)
                     cur_test.save()                           
                     cur_test = copy(test)
                     cur_test.pk = None
                     cur_test.save()
                 else:
                     cur_test.name = '%s [%s-%s]' % (test_name, i+1-count, len(questions))
                     cur_test.save()
                                                   
                 count = 0
             
     return test
开发者ID:Alerion,项目名称:testing-for-Kate,代码行数:48,代码来源:forms.py


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