コード例 #1
0
 def get(self, request, course_id, format=None):
     """ Get comment number of the current course. """
     result = {
         "comments": course_stat.comment_total_count(
             SlashSeparatedCourseKey.from_deprecated_string(course_id)),
     }
     return Response(result)
コード例 #2
0
    def get(self, request, course_id, format=None):
        """ Get some frequency update data of the current course. """
        try:
            course = Course.objects.get(course_id=course_id)
        except:
            return Response(status=status.HTTP_404_NOT_FOUND)

        course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)

        result = {
            "enrollments": course_stat.enrollment_total_count(course_key),
            "comments": course_stat.comment_total_count(course_key),
            "serialized": course.serialized,
        }
        return Response(result)