Commit cab7b747a3b25ed2db4cd3a97e28cf3ce83b5f98

Authored by Felipe Bormann
2 parents 8baad86a c04bf6c3

Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring

webconference/templates/webconference/relatorios.html
1   -{% extends "subjects/view.html" %}
  1 +{% extends "webconference/view.html" %}
2 2  
3 3 {% load static i18n pagination permissions_tags subject_counter %}
4 4 {% load django_bootstrap_breadcrumbs %}
... ... @@ -11,7 +11,7 @@
11 11  
12 12 var array_history = [];
13 13 {%for data_json in json_history.data %}
14   - array_history.push(["{{data_json.0}}","{{data_json.1}}","{{view}}",{% if data_json.3 is not None %}new Date('{{data_json.3.isoformat}}'){% else%}null{% endif %}]);
  14 + array_history.push(["{{data_json.0}}","{{data_json.1}}","{% if data_json.2 == 'view' %} {{view}} {% elif data_json.2 == 'initwebconference' %} {{initwebconference}} {% else %} {{participate}} {% endif %}",{% if data_json.3 is not None %}new Date('{{data_json.3.isoformat}}'){% else%}null{% endif %}]);
15 15 {% endfor%}
16 16 var json_history = {"data":array_history};
17 17 var column_history = [{"string":'{% trans "User" %}'},{"string":'{% trans "Group" %}'},{"string":'{% trans "Action" %}'},{"date":'{% trans "Date of Action" %}'}];
... ... @@ -48,7 +48,7 @@
48 48 var options = {
49 49 title: '{{title_chart}}',
50 50 // legend: {position: 'right', maxLines: 1},
51   - bar: { groupWidth: '30%' },
  51 + bar: { groupWidth: '50%' },
52 52 chartArea:{width:"50%"},
53 53 titlePosition: 'out',
54 54 vAxis: {
... ... @@ -64,9 +64,87 @@
64 64  
65 65 function selectHandler() {
66 66 var selectedItem = chart.getSelection()[0];
  67 + var col = data.getColumnLabel(selectedItem.column);
67 68 if (selectedItem) {
68   - var col = data.getColumnLabel(selectedItem.column);
69   - if (col == "{{n_did_table}}"){
  69 + if (selectedItem.row == 0 && selectedItem.column == 1){
  70 + tabela_atual = true;
  71 + search = [];
  72 + var text = "{{view}}";
  73 + for (var i in json_history["data"]){
  74 + if (json_history["data"][i][2].toLowerCase().includes(text.toLowerCase())){
  75 + search.push([json_history["data"][i][0],json_history["data"][i][1],
  76 + json_history["data"][i][2],json_history["data"][i][3]]);
  77 + }
  78 + }
  79 + drawTable(column_history,pagination(search,1),true,3);
  80 + alterTitleTable(search.length);
  81 + putpagination(search,tabela_atual);
  82 + } else if(selectedItem.row == 0 && selectedItem.column == 2){
  83 + tabela_atual = false;
  84 + search = [];
  85 + var text = "{{view}}";
  86 + for (var i in json_n_did["data"]){
  87 + if (json_n_did["data"][i][3].toLowerCase().includes(text.toLowerCase())){
  88 + search.push([json_n_did["data"][i][0],json_n_did["data"][i][1],
  89 + json_n_did["data"][i][2],json_n_did["data"][i][3]]);
  90 + }
  91 + }
  92 + drawTable(column_n_did,pagination(search,1),false);
  93 + alterTitleTable(search.length);
  94 + putpagination(search,tabela_atual);
  95 + } else if (selectedItem.row == 1 && selectedItem.column == 1){
  96 + tabela_atual = true;
  97 + search = [];
  98 + var text = "{{initwebconference}}";
  99 + for (var i in json_history["data"]){
  100 + if (json_history["data"][i][2].toLowerCase().includes(text.toLowerCase())){
  101 + search.push([json_history["data"][i][0],json_history["data"][i][1],
  102 + json_history["data"][i][2],json_history["data"][i][3]]);
  103 + }
  104 + }
  105 + drawTable(column_history,pagination(search,1),true,3);
  106 + alterTitleTable(search.length);
  107 + putpagination(search,tabela_atual);
  108 + } else if(selectedItem.row == 1 && selectedItem.column == 2){
  109 + tabela_atual = false;
  110 + search = [];
  111 + var text = "{{initwebconference}}";
  112 + for (var i in json_n_did["data"]){
  113 + if (json_n_did["data"][i][3].toLowerCase().includes(text.toLowerCase())){
  114 + search.push([json_n_did["data"][i][0],json_n_did["data"][i][1],
  115 + json_n_did["data"][i][2],json_n_did["data"][i][3]]);
  116 + }
  117 + }
  118 + drawTable(column_n_did,pagination(search,1),false);
  119 + alterTitleTable(search.length);
  120 + putpagination(search,tabela_atual);
  121 + } else if (selectedItem.row == 2 && selectedItem.column == 1){
  122 + tabela_atual = true;
  123 + search = [];
  124 + var text = "{{participate}}";
  125 + for (var i in json_history["data"]){
  126 + if (json_history["data"][i][2].toLowerCase().includes(text.toLowerCase())){
  127 + search.push([json_history["data"][i][0],json_history["data"][i][1],
  128 + json_history["data"][i][2],json_history["data"][i][3]]);
  129 + }
  130 + }
  131 + drawTable(column_history,pagination(search,1),true,3);
  132 + alterTitleTable(search.length);
  133 + putpagination(search,tabela_atual);
  134 + } else if(selectedItem.row == 2 && selectedItem.column == 2){
  135 + tabela_atual = false;
  136 + search = [];
  137 + var text = "{{participate}}";
  138 + for (var i in json_n_did["data"]){
  139 + if (json_n_did["data"][i][3].toLowerCase().includes(text.toLowerCase())){
  140 + search.push([json_n_did["data"][i][0],json_n_did["data"][i][1],
  141 + json_n_did["data"][i][2],json_n_did["data"][i][3]]);
  142 + }
  143 + }
  144 + drawTable(column_n_did,pagination(search,1),false);
  145 + alterTitleTable(search.length);
  146 + putpagination(search,tabela_atual);
  147 + } else if (col == "{{n_did_table}}"){
70 148 tabela_atual = false;
71 149 search = [];
72 150 for (var i in json_n_did["data"]){
... ... @@ -149,9 +227,8 @@
149 227  
150 228 {% block breadcrumbs %}
151 229 {{ block.super }}
152   - {% breadcrumb webconference.topic 'subjects:topic_view' webconference.topic.subject.slug webconference.topic.slug %}
153 230 {% trans 'Reports' as bread %}
154   - {% breadcrumb bread webconference%}
  231 + {% breadcrumb bread webconference%}
155 232 {% endblock %}
156 233  
157 234 {% block content %}
... ... @@ -203,7 +280,7 @@
203 280 <ul>
204 281 </div>
205 282 </div>
206   -
  283 +
207 284 <div class="row">
208 285 <div class="col-md-10 col-md-offset-1">
209 286 <div id="chart_div" style="height: 500px; margin-top: -50px;"></div>
... ... @@ -231,10 +308,10 @@
231 308 <div id="table_div"></div>
232 309 </form>
233 310 <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12 text-center">
234   - <ul class="pagination">
  311 + <ul class="pagination">
235 312  
236   - </ul>
237   - </div>
  313 + </ul>
  314 + </div>
238 315 </div>
239 316 </div>
240 317 <div id="modal-message"></div>
... ... @@ -324,7 +401,7 @@
324 401 }
325 402 }
326 403 }
327   - console.log(search);
  404 +
328 405 if (!load_histoty){
329 406 drawTable(column_n_did,pagination(search,1),false);
330 407 } else {
... ... @@ -432,5 +509,8 @@
432 509 function scroll(to){
433 510 $("html, body").animate({ scrollTop: $(to).offset().top }, "slow");
434 511 }
  512 + function alterTitleTable (quant){
  513 + $("#title-table").text(quant + " {% trans 'record(s)' %}");
  514 + }
435 515 </script>
436 516 {% endblock %}
... ...
webconference/views.py
... ... @@ -10,6 +10,7 @@ from webpage.forms import FormModalMessage
10 10 from chat.models import Conversation, TalkMessages, ChatVisualizations
11 11 import textwrap
12 12 import json
  13 +from django.db.models import Q
13 14 from channels import Group
14 15 import datetime
15 16 from users.models import User
... ... @@ -545,6 +546,7 @@ class ConferenceSettings(braces_mixins.LoginRequiredMixin, braces_mixins.Staffus
545 546 context['title'] = _('Web Conference Settings')
546 547  
547 548 return context
  549 +
548 550 class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView):
549 551 log_component = 'resources'
550 552 log_action = 'view_statistics'
... ... @@ -561,7 +563,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView):
561 563 webconference = get_object_or_404(Webconference, slug = slug)
562 564  
563 565 if not has_subject_permissions(request.user, webconference.topic.subject):
564   - return redirect(reverse_lazy('subjects:home'))
  566 + return redirect(reverse_lazy('subjects:home'))
565 567  
566 568 return super(StatisticsView, self).dispatch(request, *args, **kwargs)
567 569  
... ... @@ -584,7 +586,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView):
584 586 super(StatisticsView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context)
585 587  
586 588  
587   - context['title'] = _('Webconference Reports')
  589 + context['title'] = _('Youtube Video Reports')
588 590  
589 591 slug = self.kwargs.get('slug')
590 592 webconference = get_object_or_404(Webconference, slug = slug)
... ... @@ -602,7 +604,7 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView):
602 604 if webconference.all_students :
603 605 alunos = webconference.topic.subject.students.all()
604 606  
605   - vis_ou = Log.objects.filter(context__contains={'webconference_id':webconference.id},resource="webconference",action="view",user_email__in=(aluno.email for aluno in alunos), datetime__range=(start_date,end_date + datetime.timedelta(minutes = 1)))
  607 + vis_ou = Log.objects.filter(context__contains={'webconference_id':webconference.id},resource="webconference",user_email__in=(aluno.email for aluno in alunos), datetime__range=(start_date,end_date + datetime.timedelta(minutes = 1))).filter(Q(action="view") | Q(action="initwebconference") | Q(action="participating"))
606 608 did,n_did,history = str(_("Realized")),str(_("Unrealized")),str(_("Historic"))
607 609 re = []
608 610 data_n_did,data_history = [],[]
... ... @@ -615,26 +617,48 @@ class StatisticsView(LoginRequiredMixin, LogMixin, generic.DetailView):
615 617  
616 618 json_history["data"] = data_history
617 619  
618   - not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.distinct("user_email")])
  620 + column_view,column_initwebconference,column_participate = str(_('View')),str(_('Enter')),str(_('Participate'))
  621 +
  622 + not_view = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="view").distinct("user_email")])
