|
@@ -14,6 +14,10 @@ class PractiseLogSerializer(serializers.ModelSerializer):
|
|
|
if obj.end_answer:
|
|
|
now_type = obj.end_answer.question.type
|
|
|
questions = ExamQuestion.objects.filter(type=now_type, delete=False).order_by('id').values_list('id', flat=True)
|
|
|
+ if obj.chapter:
|
|
|
+ questions = questions.filter(chapter=obj.chapter)
|
|
|
+ else:
|
|
|
+ questions = questions.filter(chapter__subject=obj.subject)
|
|
|
now_question_index = list(questions).index(obj.end_answer.question.id)
|
|
|
if now_question_index < (len(questions) -1):
|
|
|
# 该题型未练习完,继续返回该题型下的习题
|
|
@@ -23,6 +27,10 @@ class PractiseLogSerializer(serializers.ModelSerializer):
|
|
|
while now_type <= ExamQuestion.JUDGMENT:
|
|
|
now_type += 1
|
|
|
questions = ExamQuestion.objects.filter(type=now_type, delete=False).order_by('id').first()
|
|
|
+ if obj.chapter:
|
|
|
+ questions = questions.filter(chapter=obj.chapter)
|
|
|
+ else:
|
|
|
+ questions = questions.filter(chapter__subject=obj.subject)
|
|
|
if questions:
|
|
|
next_practise = questions.id
|
|
|
break
|
|
@@ -31,7 +39,7 @@ class PractiseLogSerializer(serializers.ModelSerializer):
|
|
|
def get_end_answer(self, obj):
|
|
|
if obj.end_answer:
|
|
|
now_type = obj.end_answer.question.type
|
|
|
- # todo
|
|
|
+ # todo 按id查
|
|
|
questions = ExamQuestion.objects.filter(type=now_type, delete=False).order_by('id').values_list('id', flat=True)
|
|
|
now_question_index = list(questions).index(obj.end_answer.question.id)
|
|
|
name = '{0}/{1} {2}第{3}题'.format(obj.end_answer.question.chapter.name,
|