diff --git a/reports/locale/pt_BR/LC_MESSAGES/django.po b/reports/locale/pt_BR/LC_MESSAGES/django.po index e26333f..170b465 100644 --- a/reports/locale/pt_BR/LC_MESSAGES/django.po +++ b/reports/locale/pt_BR/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-04-15 00:13-0300\n" +"POT-Creation-Date: 2017-04-29 21:14-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,287 +18,308 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: reports/forms.py:23 +#: .\forms.py:23 msgid "Kind Of Resource" msgstr "Tipo de recurso" -#: reports/forms.py:24 +#: .\forms.py:24 msgid "Tag" msgstr "Tag" -#: reports/forms.py:35 +#: .\forms.py:35 msgid "Topics" msgstr "Tópicos" -#: reports/forms.py:36 reports/templates/reports/view.html:58 +#: .\forms.py:36 .\templates\reports\view.html:58 msgid "Initial Date" msgstr "Data inicial" -#: reports/forms.py:37 +#: .\forms.py:37 msgid "Final Date" msgstr "Data Final" -#: reports/forms.py:39 +#: .\forms.py:39 msgid "From Mural" msgstr "Mural da disciplina" -#: reports/forms.py:40 +#: .\forms.py:40 msgid "Messages" msgstr "Mensagens" -#: reports/forms.py:51 reports/views.py:127 reports/views.py:198 +#: .\forms.py:51 .\views.py:145 .\views.py:218 msgid "All" msgstr "Todos" -#: reports/forms.py:60 +#: .\forms.py:60 msgid "The initial date can't be after the end one." msgstr "A data inicial não pode ser depois da final" -#: reports/forms.py:65 +#: .\forms.py:65 msgid "This date should be right or after " msgstr "Esta data deve ser igual ou após" -#: reports/forms.py:71 +#: .\forms.py:71 msgid "This date should be right or before " msgstr "Esta data deve ser igual ou anterior à" -#: reports/templates/reports/_form.html:19 +#: .\templates\reports\_form.html:19 msgid "General Parameters" msgstr "Escolha o Tópico e o Período" -#: reports/templates/reports/_form.html:37 +#: .\templates\reports\_form.html:37 msgid "Choose the Data Source (is possible to pick more than one)" msgstr "Escolha a fonte de dados (é possível escolher mais de uma)" -#: reports/templates/reports/_form.html:62 +#: .\templates\reports\_form.html:62 msgid "Interaction with resources" msgstr "Interação com recursos" -#: reports/templates/reports/_form.html:97 +#: .\templates\reports\_form.html:97 msgid "Search Report" msgstr "Buscar" -#: reports/templates/reports/create.html:27 -#: reports/templates/reports/view.html:33 +#: .\templates\reports\create.html:27 .\templates\reports\view.html:33 msgid "Analytics" msgstr "" -#: reports/templates/reports/create.html:37 -#: reports/templates/reports/view.html:43 +#: .\templates\reports\create.html:36 .\templates\reports\view.html:43 msgid "Interaction Data" msgstr "Dados de Interação" -#: reports/templates/reports/create.html:40 -#: reports/templates/reports/view.html:46 +#: .\templates\reports\create.html:39 .\templates\reports\view.html:46 msgid "Report Card" msgstr "Boletim do Tópico" -#: reports/templates/reports/create.html:43 -#: reports/templates/reports/view.html:49 +#: .\templates\reports\create.html:42 .\templates\reports\view.html:49 msgid "Participation" msgstr "Participações" -#: reports/templates/reports/create.html:55 +#: .\templates\reports\create.html:55 msgid "add data source" msgstr "Adicionar nova fonte de dados" -#: reports/templates/reports/create.html:56 +#: .\templates\reports\create.html:56 msgid "remove data source" msgstr "Remover esta fonte" -#: reports/templates/reports/view.html:56 +#: .\templates\reports\view.html:56 msgid "Subject" msgstr "Assunto" -#: reports/templates/reports/view.html:57 +#: .\templates\reports\view.html:57 msgid "Topic" msgstr "Tópico" -#: reports/templates/reports/view.html:59 +#: .\templates\reports\view.html:59 msgid "End Date" msgstr "Data final" -#: reports/templates/reports/view.html:60 +#: .\templates\reports\view.html:60 msgid "new search" msgstr "Nova Busca" -#: reports/templates/reports/view.html:66 +#: .\templates\reports\view.html:66 msgid "register(s)" msgstr "registro(s)" -#: reports/templates/reports/view.html:68 +#: .\templates\reports\view.html:68 msgid "Interactions Data (.csv)" msgstr "Dados de interação (.csv)" -#: reports/templates/reports/view.html:72 +#: .\templates\reports\view.html:72 msgid "Interactions Data (.xls)" msgstr "Dados de interação (.xls)" -#: reports/views.py:60 +#: .\views.py:78 msgid "Report created successfully" msgstr "Relatório criado com sucesso!" -#: reports/views.py:202 +#: .\views.py:222 msgid "User" msgstr "" -#: reports/views.py:222 +#: .\views.py:245 msgid "Number of help posts created by the user." msgstr "Número de postagens de dúvidas criadas no mural da disciplina." -#: reports/views.py:228 +#: .\views.py:251 msgid "Amount of comments on help posts created by the student." msgstr "" "Número de comentários criados para as próprias postagens de dúvidas no mural " "da disciplina." -#: reports/views.py:233 +#: .\views.py:256 msgid "Amount of comments made by the student on teachers help posts." msgstr "" "Número de comentários às postagens de dúvidas no mural da disciplina criadas " "pelo professor." -#: reports/views.py:237 +#: .\views.py:260 msgid "Amount of comments made by the student on other students help posts." msgstr "" "Número de comentários às postagens de dúvidas no mural da disciplina criadas " "por outros estudantes." -#: reports/views.py:248 +#: .\views.py:271 msgid "Number of help posts created by the user that the teacher commented on." msgstr "" "Número de comentários às postagens de dúvidas no mural da disciplina criadas " "por outros estudantes" -#: reports/views.py:256 +#: .\views.py:279 msgid "Number of help posts created by the user others students commented on." msgstr "" " Número de postagens de dúvidas criadas no mural da disciplina que foram " "comentadas por outros estudantes." -#: reports/views.py:259 +#: .\views.py:282 msgid "Number of student visualizations on the mural of the subject." msgstr "Número de visualizações do mural da disciplina." -#: reports/views.py:271 +#: .\views.py:303 msgid "Number of access to mural between 6 a.m to 12a.m. ." msgstr "" "Número de acessos ao ambiente virtual da disciplina no horário de 06h às 12h." -#: reports/views.py:275 +#: .\views.py:307 msgid "Number of access to mural between 0 p.m to 6p.m. ." msgstr "" "Número de acessos ao ambiente virtual da disciplina no horário de 12h às 18h." -#: reports/views.py:278 +#: .\views.py:310 msgid "Number of access to mural between 6 p.m to 12p.m. ." msgstr "" "Número de acessos ao ambiente virtual da disciplina no horário de 18h às 24h." -#: reports/views.py:282 +#: .\views.py:314 msgid "Number of access to mural between 0 a.m to 6a.m. ." msgstr "" "Número de acessos ao ambiente virtual da disciplina no horário de 24h às 06h." -#: reports/views.py:287 +#: .\views.py:319 msgid "sunday" msgstr "domingo" -#: reports/views.py:287 +#: .\views.py:319 msgid "monday" msgstr "segunda" -#: reports/views.py:287 +#: .\views.py:319 msgid "tuesday" msgstr "terça-feira" -#: reports/views.py:287 +#: .\views.py:319 msgid "wednesday" msgstr "quarta" -#: reports/views.py:287 +#: .\views.py:319 msgid "thursday" msgstr "quinta-feira" -#: reports/views.py:288 +#: .\views.py:320 msgid "friday" msgstr "sexta" -#: reports/views.py:288 +#: .\views.py:320 msgid "saturday" msgstr "sábado" -#: reports/views.py:292 reports/views.py:295 +#: .\views.py:324 .\views.py:327 msgid "Number of access to the subject on " msgstr "Número de acessos ao assunto na(o) " -#: reports/views.py:298 +#: .\views.py:330 msgid "Number of distinct days the user access the subject. " msgstr "Número de dias distintos que acessou o ambiente virtual da disciplina." -#: reports/views.py:299 +#: .\views.py:331 msgid "Class" msgstr "Classe" -#: reports/views.py:299 reports/views.py:300 +#: .\views.py:331 .\views.py:332 msgid "Undefined" msgstr "Indefinido" -#: reports/views.py:300 +#: .\views.py:332 msgid "Performance" msgstr "Desempenho" -#: reports/views.py:448 reports/views.py:498 +#: .\views.py:482 .\views.py:583 msgid "PDF File" msgstr "" -#: reports/views.py:449 reports/views.py:499 +#: .\views.py:483 .\views.py:584 #, fuzzy #| msgid "Topics" msgid "Topic Goals" msgstr "Tópicos" -#: reports/views.py:450 reports/views.py:500 +#: .\views.py:484 .\views.py:585 msgid "Link to Website" msgstr "" -#: reports/views.py:451 reports/views.py:501 +#: .\views.py:485 .\views.py:586 msgid "File Link" msgstr "" -#: reports/views.py:452 reports/views.py:502 +#: .\views.py:486 .\views.py:587 msgid "Web Conference" msgstr "" -#: reports/views.py:453 reports/views.py:503 +#: .\views.py:487 .\views.py:588 msgid "YouTube Video" msgstr "" -#: reports/views.py:454 reports/views.py:504 +#: .\views.py:488 .\views.py:589 msgid "WebPage" msgstr "" -#: reports/views.py:456 reports/views.py:463 +#: .\views.py:490 .\views.py:497 msgid "number of visualizations of " msgstr "Número de visualizações do(e) " -#: reports/views.py:456 reports/views.py:457 reports/views.py:458 -#: reports/views.py:461 +#: .\views.py:490 .\views.py:491 .\views.py:492 .\views.py:495 msgid " with tag " msgstr " com a tag " -#: reports/views.py:457 reports/views.py:464 +#: .\views.py:491 .\views.py:498 msgid "number of visualizations of distintic " msgstr "Número de visualizações dos distintos " -#: reports/views.py:458 reports/views.py:465 +#: .\views.py:492 .\views.py:499 msgid "distintic days " msgstr "número de dias distintos " -#: reports/views.py:461 reports/views.py:468 +#: .\views.py:495 .\views.py:502 msgid "hours viewed of " msgstr "quantidade de horas vistas " +#: .\views.py:522 .\views.py:523 .\views.py:525 +msgid " amount of messages sent to other students" +msgstr " quantidade mensagens enviadas para outros estudantes" + +#: .\views.py:527 .\views.py:528 .\views.py:531 +msgid "amount of messages received from other students" +msgstr "quantidade de mensagens recebidas de outros estudantes" + +#: .\views.py:537 +msgid "amount of distinct students to whom sent messages" +msgstr "quantidade de estudantes distintos para quem enviou mensagem" + +#: .\views.py:546 .\views.py:547 .\views.py:549 +msgid "amount messages sent to professors" +msgstr "quantidade mensagens enviadas para o(s) professor(es)" + +#: .\views.py:551 .\views.py:552 .\views.py:554 +msgid "amount of messages received from professors" +msgstr "quantidade de mensagens recebidas do(s) professor(es)" + +#~ msgid " amount messages sent to other students" +#~ msgstr " número de mensagens enviadas para outros estudantes" + +#~ msgid " amount of messages sent to others students" +#~ msgstr " número de mensagens enviadas para outros estudantes" + #~ msgid "distintic " #~ msgstr "distintos " diff --git a/reports/tests.py b/reports/tests.py index 7ce503c..0fabb9f 100644 --- a/reports/tests.py +++ b/reports/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - -# Create your tests here. +from django.test import TestCase \ No newline at end of file diff --git a/reports/tests/test_report_auth.py b/reports/tests/test_report_auth.py index c3db2cb..ceed176 100644 --- a/reports/tests/test_report_auth.py +++ b/reports/tests/test_report_auth.py @@ -3,8 +3,12 @@ from django.core.urlresolvers import resolve from reports.views import ReportView from subjects.models import Subject from users.models import User - +from topics.models import Topic +from chat.models import Conversation, TalkMessages from datetime import datetime +from log.models import Log +from django.db.models import Q + class ReportTest(TestCase): @@ -42,4 +46,29 @@ class ReportTest(TestCase): report_view = self.c.get('/subjects/report/create/interactions/?subject_id='+ str(self.subject.id)) self.assertEqual(report_view.url, "/subjects/home/") - \ No newline at end of file + + + @override_settings(STATICFILES_STORAGE = None) + def test_message_data_from_view(self): + """ + test if I'm capturing the message data correctly in all scenarios + """ + + #scenario 01: the number of messages a student receives from other students + topic = Topic.objects.create(name="novo topico", subject= self.subject, visible = True) + topic.save() + student02 = User.objects.create(username="student02", email= "student02@gmail.com", password="amadeus") + student02.save() + conversation_01 = Conversation.objects.create(user_one = self.student, user_two = student02) + + #building messages + message01 = TalkMessages(text="hi", talk = conversation_01, subject = self.subject, user = self.student) + message01.save() + message02 = TalkMessages(text="hello, how are you?", talk = conversation_01, subject = self.subject, user = student02) + message02.save() + #get all conversations where a student of the subject is in and the amount of messages the hey sent to other students + conversations = Conversation.objects.filter(Q(user_one = self.student) | Q(user_two = self.student) ) + + amount_of_messages = TalkMessages.objects.filter(talk__in= conversations).count() + print(amount_of_messages) + self.assertEqual(3,3) \ No newline at end of file diff --git a/reports/views.py b/reports/views.py index 9ceafd2..eaee0b8 100644 --- a/reports/views.py +++ b/reports/views.py @@ -26,6 +26,9 @@ import os import copy from django.shortcuts import render, get_object_or_404, redirect +from chat.models import Conversation, TalkMessages + + from amadeus.permissions import has_category_permissions, has_subject_permissions class ReportView(LoginRequiredMixin, generic.FormView): @@ -146,15 +149,17 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): context['init_date'] = params_data['init_date'] context['end_date'] = params_data['end_date'] context['subject'] = subject + #I used getlist method so it can get more than one tag and one resource class_name resources = params_data.getlist('resource') tags = params_data.getlist('tag') self.from_mural = params_data['from_mural'] - + self.from_messages = params_data['from_messages'] + context['data'], context['header'] = self.get_mural_data(subject, params_data['topic'], params_data['init_date'], params_data['end_date'], - resources, tags ) + resources, tags ) #this is to save the csv for further download @@ -226,8 +231,11 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): data[student.id].append(student.social_name) - interactions = OrderedDict() - + interactions = OrderedDict() + + + + #interactions['username'] = student.social_name if self.from_mural == "True": help_posts_made_by_user = SubjectPost.objects.filter(action="help",space__id=subject.id, user=student, @@ -275,6 +283,15 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): user = student).count() + #variables from messages + + + if self.from_messages == "True": + + message_data = self.get_messages_data(subject, student) + for key, value in message_data.items(): + interactions[key] = value + #VAR08 through VAR_019 of documenttation: if len(resources_type_names) > 0: resources_data = self.get_resources_and_tags_data(resources_type_names, tags_id, student, subject, topics, init_date, end_date) @@ -376,7 +393,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): for resource in resources: if isinstance(topics,Topic): - #or it selected only one topic to work with + #if it selected only one topic to work with count = Log.objects.filter(action="view", resource=resources_types[i].lower(), user_id = student.id, context__contains = {'subject_id': subject.id, resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__range=(init_date, end_date)).count() @@ -452,6 +469,8 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): time_delta = math.fabs(end_time - begin_time) hours_viewed += time_delta/3600 #so it's turned this seconds into hours + + if count > 0: distinct_resources += 1 total_count += count @@ -484,15 +503,66 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): return data + def get_messages_data(self, subject, student): + data = OrderedDict() + + + + messages_sent_to_other_students = 0 + + distinct_students = 0 + + for other_student in subject.students.exclude(id = student.id): + conversations_with_other = Conversation.objects.filter(Q(user_one=student) & Q(user_two = other_student) | Q(user_one = other_student) & Q(user_two = student) ) + messages_sent_other = TalkMessages.objects.filter(talk__in = conversations_with_other, user = student , subject= subject) + messages_received_other = TalkMessages.objects.filter(talk__in = conversations_with_other, user = other_student, subject = subject) + + + + if data.get(_(" amount of messages sent to other students")): + data[_(" amount of messages sent to other students")] = messages_sent_other.count() + data.get(_(" amount of messages sent to other students")) + else: + data[_(" amount of messages sent to other students")] = messages_sent_other.count() + + if data.get(_("amount of messages received from other students")): + data[_("amount of messages received from other students")] = messages_received_other.count() + data.get(_("amount of messages received from other students")) + else: + + data[_("amount of messages received from other students")] = messages_received_other.count() + + #check whether the other started a conversation or not + if messages_sent_other.count() >0: + distinct_students += 1 + + data[_("amount of distinct students to whom sent messages")] = distinct_students + #calculate the amount of messages sent to and received from professor + messages_sent_professors = 0 + messages_received_professors = 0 + for professor in subject.professor.all(): + conversations_with_professor = Conversation.objects.filter(Q(user_one = student) & Q(user_two = professor) | Q(user_one = professor) & Q(user_two = student)) + messages_sent_to_professors = TalkMessages.objects.filter(talk__in = conversations_with_professor, user = student, subject = subject) + + messages_received_from_professors = TalkMessages.objects.filter(talk__in = conversations_with_professor, user = professor, subject = subject) + if data.get(_("amount messages sent to professors")): + data[_("amount messages sent to professors")] = messages_sent_to_professors.count() + data.get(_("amount messages sent to professors")) + else: + data[_("amount messages sent to professors")] = messages_sent_to_professors.count() + + if data.get(_("amount of messages received from professors")): + data[_("amount of messages received from professors")] = messages_received_from_professors.count() + data.get(_("amount of messages received from professors")) + else: + data[_("amount of messages received from professors")] = messages_received_from_professors.count() + + + return data + """ Get all possible resource subclasses available for that topic selected """ def get_resources(request): - #get all possible resources - classes = Resource.__subclasses__() - data = {} + #get all possible resources subject = Subject.objects.get(id=request.GET['subject_id']) topic_choice = request.GET["topic_choice"] -- libgit2 0.21.2