Commit 5b858ddebff6e23959bb019c9945c991fbce3feb
1 parent
431b542e
Exists in
master
and in
3 other branches
finished variable 24 to 31
Showing
1 changed file
with
30 additions
and
3 deletions
Show diff stats
api/views.py
@@ -9,6 +9,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin | @@ -9,6 +9,8 @@ from django.contrib.auth.mixins import LoginRequiredMixin | ||
9 | from datetime import datetime, date | 9 | from datetime import datetime, date |
10 | from subjects.models import Subject | 10 | from subjects.models import Subject |
11 | 11 | ||
12 | +from log.models import Log | ||
13 | + | ||
12 | class ReportView(LoginRequiredMixin, generic.TemplateView): | 14 | class ReportView(LoginRequiredMixin, generic.TemplateView): |
13 | template_name = "api/report.html" | 15 | template_name = "api/report.html" |
14 | 16 | ||
@@ -37,9 +39,11 @@ class ReportView(LoginRequiredMixin, generic.TemplateView): | @@ -37,9 +39,11 @@ class ReportView(LoginRequiredMixin, generic.TemplateView): | ||
37 | interactions['init_date'] = init_date | 39 | interactions['init_date'] = init_date |
38 | interactions['end_date'] = end_date | 40 | interactions['end_date'] = end_date |
39 | 41 | ||
42 | + help_posts_made_by_user = SubjectPost.objects.filter(action="help",space__id=subject.id, user=student, | ||
43 | + create_date__range=(init_date, end_date)) | ||
44 | + | ||
40 | #number of help posts created by the student | 45 | #number of help posts created by the student |
41 | - interactions['doubts_count'] = SubjectPost.objects.filter(action="help", create_date__range=(init_date, end_date), | ||
42 | - space__id=subject_id, user=student).count() | 46 | + interactions['doubts_count'] = help_posts_made_by_user.count() |
43 | 47 | ||
44 | help_posts = SubjectPost.objects.filter(action="help", create_date__range=(init_date, end_date), | 48 | help_posts = SubjectPost.objects.filter(action="help", create_date__range=(init_date, end_date), |
45 | space__id=subject_id) | 49 | space__id=subject_id) |
@@ -75,15 +79,38 @@ class ReportView(LoginRequiredMixin, generic.TemplateView): | @@ -75,15 +79,38 @@ class ReportView(LoginRequiredMixin, generic.TemplateView): | ||
75 | #number of help posts created by the user others students commented on | 79 | #number of help posts created by the user others students commented on |
76 | interactions['help_posts_commented_by_others'] = help_posts.filter(user=student, id__in = help_posts_ids).count() | 80 | interactions['help_posts_commented_by_others'] = help_posts.filter(user=student, id__in = help_posts_ids).count() |
77 | 81 | ||
78 | - | ||
79 | #Number of student visualizations on the mural of the subject | 82 | #Number of student visualizations on the mural of the subject |
80 | interactions['mural_visualizations_count'] = MuralVisualizations.objects.filter(post__in = SubjectPost.objects.filter(space__id=subject.id), | 83 | interactions['mural_visualizations_count'] = MuralVisualizations.objects.filter(post__in = SubjectPost.objects.filter(space__id=subject.id), |
81 | user = student).count() | 84 | user = student).count() |
82 | 85 | ||
83 | 86 | ||
87 | + #VAR20 - number of access to mural between 6 a.m to 12a.m. | ||
88 | + interactions['access_subject_between_6_to_12_am'] = Log.objects.filter(action="access", resource="subject", | ||
89 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (5, 11)).count() | ||
90 | + | ||
91 | + #VAR21 - number of access to mural between 6 a.m to 12a.m. | ||
92 | + interactions['access_subject_between_0_to_6_pm'] = Log.objects.filter(action="access", resource="subject", | ||
93 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (11, 17)).count() | ||
94 | + #VAR22 | ||
95 | + interactions['access_subject_between_6_to_12_pm'] = Log.objects.filter(action="access", resource="subject", | ||
96 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (17, 23)).count() | ||
97 | + | ||
98 | + #VAR23 | ||
99 | + interactions['access_subject_between_0_to_6_am'] = Log.objects.filter(action="access", resource="subject", | ||
100 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (23, 5)).count() | ||
101 | + | ||
102 | + #VAR24 through 30 | ||
103 | + day_numbers = [0, 1, 2, 3, 4, 5, 6] | ||
104 | + day_names = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] | ||
105 | + for day_num in day_numbers: | ||
106 | + interactions['access_subject_'+day_names[day_num]] = Log.objects.filter(action="access", resource="subject", | ||
107 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__week_day = day_num).count() | ||
108 | + | ||
84 | data[student] = interactions | 109 | data[student] = interactions |
85 | 110 | ||
86 | context["data"] = data | 111 | context["data"] = data |
87 | 112 | ||
88 | 113 | ||
89 | return context | 114 | return context |
115 | + | ||
116 | + |