Commit c4a82665 authored by Fernando Ribeiro's avatar Fernando Ribeiro
Browse files

Merge branch 'develop' into 'master'

Develop into master

See merge request !15
parents 752b0569 b50cc400
......@@ -209,9 +209,9 @@ class Course(models.Model):
def avg_lessons_users_progress(self, classes=None):
if classes:
student_enrolled = self.course_students.filter(
user__classes__in=classes).count()
user__classes__in=classes, user__is_active=True).count()
else:
student_enrolled = self.course_students.all().count()
student_enrolled = self.course_students.filter(user__is_active=True).count()
progress_list = []
for lesson in self.lessons.all():
lesson_progress = {}
......@@ -222,7 +222,7 @@ class Course(models.Model):
# avoid zero divisfion
if units_len and student_enrolled:
units_done = StudentProgress.objects.exclude(
complete=None).filter(unit__lesson=lesson)
complete=None, user__is_active=True).filter(unit__lesson=lesson)
if classes:
units_done = units_done.filter(user__classes__in=classes)
units_done_len = units_done.count()
......
......@@ -40,7 +40,7 @@ class SummaryViewSet(viewsets.ViewSet):
for course in courses:
stats[course.slug] = {
'name': course.name,
'user_count': course.course_students.count(),
'user_count': course.course_students.filter(user__is_active=True).count(),
'user_finished_course_count': 0,
'classes' : []
}
......@@ -54,7 +54,7 @@ class SummaryViewSet(viewsets.ViewSet):
activities[course.slug] = le_activities.count()
aux = Answer.objects \
.filter(activity__in=le_activities)\
.filter(activity__in=le_activities, user__is_active=True)\
.values('user')\
.order_by('user')\
.annotate(Count('user'))
......@@ -63,7 +63,7 @@ class SummaryViewSet(viewsets.ViewSet):
aux = StudentProgress.objects\
.exclude(complete=None) \
.filter(unit__lesson__course=course)\
.filter(unit__lesson__course=course, user__is_active=True)\
.values('user')\
.order_by('user').\
annotate(Count('user'))
......@@ -97,11 +97,11 @@ class SummaryViewSet(viewsets.ViewSet):
classes = Class.objects.filter(course__in=courses).prefetch_related('students').select_related('course')
for cclass in classes:
certified = cclass.get_students.filter(certificate__type='certificate').select_related('course', 'user')
not_certified = cclass.get_students.exclude(certificate__type='certificate').select_related('course', 'user')
certified = cclass.get_students.filter(certificate__type='certificate', user__is_active=True).select_related('course', 'user')
not_certified = cclass.get_students.exclude(certificate__type='certificate', user__is_active=False).select_related('course', 'user')
cclass_stats = {
'name': cclass.name,
'user_count': cclass.get_students.count(),
'user_count': cclass.get_students.filter(user__is_active=True).count(),
'certificate_count': certified.count(),
'user_finished': 0
}
......@@ -122,16 +122,17 @@ class SummaryViewSet(viewsets.ViewSet):
stats = list(stats.values())
users_director_total = User.objects.filter(groups__name='Diretor Escolar').count()
users_director_login = User.objects.filter(groups__name='Diretor Escolar').exclude(last_login=None).count()
users_coordinator_total = User.objects.filter(groups__name='Coordenação Pedagógica').count()
users_coordinator_login = User.objects.filter(groups__name='Coordenação Pedagógica').exclude(last_login=None).count()
users_technical_total = User.objects.filter(groups__name='Equipe Técnica').count()
users_technical_login = User.objects.filter(groups__name='Equipe Técnica').exclude(last_login=None).count()
users_formadores_total = User.objects.filter(groups__name='Formadores').count()
users_formadores_login = User.objects.filter(groups__name='Formadores').exclude(last_login=None).count()
users_apoio_total = User.objects.filter(groups__name='Apoio Pedagógico').count()
users_apoio_login = User.objects.filter(groups__name='Apoio Pedagógico').exclude(last_login=None).count()
users_active = User.objects.filter(is_active=True)
users_director_total = users_active.filter(groups__name='Diretor Escolar').count()
users_director_login = users_active.filter(groups__name='Diretor Escolar').exclude(last_login=None).count()
users_coordinator_total = users_active.filter(groups__name='Coordenação Pedagógica').count()
users_coordinator_login = users_active.filter(groups__name='Coordenação Pedagógica').exclude(last_login=None).count()
users_technical_total = users_active.filter(groups__name='Equipe Técnica').count()
users_technical_login = users_active.filter(groups__name='Equipe Técnica').exclude(last_login=None).count()
users_formadores_total = users_active.filter(groups__name='Formadores').count()
users_formadores_login = users_active.filter(groups__name='Formadores').exclude(last_login=None).count()
users_apoio_total = users_active.filter(groups__name='Apoio Pedagógico').count()
users_apoio_login = users_active.filter(groups__name='Apoio Pedagógico').exclude(last_login=None).count()
response = Response({
'users_director_total': users_director_total,
......@@ -144,10 +145,11 @@ class SummaryViewSet(viewsets.ViewSet):
'users_formadores_login': users_formadores_login,
'users_apoio_total': users_apoio_total,
'users_apoio_login': users_apoio_login,
'user_count': User.objects.count(),
'total_number_of_topics': Topic.objects.count(),
'total_number_of_comments': Comment.objects.count(),
'total_number_of_likes': TopicLike.objects.count() + CommentLike.objects.count(),
'user_count': User.objects.filter(is_active=True).count(),
'user_inactive_count': User.objects.filter(is_active=False).count(),
'total_number_of_topics': Topic.objects.filter(author__is_active=True).count(),
'total_number_of_comments': Comment.objects.filter(author__is_active=True).count(),
'total_number_of_likes': TopicLike.objects.filter(user__is_active=True).count() + CommentLike.objects.filter(user__is_active=True).count(),
'statistics_per_course': stats})
return response
......
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