|
@@ -85,17 +85,8 @@ class StaffExamLogRetrieveSerializer(serializers.ModelSerializer):
|
|
|
question_total_count = serializers.CharField(source='exampaper.question_total_count', read_only=True)
|
|
|
question_total_scores = serializers.CharField(source='exampaper.question_total_scores', read_only=True)
|
|
|
|
|
|
- single_total_count = serializers.CharField(source='exampaper.single_total_count', read_only=True)
|
|
|
- multiple_total_count = serializers.CharField(source='exampaper.multiple_total_count', read_only=True)
|
|
|
- fill_total_count = serializers.CharField(source='exampaper.fill_total_count', read_only=True)
|
|
|
- judgment_total_count = serializers.CharField(source='exampaper.judgment_total_count', read_only=True)
|
|
|
-
|
|
|
- single_total_scores = serializers.CharField(source='exampaper.single_total_scores', read_only=True)
|
|
|
- multiple_total_scores = serializers.CharField(source='exampaper.multiple_total_scores', read_only=True)
|
|
|
- fill_total_scores = serializers.CharField(source='exampaper.fill_total_scores', read_only=True)
|
|
|
- judgment_total_scores = serializers.CharField(source='exampaper.judgment_total_scores', read_only=True)
|
|
|
-
|
|
|
total_right_count = serializers.SerializerMethodField()
|
|
|
+ answer_items = serializers.SerializerMethodField()
|
|
|
|
|
|
class Meta:
|
|
|
model = ExamLog
|
|
@@ -104,6 +95,46 @@ class StaffExamLogRetrieveSerializer(serializers.ModelSerializer):
|
|
|
def get_total_right_count(self, obj):
|
|
|
return obj.single_answer_count + obj.multiple_answer_count + obj.fill_answer_count + obj.judgment_answer_count
|
|
|
|
|
|
+ def get_answer_items(self, obj):
|
|
|
+ data = []
|
|
|
+ if obj.exampaper.single_total_count:
|
|
|
+ item = {
|
|
|
+ 'name': '单选题',
|
|
|
+ 'total_count': obj.exampaper.single_total_count,
|
|
|
+ 'total_right': obj.single_answer_count,
|
|
|
+ 'total_scores': obj.exampaper.single_total_scores,
|
|
|
+ 'answer_scores': obj.single_answer_scores,
|
|
|
+ }
|
|
|
+ data.append(item)
|
|
|
+ if obj.exampaper.multiple_total_count:
|
|
|
+ item = {
|
|
|
+ 'name': '多选题',
|
|
|
+ 'total_count': obj.exampaper.multiple_total_count,
|
|
|
+ 'total_right': obj.multiple_answer_count,
|
|
|
+ 'total_scores': obj.exampaper.multiple_total_scores,
|
|
|
+ 'answer_scores': obj.multiple_answer_scores,
|
|
|
+ }
|
|
|
+ data.append(item)
|
|
|
+ if obj.exampaper.fill_total_count:
|
|
|
+ item = {
|
|
|
+ 'name': '填空题',
|
|
|
+ 'total_count': obj.exampaper.fill_total_count,
|
|
|
+ 'total_right': obj.fill_answer_count,
|
|
|
+ 'total_scores': obj.exampaper.fill_total_scores,
|
|
|
+ 'answer_scores': obj.fill_answer_scores,
|
|
|
+ }
|
|
|
+ data.append(item)
|
|
|
+ if obj.exampaper.judgment_total_count:
|
|
|
+ item = {
|
|
|
+ 'name': '判断题',
|
|
|
+ 'total_count': obj.exampaper.judgment_total_count,
|
|
|
+ 'total_right': obj.judgment_answer_count,
|
|
|
+ 'total_scores': obj.exampaper.judgment_total_scores,
|
|
|
+ 'answer_scores': obj.judgment_answer_scores,
|
|
|
+ }
|
|
|
+ data.append(item)
|
|
|
+ return data
|
|
|
+
|
|
|
|
|
|
class ExamAnswerLogSerializer(serializers.ModelSerializer):
|
|
|
item = serializers.SerializerMethodField()
|