Commit c209b763 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

[Classroom Status] Add urls for classroom_report


Signed-off-by: default avatarMatheus Miranda <matheusmirandalacerda@gmail.com>
parent 548393a3
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, CourseStudent, Course, User
from django.contrib.auth.models import User
from rest_framework import serializers
......
from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from django.db.models import Count
from rest_framework import viewsets
from rest_framework import viewsets, filters
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from rest_framework.pagination import PageNumberPagination
from django_filters.rest_framework import DjangoFilterBackend
from rest_pandas import PandasViewSet
from rest_pandas.renderers import PandasCSVRenderer, PandasJSONRenderer
......@@ -11,7 +15,7 @@ import pandas as pd
from discussion.models import Comment, CommentLike, Topic, TopicLike
from courses.models import Course, CourseStudent, StudentProgress, User
from courses.models import Course, CourseStudent, StudentProgress
from courses.classes.models import Class
from courses_learning_objects.models import LearningObject, Answer
......@@ -305,10 +309,10 @@ class ReportPagination(PageNumberPagination):
max_page_size = 100
class UserCourseStats(viewsets.ReadOnlyModelViewSet):
class UserClassRoomStats(viewsets.ReadOnlyModelViewSet):
model = User
queryset = User.objects.all().order_by('name')
serializer_class = UserCourseStatsSerializer
serializer_class = UserClassRoomStatsSerializer
filter_fields = ('group',)
permission_classes = [IsAuthenticated]
pagination_class = ReportPagination
......@@ -328,7 +332,7 @@ class UserCourseStats(viewsets.ReadOnlyModelViewSet):
## MANTER O FILTER ABAIXO?
queryset = super(User, self).get_queryset().filter(is_active=True)
user = self.request.user
course_id = self.request.query_params.get('course')
classroom_id = self.request.query_params.get('classroom')
role = None
try:
role = self.request.user.teaching_courses.get(course__id=course_id).role
......
......@@ -24,6 +24,7 @@ from courses.reports.views import (
SummaryViewSet,
UsersByGroupViewSet,
UsersByClassViewSet,
UserClassRoomStats
)
from courses.classroom.views import (
BasicClassroomViewSet,
......@@ -54,6 +55,7 @@ router.register(r'class_basic', BasicClassViewSet)
router.register(r'summary', SummaryViewSet, base_name='summary')
router.register(r'users-by-group', UsersByGroupViewSet, base_name='users-by-group')
router.register(r'users-by-class', UsersByClassViewSet, base_name='users-by-class')
router.register(r'classroom-reports', UserClassRoomStats, base_name='classroom-reports')
# router.register(r'course_carousel', views.CarouselCourseView, base_name='course_carousel')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment