Commit 3be7ec9df59de75dc8407049e5e04206af610ebe

Authored by fbormann
1 parent ed70024a

fixed breadcrumbs and variable names

reports/forms.py
@@ -5,7 +5,7 @@ import datetime @@ -5,7 +5,7 @@ import datetime
5 5
6 6
7 class CreateInteractionReportForm(forms.Form): 7 class CreateInteractionReportForm(forms.Form):
8 - topic = forms.ChoiceField( label= _("topics to select data from")) 8 + topic = forms.ChoiceField( label= _("Topics to select data from"))
9 init_date = forms.DateField() 9 init_date = forms.DateField()
10 end_date = forms.DateField() 10 end_date = forms.DateField()
11 11
@@ -22,4 +22,4 @@ class CreateInteractionReportForm(forms.Form): @@ -22,4 +22,4 @@ class CreateInteractionReportForm(forms.Form):
22 topics = list(initial['topic']) 22 topics = list(initial['topic'])
23 23
24 self.fields['topic'].choices = [(topic.id, topic.name) for topic in topics] 24 self.fields['topic'].choices = [(topic.id, topic.name) for topic in topics]
25 - self.fields['topic'].choices.append((_("all"), _("all"))) 25 + self.fields['topic'].choices.append((_("All"), _("All")))
reports/templates/reports/create.html
@@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
6 6
7 {% block breadcrumbs %} 7 {% block breadcrumbs %}
8 {{ block.super }} 8 {{ block.super }}
9 - 9 + {% breadcrumb subject.category 'subjects:cat_view' subject.category.slug %}
  10 + {% breadcrumb subject 'subjects:view' subject.slug %}
10 {% breadcrumb 'analytics' '' %} 11 {% breadcrumb 'analytics' '' %}
11 {% endblock %} 12 {% endblock %}
12 13
reports/templates/reports/view.html
@@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
6 6
7 {% block breadcrumbs %} 7 {% block breadcrumbs %}
8 {{ block.super }} 8 {{ block.super }}
9 - 9 + {% breadcrumb view.subject.category 'subjects:cat_view' view.subject.category.slug %}
  10 + {% breadcrumb view.subject 'subjects:view' view.subject.slug %}
10 {% breadcrumb 'analytics' '' %} 11 {% breadcrumb 'analytics' '' %}
11 {% endblock %} 12 {% endblock %}
12 13
reports/views.py
@@ -34,6 +34,13 @@ class ReportView(LoginRequiredMixin, generic.FormView): @@ -34,6 +34,13 @@ class ReportView(LoginRequiredMixin, generic.FormView):
34 initial['end_date'] = date.today() 34 initial['end_date'] = date.today()
35 return initial 35 return initial
36 36
  37 + def get_context_data(self, **kwargs):
  38 + context = super(ReportView, self).get_context_data(**kwargs)
  39 + subject = Subject.objects.get(id=self.request.GET['subject_id'])
  40 +
  41 + context['subject'] = subject
  42 +
  43 + return context
