def test_lesson_average_score(self): score = LessonStudent.lesson_average_score( self.lesson1.id)['score__avg'] self.assertEqual(score, 76.0)
def get(self, request, pk): average_score = LessonStudent.lesson_average_score(pk)['score__avg'] lesson_score = LessonScore(lesson_id=pk, average_score=average_score) return Response(LessonScoreSerializer(lesson_score).data)
def test_student_average_score(self): score = LessonStudent.student_average_score( self.student2.id)['score__avg'] self.assertEqual(score, 42.0)
def get(self, request, pk): average_score = LessonStudent.student_average_score(pk)['score__avg'] student_score = StudentScore(student_id=pk, average_score=average_score) return Response(StudentScoreSerializer(student_score).data)