|
@@ -66,14 +66,17 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
with transaction.atomic():
|
|
|
cur_question = None
|
|
|
for row in data:
|
|
|
- title = row['试题内容']
|
|
|
- subject = row['科目']
|
|
|
- chapter = row['章节']
|
|
|
- difficulty_text = row['难度']
|
|
|
- scores= row['分数']
|
|
|
- analysis = row['解析']
|
|
|
- content = row['选项']
|
|
|
- right = row['正确答案']
|
|
|
+ try:
|
|
|
+ title = row['试题内容']
|
|
|
+ subject = row['科目']
|
|
|
+ chapter = row['章节']
|
|
|
+ difficulty_text = row['难度']
|
|
|
+ scores= row['分数']
|
|
|
+ analysis = row['解析']
|
|
|
+ content = row['选项']
|
|
|
+ right = row['正确答案']
|
|
|
+ except:
|
|
|
+ raise CustomError(u'模版文件不正确,请检查模版文件或重新下载')
|
|
|
|
|
|
if title and content:
|
|
|
raise CustomError(u'第%d行:数据格式不正确' % line)
|
|
@@ -118,6 +121,8 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
create_time=timezone.now()
|
|
|
)
|
|
|
question_count += 1
|
|
|
+ if not title and not cur_question:
|
|
|
+ raise CustomError(u'第%d行:试题内容不能为空' % line)
|
|
|
if content and not title:
|
|
|
if not cur_question:
|
|
|
continue
|
|
@@ -149,14 +154,17 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
with transaction.atomic():
|
|
|
cur_question = None
|
|
|
for row in data:
|
|
|
- title = row['试题内容']
|
|
|
- subject = row['科目']
|
|
|
- chapter = row['章节']
|
|
|
- difficulty_text = row['难度']
|
|
|
- scores = row['分数']
|
|
|
- analysis = row['解析']
|
|
|
- content = row['选项']
|
|
|
- right = row['正确答案']
|
|
|
+ try:
|
|
|
+ title = row['试题内容']
|
|
|
+ subject = row['科目']
|
|
|
+ chapter = row['章节']
|
|
|
+ difficulty_text = row['难度']
|
|
|
+ scores = row['分数']
|
|
|
+ analysis = row['解析']
|
|
|
+ content = row['选项']
|
|
|
+ right = row['正确答案']
|
|
|
+ except:
|
|
|
+ raise CustomError(u'模版文件不正确,请检查模版文件或重新下载')
|
|
|
|
|
|
if title and content:
|
|
|
raise CustomError(u'第%d行:数据格式不正确' % line)
|
|
@@ -201,6 +209,8 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
create_time=timezone.now()
|
|
|
)
|
|
|
question_count += 1
|
|
|
+ if not title and not cur_question:
|
|
|
+ raise CustomError(u'第%d行:试题内容不能为空' % line)
|
|
|
if content and not title:
|
|
|
if not cur_question:
|
|
|
continue
|
|
@@ -233,13 +243,16 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
cur_question = None
|
|
|
order = 0
|
|
|
for row in data:
|
|
|
- title = row['试题内容']
|
|
|
- subject = row['科目']
|
|
|
- chapter = row['章节']
|
|
|
- difficulty_text = row['难度']
|
|
|
- scores = row['分数']
|
|
|
- analysis = row['解析']
|
|
|
- content = row['答案']
|
|
|
+ try:
|
|
|
+ title = row['试题内容']
|
|
|
+ subject = row['科目']
|
|
|
+ chapter = row['章节']
|
|
|
+ difficulty_text = row['难度']
|
|
|
+ scores = row['分数']
|
|
|
+ analysis = row['解析']
|
|
|
+ content = row['答案']
|
|
|
+ except:
|
|
|
+ raise CustomError(u'模版文件不正确,请检查模版文件或重新下载')
|
|
|
|
|
|
if title and not content:
|
|
|
raise CustomError(u'第%d行:答案不能为空' % line)
|
|
@@ -287,6 +300,8 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
ExamQuestionFill.objects.create(main=cur_question, content=content, order=order)
|
|
|
question_count += 1
|
|
|
order += 1
|
|
|
+ if not title and not cur_question:
|
|
|
+ raise CustomError(u'第%d行:试题内容不能为空' % line)
|
|
|
if content and not title:
|
|
|
if (not cur_question) or (not order):
|
|
|
continue
|
|
@@ -314,13 +329,16 @@ class ExamQuestionViewSet(CustomModelViewSet):
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
for row in data:
|
|
|
- title = row['试题内容']
|
|
|
- subject = row['科目']
|
|
|
- chapter = row['章节']
|
|
|
- difficulty_text = row['难度']
|
|
|
- scores = row['分数']
|
|
|
- analysis = row['解析']
|
|
|
- judgment_text = row['答案']
|
|
|
+ try:
|
|
|
+ title = row['试题内容']
|
|
|
+ subject = row['科目']
|
|
|
+ chapter = row['章节']
|
|
|
+ difficulty_text = row['难度']
|
|
|
+ scores = row['分数']
|
|
|
+ analysis = row['解析']
|
|
|
+ judgment_text = row['答案']
|
|
|
+ except:
|
|
|
+ raise CustomError(u'模版文件不正确,请检查模版文件或重新下载')
|
|
|
|
|
|
if not title:
|
|
|
raise CustomError(u'第%d行:试题内容不能为空' % line)
|