37 44
38 def get_success_url(self): 45 def get_success_url(self):
39 46
@@ -93,7 +100,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -93,7 +100,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
93 except ValueError: 100 except ValueError:
94 pass 101 pass
95 102
96 - header = ['social_name'] 103 + header = ['User']
97 104
98 for student in students: 105 for student in students:
99 data[student] = [] 106 data[student] = []
@@ -107,22 +114,22 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -107,22 +114,22 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
107 create_date__range=(init_date, end_date)) 114 create_date__range=(init_date, end_date))
108 115
109 #number of help posts created by the student 116 #number of help posts created by the student
110 - interactions['doubts_count'] = help_posts_made_by_user.count() 117 + interactions['v01'] = help_posts_made_by_user.count()
111 118
112 help_posts = SubjectPost.objects.filter(action="help", create_date__range=(init_date, end_date), 119 help_posts = SubjectPost.objects.filter(action="help", create_date__range=(init_date, end_date),
113 space__id=subject.id) 120 space__id=subject.id)
114 121
115 #comments count on help posts created by the student 122 #comments count on help posts created by the student
116 - interactions['comments_count'] = Comment.objects.filter(post__in = help_posts.filter(user=student), 123 + interactions['v02'] = Comment.objects.filter(post__in = help_posts.filter(user=student),
117 create_date__range=(init_date, end_date)).count() 124 create_date__range=(init_date, end_date)).count()
118 125
119 126
120 #count the amount of comments made by the student on posts made by one of the professors 127 #count the amount of comments made by the student on posts made by one of the professors
121 - interactions['comments_professor_count'] = Comment.objects.filter(post__in = help_posts.filter(user__in= subject.professor.all()), create_date__range=(init_date, end_date), 128 + interactions['v03'] = Comment.objects.filter(post__in = help_posts.filter(user__in= subject.professor.all()), create_date__range=(init_date, end_date),
122 user=student).count() 129 user=student).count()
123 130
124 #comments made by the user on other users posts 131 #comments made by the user on other users posts
125 - interactions['comments_on_others_count'] = Comment.objects.filter(post__in = help_posts.exclude(user=student), 132 + interactions['v04'] = Comment.objects.filter(post__in = help_posts.exclude(user=student),
126 create_date__range=(init_date, end_date), 133 create_date__range=(init_date, end_date),
127 user= student).count() 134 user= student).count()
128 135
@@ -133,7 +140,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -133,7 +140,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
133 for comment in comments_by_teacher: 140 for comment in comments_by_teacher:
134 help_posts_ids.append(comment.post.id) 141 help_posts_ids.append(comment.post.id)
135 #number of help posts created by the user that the teacher commented on 142 #number of help posts created by the user that the teacher commented on
136 - interactions['help_posts_commented_by_teacher'] = help_posts.filter(user=student, id__in = help_posts_ids).count() 143 + interactions['v05'] = help_posts.filter(user=student, id__in = help_posts_ids).count()
137 144
138 145
139 comments_by_others = Comment.objects.filter(user__in=subject.students.exclude(id = student.id)) 146 comments_by_others = Comment.objects.filter(user__in=subject.students.exclude(id = student.id))
@@ -141,33 +148,33 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -141,33 +148,33 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
141 for comment in comments_by_teacher: 148 for comment in comments_by_teacher:
142 help_posts_ids.append(comment.post.id) 149 help_posts_ids.append(comment.post.id)
143 #number of help posts created by the user others students commented on 150 #number of help posts created by the user others students commented on
144 - interactions['help_posts_commented_by_others'] = help_posts.filter(user=student, id__in = help_posts_ids).count() 151 + interactions['v06'] = help_posts.filter(user=student, id__in = help_posts_ids).count()
145 152
146 #Number of student visualizations on the mural of the subject 153 #Number of student visualizations on the mural of the subject
147 - interactions['mural_visualizations_count'] = MuralVisualizations.objects.filter(post__in = SubjectPost.objects.filter(space__id=subject.id), 154 + interactions['v07'] = MuralVisualizations.objects.filter(post__in = SubjectPost.objects.filter(space__id=subject.id),
148 user = student).count() 155 user = student).count()
149 156
150 157
151 #VAR20 - number of access to mural between 6 a.m to 12a.m. 158 #VAR20 - number of access to mural between 6 a.m to 12a.m.
152 - interactions['access_subject_between_6_to_12_am'] = Log.objects.filter(action="access", resource="subject", 159 + interactions['v20'] = Log.objects.filter(action="access", resource="subject",
153 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (5, 11)).count() 160 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (5, 11)).count()
154 161
155 #VAR21 - number of access to mural between 6 a.m to 12a.m. 162 #VAR21 - number of access to mural between 6 a.m to 12a.m.
156 - interactions['access_subject_between_0_to_6_pm'] = Log.objects.filter(action="access", resource="subject", 163 + interactions['v21'] = Log.objects.filter(action="access", resource="subject",
157 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (11, 17)).count() 164 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (11, 17)).count()
158 #VAR22 165 #VAR22
159 - interactions['access_subject_between_6_to_12_pm'] = Log.objects.filter(action="access", resource="subject", 166 + interactions['v22'] = Log.objects.filter(action="access", resource="subject",
160 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (17, 23)).count() 167 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (17, 23)).count()
161 168
162 #VAR23 169 #VAR23
163 - interactions['access_subject_between_0_to_6_am'] = Log.objects.filter(action="access", resource="subject", 170 + interactions['v23'] = Log.objects.filter(action="access", resource="subject",
164 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (23, 5)).count() 171 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (23, 5)).count()
165 172
166 #VAR24 through 30 173 #VAR24 through 30
167 day_numbers = [0, 1, 2, 3, 4, 5, 6] 174 day_numbers = [0, 1, 2, 3, 4, 5, 6]
168 day_names = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"] 175 day_names = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
169 for day_num in day_numbers: 176 for day_num in day_numbers:
170 - interactions['access_subject_'+day_names[day_num]] = Log.objects.filter(action="access", resource="subject", 177 + interactions['v'+ str(24+day_num)] = Log.objects.filter(action="access", resource="subject",
171 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__week_day = day_num).count() 178 user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__week_day = day_num).count()
172 179
173 for value in interactions.values(): 180 for value in interactions.values():