Commit f852e9fcaa421eb7aabfece07f9acad7f0bbdcc3
1 parent
6b44b1e6
Exists in
master
and in
3 other branches
fixed timespan variables 20 to 31
Showing
1 changed file
with
9 additions
and
7 deletions
Show diff stats
reports/views.py
... | ... | @@ -133,10 +133,12 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): |
133 | 133 | context['end_date'] = params_data['end_date'] |
134 | 134 | context['subject'] = subject |
135 | 135 | |
136 | + #I used getlist method so it can get more than one tag and one resource class_name | |
136 | 137 | resources = params_data.getlist('resource') |
137 | 138 | tags = params_data.getlist('tag') |
139 | + | |
138 | 140 | self.from_mural = params_data['from_mural'] |
139 | - #I used getlist method so it can get more than one tag and one resource class_name | |
141 | + | |
140 | 142 | context['data'], context['header'] = self.get_mural_data(subject, params_data['init_date'], params_data['end_date'], |
141 | 143 | resources, tags ) |
142 | 144 | |
... | ... | @@ -248,18 +250,18 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): |
248 | 250 | |
249 | 251 | #VAR20 - number of access to mural between 6 a.m to 12a.m. |
250 | 252 | interactions[_('Number of access to mural between 6 a.m to 12a.m. .')] = Log.objects.filter(action="access", resource="subject", |
251 | - user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (5, 11)).count() | |
253 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (5, 11), datetime__range=(init_date,end_date)).count() | |
252 | 254 | |
253 | 255 | #VAR21 - number of access to mural between 0 p.m to 6p.m. |
254 | 256 | interactions[_('Number of access to mural between 0 p.m to 6p.m. .')] = Log.objects.filter(action="access", resource="subject", |
255 | - user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (11, 17)).count() | |
257 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (11, 17), datetime__range=(init_date,end_date)).count() | |
256 | 258 | #VAR22 |
257 | 259 | interactions[_('Number of access to mural between 6 p.m to 12p.m. .')] = Log.objects.filter(action="access", resource="subject", |
258 | - user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (17, 23)).count() | |
260 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (17, 23), datetime__range=(init_date,end_date)).count() | |
259 | 261 | |
260 | 262 | #VAR23 |
261 | 263 | interactions[_('Number of access to mural between 0 a.m to 6a.m. .')] = Log.objects.filter(action="access", resource="subject", |
262 | - user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (23, 5)).count() | |
264 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__hour__range = (23, 5), datetime__range=(init_date,end_date)).count() | |
263 | 265 | |
264 | 266 | #VAR24 through 30 |
265 | 267 | day_numbers = [0, 1, 2, 3, 4, 5, 6] |
... | ... | @@ -267,7 +269,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): |
267 | 269 | distinct_days = 0 |
268 | 270 | for day_num in day_numbers: |
269 | 271 | interactions[_('Number of access to the subject on ')+ day_names[day_num]] = Log.objects.filter(action="access", resource="subject", |
270 | - user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__week_day = day_num).count() | |
272 | + user_id= student.id, context__contains = {'subject_id' : subject.id}, datetime__week_day = day_num, datetime__range = (init_date, end_date)).count() | |
271 | 273 | #to save the distinct days the user has accessed |
272 | 274 | if interactions[_('Number of access to the subject on ')+ day_names[day_num]] > 0: |
273 | 275 | distinct_days += 1 |
... | ... | @@ -285,7 +287,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): |
285 | 287 | |
286 | 288 | def get_resources_and_tags_data(self, resources_types, tags, student, subject, init_date, end_date): |
287 | 289 | data = OrderedDict() |
288 | - | |
290 | + print(tags) | |
289 | 291 | for i in range(len(resources_types)): |
290 | 292 | |
291 | 293 | resources = Resource.objects.select_related(resources_types[i].lower()).filter(tags__in = tags, topic__in=subject.topic_subject.all()) | ... | ... |