feat: add problem scores to progress tab api (AA-875)
This commit is contained in:
@@ -27,6 +27,7 @@ class SubsectionScoresSerializer(serializers.Serializer):
|
||||
num_points_earned = serializers.FloatField(source='graded_total.earned')
|
||||
num_points_possible = serializers.FloatField(source='graded_total.possible')
|
||||
percent_graded = serializers.FloatField()
|
||||
problem_scores = serializers.SerializerMethodField()
|
||||
show_correctness = serializers.CharField()
|
||||
show_grades = serializers.SerializerMethodField()
|
||||
url = serializers.SerializerMethodField()
|
||||
@@ -34,6 +35,16 @@ class SubsectionScoresSerializer(serializers.Serializer):
|
||||
def get_block_key(self, subsection):
|
||||
return str(subsection.location)
|
||||
|
||||
def get_problem_scores(self, subsection):
|
||||
problem_scores = [
|
||||
{
|
||||
'earned': score.earned,
|
||||
'possible': score.possible,
|
||||
}
|
||||
for score in subsection.problem_scores.values()
|
||||
]
|
||||
return problem_scores
|
||||
|
||||
def get_url(self, subsection):
|
||||
relative_path = reverse('jump_to', args=[self.context['course_key'], subsection.location])
|
||||
request = self.context['request']
|
||||
|
||||
@@ -79,6 +79,9 @@ class ProgressTabView(RetrieveAPIView):
|
||||
num_points_earned: (int) the amount of points the user has earned for the given subsection
|
||||
num_points_possible: (int) the total amount of points possible for the given subsection
|
||||
percent_graded: (float) the percentage of total points the user has received a grade for in a given subsection
|
||||
problem_scores: List of objects that represent individual problem scores with the following fields:
|
||||
earned: (float) number of earned points
|
||||
possible: (float) number of possible points
|
||||
show_correctness: (str) a str representing whether to show the problem/practice scores based on due date
|
||||
('always', 'never', 'past_due', values defined in
|
||||
common/lib/xmodule/xmodule/modulestore/inheritance.py)
|
||||
|
||||
Reference in New Issue
Block a user