619 623 index = 0
620 624 for alun in not_view:
621   - data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),str(_('View')), str(alun.email)])
  625 + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_view, str(alun.email)])
  626 + index += 1
  627 +
  628 + not_initwebconference = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="initwebconference").distinct("user_email")])
  629 + for alun in not_initwebconference:
  630 + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_initwebconference, str(alun.email)])
  631 + index += 1
  632 +
  633 + not_participate = alunos.exclude(email__in=[log.user_email for log in vis_ou.filter(action="participating").distinct("user_email")])
  634 + for alun in not_participate:
  635 + data_n_did.append([index,str(alun),", ".join([str(x) for x in webconference.topic.subject.group_subject.filter(participants__email=alun.email)]),column_participate, str(alun.email)])
622 636 index += 1
  637 +
623 638 json_n_did["data"] = data_n_did
624 639  
625 640  
626 641 context["json_n_did"] = json_n_did
627 642 context["json_history"] = json_history
628   - c_visualizou = vis_ou.distinct("user_email").count()
629   - column_view = str(_('View'))
630   - re.append([str(_('File link')),did,n_did])
  643 + c_visualizou = vis_ou.filter(action="view").distinct("user_email").count()
  644 + c_initwebconference = vis_ou.filter(action="initwebconference").distinct("user_email").count()
  645 + c_participate = vis_ou.filter(action="participating").distinct("user_email").count()
  646 + re.append([str(_('Webconference')),did,n_did])
  647 +
631 648 re.append([column_view,c_visualizou, alunos.count() - c_visualizou])
  649 + re.append([column_initwebconference,c_initwebconference, alunos.count() - c_initwebconference])
  650 + re.append([column_participate,c_participate, alunos.count() - c_participate])
  651 +
  652 + context['view'] = column_view
  653 + context['initwebconference'] = column_initwebconference
  654 + context['participate'] = column_participate
632 655 context['topic'] = webconference.topic
633 656 context['subject'] = webconference.topic.subject
  657 + context['webconference'] = webconference
634 658 context['db_data'] = re
635 659 context['title_chart'] = _('Actions about resource')
636 660 context['title_vAxis'] = _('Quantity')
637   - context['view'] = column_view
  661 +
638 662 context["n_did_table"] = n_did
639 663 context["did_table"] = did
640 664 context["history_table"] = history
... ...