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


Python Test.test_name方法代码示例

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


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

示例1: create_test_backup

# 需要导入模块: from models import Test [as 别名]
# 或者: from models.Test import test_name [as 别名]
def create_test_backup(request):
    test_obj = json.loads(request.body)
    test = Test()
    #import pdb; pdb.set_trace()
    if request.user.is_authenticated():
        owner = User_Profile.objects.filter(user = request.user)
        test.owner = owner[0]
        test.test_name = test_obj['PRE_TEST']['test_name']
        #test.subject = test_obj['PRE_TEST'].subject
        #test.target_exam = test_obj['PRE_TEST'].target_exam
        #test.topics = test_obj['PRE_TEST'].topics_included
        test.total_time = test_obj['PRE_TEST']['total_time']
        test.pass_criteria = test_obj['PRE_TEST']['pass_criteria']
        test.assoicated_class = Class.objects.get(pk=test_obj['CLASS_INFO'])
        test.save()
        try:
            for item in test_obj['QUESTIONS']:
                question = Question()
                question.question_text = item['question_text']
                question.explanation = item['explanation']
                question.options = json.dumps(item['options'])
                question.hint = item['hint']
                question.difficulty = item['difficulty_level']
                question.points = item['points']
                question.owner = owner[0]
                #question.target_exam = test.target_exam
                #question.subject = test.subject
                #question.topic = item.topic
                question.save()
                test.questions.add(question)
            data = {"status" : "success"}
            return JsonResponse(data)
        except Exception, e:
            raise e
开发者ID:adideshp,项目名称:Tutor,代码行数:36,代码来源:views.py


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