Commit a71ff4336da4ca9390afdce31dd2b3a2117b9ed2

Authored by fbormann
1 parent 341d2d2b

added webconference variables to report view as well as added distinct days vari…

…ables to all kind of resources
Showing 2 changed files with 22 additions and 5 deletions   Show diff stats
links/views.py
... ... @@ -21,7 +21,7 @@ from topics.models import Topic
21 21 class CreateLinkView(LoginRequiredMixin, LogMixin, generic.edit.CreateView):
22 22 log_component = 'resources'
23 23 log_action = 'create'
24   - log_resource = 'links'
  24 + log_resource = 'link'
25 25 log_context = {}
26 26  
27 27 login_url = reverse_lazy("users:login")
... ... @@ -185,7 +185,7 @@ class DeleteLinkView(LoginRequiredMixin, LogMixin, generic.edit.DeleteView):
185 185 class DetailLinkView(LoginRequiredMixin, LogMixin, generic.detail.DetailView):
186 186 log_component = 'resources'
187 187 log_action = 'view'
188   - log_resource = 'links'
  188 + log_resource = 'link'
189 189 log_context = {}
190 190 login_url = reverse_lazy("users:login")
191 191 redirect_field_name = 'next'
... ...
reports/views.py
... ... @@ -58,7 +58,6 @@ class ReportView(LoginRequiredMixin, generic.FormView):
58 58  
59 59 classes = Resource.__subclasses__()
60 60  
61   -
62 61 #set formset
63 62 resourceTagFormSet = formset_factory(ResourceAndTagForm, formset=BaseResourceAndTagFormset)
64 63 resourceTagFormSet = resourceTagFormSet()
... ... @@ -319,26 +318,44 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
319 318 distinct_resources = 0
320 319 total_count = 0
321 320  
  321 + day_numbers = [0, 1, 2, 3, 4, 5, 6]
  322 + distinct_days = 0
322 323 for resource in resources:
  324 +
323 325 if isinstance(topics,Topic):
324 326 #or it selected only one topic to work with
325 327 count = Log.objects.filter(action="view", resource=resources_types[i].lower(),
326 328 user_id = student.id, context__contains = {'subject_id': subject.id,
327 329 resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__range=(init_date, end_date)).count()
328   -
  330 +
  331 + for daynum in day_numbers:
  332 + count_temp = Log.objects.filter(action="view", resource=resources_types[i].lower(),
  333 + user_id = student.id, context__contains = {'subject_id': subject.id,
  334 + resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__week_day = day_num+1, datetime__range=(init_date, end_date)).count()
  335 + if count_temp > 0:
  336 + distinct_days += 1
329 337 else:
330 338 #or the user selected all
331 339  
332   - count = Log.objects.filter(action="view", resource=resources_types[i].lower(),
  340 + count = Log.objects.filter(action="view", resource=resources_types[i].lower(),
333 341 user_id = student.id, context__contains = {'subject_id': subject.id,
334 342 resources_types[i].lower()+'_id': resource.id}, datetime__range=(init_date, end_date)).count()
335 343  
  344 + for daynum in day_numbers:
  345 + count_temp = Log.objects.filter(action="view", resource=resources_types[i].lower(),
  346 + user_id = student.id, context__contains = {'subject_id': subject.id,
  347 + resources_types[i].lower()+'_id': resource.id}, datetime__week_day = daynum+1,
  348 + datetime__range=(init_date, end_date)).count()
  349 + if count_temp > 0:
  350 + distinct_days += 1
336 351 if count > 0:
337 352 distinct_resources += 1
338 353 total_count += count
339 354  
340 355 data[str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = total_count
341 356 data["distintic " + str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = distinct_resources
  357 + data["distintic days " + str(resources_types[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = distinct_days
  358 +
342 359 """data["distinct" + str(resources[i]) + " with tag " + Tag.objects.get(id=int(tags[i])).name] = Log.objects.filter(action="view", resource=resources[i].lower(),
343 360 user_id = student.id, context__contains = {'subject_id': subject.id}).distinct().count()"""
344 361  
... ...