Skip to content

Commit

Permalink
Added stats to problem administation
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamín Mravec committed Nov 11, 2023
1 parent 295eb03 commit 5dd3f1b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions competition/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,21 @@ class ProblemWithSolutionsSerializer(serializers.ModelSerializer):
solution_set = SolutionAdministrationSerializer(many=True)
correction = ProblemCorrectionSerializer(many=False)
series = SeriesSerializer()

histogram = serializers.SerializerMethodField('get_series_histogram')
total_solutions = serializers.SerializerMethodField('get_series_num_solutions')

class Meta:
model = models.Problem
fields = ['solution_set', 'text', 'order',
fields = ['histogram', 'total_solutions', 'solution_set', 'text', 'order',
'correction', 'series', 'solution_pdf']
read_only_fields = ['text', 'order', 'series']
read_only_fields = ['histogram', 'num_solutions', 'text', 'order', 'series']

def get_series_histogram(self, obj):
return models.Problem.get_stats(obj).get('histogram')

def get_series_num_solutions(self, obj):
return models.Problem.get_stats(obj).get('num_solutions')


# class ProblemStatsSerializer(serializers.Serializer):
Expand Down

0 comments on commit 5dd3f1b

Please sign in to comment.