Commit a0d43118a67c85ecb9f77ed11d8f4a6489b8fb5f

Authored by Felipe Bormann
1 parent 9727e86c

finished messages variables in report view and translation, started tests for such functionality

reports/locale/pt_BR/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid "" @@ -8,7 +8,7 @@ msgid ""
8 msgstr "" 8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n" 9 "Project-Id-Version: PACKAGE VERSION\n"
10 "Report-Msgid-Bugs-To: \n" 10 "Report-Msgid-Bugs-To: \n"
11 -"POT-Creation-Date: 2017-04-15 00:13-0300\n" 11 +"POT-Creation-Date: 2017-04-29 21:14-0300\n"
12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14 "Language-Team: LANGUAGE <LL@li.org>\n" 14 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,287 +18,308 @@ msgstr &quot;&quot; @@ -18,287 +18,308 @@ msgstr &quot;&quot;
18 "Content-Transfer-Encoding: 8bit\n" 18 "Content-Transfer-Encoding: 8bit\n"
19 "Plural-Forms: nplurals=2; plural=(n > 1);\n" 19 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
20 20
21 -#: reports/forms.py:23 21 +#: .\forms.py:23
22 msgid "Kind Of Resource" 22 msgid "Kind Of Resource"
23 msgstr "Tipo de recurso" 23 msgstr "Tipo de recurso"
24 24
25 -#: reports/forms.py:24 25 +#: .\forms.py:24
26 msgid "Tag" 26 msgid "Tag"
27 msgstr "Tag" 27 msgstr "Tag"
28 28
29 -#: reports/forms.py:35 29 +#: .\forms.py:35
30 msgid "Topics" 30 msgid "Topics"
31 msgstr "Tópicos" 31 msgstr "Tópicos"
32 32
33 -#: reports/forms.py:36 reports/templates/reports/view.html:58 33 +#: .\forms.py:36 .\templates\reports\view.html:58
34 msgid "Initial Date" 34 msgid "Initial Date"
35 msgstr "Data inicial" 35 msgstr "Data inicial"
36 36
37 -#: reports/forms.py:37 37 +#: .\forms.py:37
38 msgid "Final Date" 38 msgid "Final Date"
39 msgstr "Data Final" 39 msgstr "Data Final"
40 40
41 -#: reports/forms.py:39 41 +#: .\forms.py:39
42 msgid "From Mural" 42 msgid "From Mural"
43 msgstr "Mural da disciplina" 43 msgstr "Mural da disciplina"
44 44
45 -#: reports/forms.py:40 45 +#: .\forms.py:40
46 msgid "Messages" 46 msgid "Messages"
47 msgstr "Mensagens" 47 msgstr "Mensagens"
48 48
49 -#: reports/forms.py:51 reports/views.py:127 reports/views.py:198 49 +#: .\forms.py:51 .\views.py:145 .\views.py:218
50 msgid "All" 50 msgid "All"
51 msgstr "Todos" 51 msgstr "Todos"
52 52
53 -#: reports/forms.py:60 53 +#: .\forms.py:60
54 msgid "The initial date can't be after the end one." 54 msgid "The initial date can't be after the end one."
55 msgstr "A data inicial não pode ser depois da final" 55 msgstr "A data inicial não pode ser depois da final"
56 56
57 -#: reports/forms.py:65 57 +#: .\forms.py:65
58 msgid "This date should be right or after " 58 msgid "This date should be right or after "
59 msgstr "Esta data deve ser igual ou após" 59 msgstr "Esta data deve ser igual ou após"
60 60
61 -#: reports/forms.py:71 61 +#: .\forms.py:71
62 msgid "This date should be right or before " 62 msgid "This date should be right or before "
63 msgstr "Esta data deve ser igual ou anterior à" 63 msgstr "Esta data deve ser igual ou anterior à"
64 64
65 -#: reports/templates/reports/_form.html:19 65 +#: .\templates\reports\_form.html:19
66 msgid "General Parameters" 66 msgid "General Parameters"
67 msgstr "Escolha o Tópico e o Período" 67 msgstr "Escolha o Tópico e o Período"
68 68
69 -#: reports/templates/reports/_form.html:37 69 +#: .\templates\reports\_form.html:37
70 msgid "Choose the Data Source (is possible to pick more than one)" 70 msgid "Choose the Data Source (is possible to pick more than one)"
71 msgstr "Escolha a fonte de dados (é possível escolher mais de uma)" 71 msgstr "Escolha a fonte de dados (é possível escolher mais de uma)"
72 72
73 -#: reports/templates/reports/_form.html:62 73 +#: .\templates\reports\_form.html:62
74 msgid "Interaction with resources" 74 msgid "Interaction with resources"
75 msgstr "Interação com recursos" 75 msgstr "Interação com recursos"
76 76
77 -#: reports/templates/reports/_form.html:97 77 +#: .\templates\reports\_form.html:97
78 msgid "Search Report" 78 msgid "Search Report"
79 msgstr "Buscar" 79 msgstr "Buscar"
80 80
81 -#: reports/templates/reports/create.html:27  
82 -#: reports/templates/reports/view.html:33 81 +#: .\templates\reports\create.html:27 .\templates\reports\view.html:33
83 msgid "Analytics" 82 msgid "Analytics"
84 msgstr "" 83 msgstr ""
85 84
86 -#: reports/templates/reports/create.html:37  
87 -#: reports/templates/reports/view.html:43 85 +#: .\templates\reports\create.html:36 .\templates\reports\view.html:43
88 msgid "Interaction Data" 86 msgid "Interaction Data"
89 msgstr "Dados de Interação" 87 msgstr "Dados de Interação"
90 88
91 -#: reports/templates/reports/create.html:40  
92 -#: reports/templates/reports/view.html:46 89 +#: .\templates\reports\create.html:39 .\templates\reports\view.html:46
93 msgid "Report Card" 90 msgid "Report Card"
94 msgstr "Boletim do Tópico" 91 msgstr "Boletim do Tópico"
95 92
96 -#: reports/templates/reports/create.html:43  
97 -#: reports/templates/reports/view.html:49 93 +#: .\templates\reports\create.html:42 .\templates\reports\view.html:49
98 msgid "Participation" 94 msgid "Participation"
99 msgstr "Participações" 95 msgstr "Participações"
100 96
101 -#: reports/templates/reports/create.html:55 97 +#: .\templates\reports\create.html:55
102 msgid "add data source" 98 msgid "add data source"
103 msgstr "Adicionar nova fonte de dados" 99 msgstr "Adicionar nova fonte de dados"
104 100
105 -#: reports/templates/reports/create.html:56 101 +#: .\templates\reports\create.html:56
106 msgid "remove data source" 102 msgid "remove data source"
107 msgstr "Remover esta fonte" 103 msgstr "Remover esta fonte"
108 104
109 -#: reports/templates/reports/view.html:56 105 +#: .\templates\reports\view.html:56
110 msgid "Subject" 106 msgid "Subject"
111 msgstr "Assunto" 107 msgstr "Assunto"
112 108
113 -#: reports/templates/reports/view.html:57 109 +#: .\templates\reports\view.html:57
114 msgid "Topic" 110 msgid "Topic"
115 msgstr "Tópico" 111 msgstr "Tópico"
116 112
117 -#: reports/templates/reports/view.html:59 113 +#: .\templates\reports\view.html:59
118 msgid "End Date" 114 msgid "End Date"
119 msgstr "Data final" 115 msgstr "Data final"
120 116
121 -#: reports/templates/reports/view.html:60 117 +#: .\templates\reports\view.html:60
122 msgid "new search" 118 msgid "new search"
123 msgstr "Nova Busca" 119 msgstr "Nova Busca"
124 120
125 -#: reports/templates/reports/view.html:66 121 +#: .\templates\reports\view.html:66
126 msgid "register(s)" 122 msgid "register(s)"
127 msgstr "registro(s)" 123 msgstr "registro(s)"
128 124
129 -#: reports/templates/reports/view.html:68 125 +#: .\templates\reports\view.html:68
130 msgid "Interactions Data (.csv)" 126 msgid "Interactions Data (.csv)"
131 msgstr "Dados de interação (.csv)" 127 msgstr "Dados de interação (.csv)"
132 128
133 -#: reports/templates/reports/view.html:72 129 +#: .\templates\reports\view.html:72
134 msgid "Interactions Data (.xls)" 130 msgid "Interactions Data (.xls)"
135 msgstr "Dados de interação (.xls)" 131 msgstr "Dados de interação (.xls)"
136 132
137 -#: reports/views.py:60 133 +#: .\views.py:78
138 msgid "Report created successfully" 134 msgid "Report created successfully"
139 msgstr "Relatório criado com sucesso!" 135 msgstr "Relatório criado com sucesso!"
140 136
141 -#: reports/views.py:202 137 +#: .\views.py:222
142 msgid "User" 138 msgid "User"
143 msgstr "" 139 msgstr ""
144 140
145 -#: reports/views.py:222 141 +#: .\views.py:245
146 msgid "Number of help posts created by the user." 142 msgid "Number of help posts created by the user."
147 msgstr "Número de postagens de dúvidas criadas no mural da disciplina." 143 msgstr "Número de postagens de dúvidas criadas no mural da disciplina."
148 144
149 -#: reports/views.py:228 145 +#: .\views.py:251
150 msgid "Amount of comments on help posts created by the student." 146 msgid "Amount of comments on help posts created by the student."
151 msgstr "" 147 msgstr ""
152 "Número de comentários criados para as próprias postagens de dúvidas no mural " 148 "Número de comentários criados para as próprias postagens de dúvidas no mural "
153 "da disciplina." 149 "da disciplina."
154 150
155 -#: reports/views.py:233 151 +#: .\views.py:256
156 msgid "Amount of comments made by the student on teachers help posts." 152 msgid "Amount of comments made by the student on teachers help posts."
157 msgstr "" 153 msgstr ""
158 "Número de comentários às postagens de dúvidas no mural da disciplina criadas " 154 "Número de comentários às postagens de dúvidas no mural da disciplina criadas "
159 "pelo professor." 155 "pelo professor."
160 156
161 -#: reports/views.py:237 157 +#: .\views.py:260
162 msgid "Amount of comments made by the student on other students help posts." 158 msgid "Amount of comments made by the student on other students help posts."
163 msgstr "" 159 msgstr ""
164 "Número de comentários às postagens de dúvidas no mural da disciplina criadas " 160 "Número de comentários às postagens de dúvidas no mural da disciplina criadas "
165 "por outros estudantes." 161 "por outros estudantes."
166 162
167 -#: reports/views.py:248 163 +#: .\views.py:271
168 msgid "Number of help posts created by the user that the teacher commented on." 164 msgid "Number of help posts created by the user that the teacher commented on."
169 msgstr "" 165 msgstr ""
170 "Número de comentários às postagens de dúvidas no mural da disciplina criadas " 166 "Número de comentários às postagens de dúvidas no mural da disciplina criadas "
171 "por outros estudantes" 167 "por outros estudantes"
172 168
173 -#: reports/views.py:256 169 +#: .\views.py:279
174 msgid "Number of help posts created by the user others students commented on." 170 msgid "Number of help posts created by the user others students commented on."
175 msgstr "" 171 msgstr ""
176 " Número de postagens de dúvidas criadas no mural da disciplina que foram " 172 " Número de postagens de dúvidas criadas no mural da disciplina que foram "
177 "comentadas por outros estudantes." 173 "comentadas por outros estudantes."
178 174
179 -#: reports/views.py:259 175 +#: .\views.py:282
180 msgid "Number of student visualizations on the mural of the subject." 176 msgid "Number of student visualizations on the mural of the subject."
181 msgstr "Número de visualizações do mural da disciplina." 177 msgstr "Número de visualizações do mural da disciplina."
182 178
183 -#: reports/views.py:271 179 +#: .\views.py:303
184 msgid "Number of access to mural between 6 a.m to 12a.m. ." 180 msgid "Number of access to mural between 6 a.m to 12a.m. ."
185 msgstr "" 181 msgstr ""
186 "Número de acessos ao ambiente virtual da disciplina no horário de 06h às 12h." 182 "Número de acessos ao ambiente virtual da disciplina no horário de 06h às 12h."
187 183
188 -#: reports/views.py:275 184 +#: .\views.py:307
189 msgid "Number of access to mural between 0 p.m to 6p.m. ." 185 msgid "Number of access to mural between 0 p.m to 6p.m. ."
190 msgstr "" 186 msgstr ""
191 "Número de acessos ao ambiente virtual da disciplina no horário de 12h às 18h." 187 "Número de acessos ao ambiente virtual da disciplina no horário de 12h às 18h."
192 188
193 -#: reports/views.py:278 189 +#: .\views.py:310
194 msgid "Number of access to mural between 6 p.m to 12p.m. ." 190 msgid "Number of access to mural between 6 p.m to 12p.m. ."
195 msgstr "" 191 msgstr ""
196 "Número de acessos ao ambiente virtual da disciplina no horário de 18h às 24h." 192 "Número de acessos ao ambiente virtual da disciplina no horário de 18h às 24h."
197 193
198 -#: reports/views.py:282 194 +#: .\views.py:314
199 msgid "Number of access to mural between 0 a.m to 6a.m. ." 195 msgid "Number of access to mural between 0 a.m to 6a.m. ."
200 msgstr "" 196 msgstr ""
201 "Número de acessos ao ambiente virtual da disciplina no horário de 24h às 06h." 197 "Número de acessos ao ambiente virtual da disciplina no horário de 24h às 06h."
202 198
203 -#: reports/views.py:287 199 +#: .\views.py:319
204 msgid "sunday" 200 msgid "sunday"
205 msgstr "domingo" 201 msgstr "domingo"
206 202
207 -#: reports/views.py:287 203 +#: .\views.py:319
208 msgid "monday" 204 msgid "monday"
209 msgstr "segunda" 205 msgstr "segunda"
210 206
211 -#: reports/views.py:287 207 +#: .\views.py:319
212 msgid "tuesday" 208 msgid "tuesday"
213 msgstr "terça-feira" 209 msgstr "terça-feira"
214 210
215 -#: reports/views.py:287 211 +#: .\views.py:319
216 msgid "wednesday" 212 msgid "wednesday"
217 msgstr "quarta" 213 msgstr "quarta"
218 214
219 -#: reports/views.py:287 215 +#: .\views.py:319
220 msgid "thursday" 216 msgid "thursday"
221 msgstr "quinta-feira" 217 msgstr "quinta-feira"
222 218
223 -#: reports/views.py:288 219 +#: .\views.py:320
224 msgid "friday" 220 msgid "friday"
225 msgstr "sexta" 221 msgstr "sexta"
226 222
227 -#: reports/views.py:288 223 +#: .\views.py:320
228 msgid "saturday" 224 msgid "saturday"
229 msgstr "sábado" 225 msgstr "sábado"
230 226
231 -#: reports/views.py:292 reports/views.py:295 227 +#: .\views.py:324 .\views.py:327
232 msgid "Number of access to the subject on " 228 msgid "Number of access to the subject on "
233 msgstr "Número de acessos ao assunto na(o) " 229 msgstr "Número de acessos ao assunto na(o) "
234 230
235 -#: reports/views.py:298 231 +#: .\views.py:330
236 msgid "Number of distinct days the user access the subject. " 232 msgid "Number of distinct days the user access the subject. "
237 msgstr "Número de dias distintos que acessou o ambiente virtual da disciplina." 233 msgstr "Número de dias distintos que acessou o ambiente virtual da disciplina."
238 234
239 -#: reports/views.py:299 235 +#: .\views.py:331
240 msgid "Class" 236 msgid "Class"
241 msgstr "Classe" 237 msgstr "Classe"
242 238
243 -#: reports/views.py:299 reports/views.py:300 239 +#: .\views.py:331 .\views.py:332
244 msgid "Undefined" 240 msgid "Undefined"
245 msgstr "Indefinido" 241 msgstr "Indefinido"
246 242
247 -#: reports/views.py:300 243 +#: .\views.py:332
248 msgid "Performance" 244 msgid "Performance"
249 msgstr "Desempenho" 245 msgstr "Desempenho"
250 246
251 -#: reports/views.py:448 reports/views.py:498 247 +#: .\views.py:482 .\views.py:583
252 msgid "PDF File" 248 msgid "PDF File"
253 msgstr "" 249 msgstr ""
254 250
255 -#: reports/views.py:449 reports/views.py:499 251 +#: .\views.py:483 .\views.py:584
256 #, fuzzy 252 #, fuzzy
257 #| msgid "Topics" 253 #| msgid "Topics"
258 msgid "Topic Goals" 254 msgid "Topic Goals"
259 msgstr "Tópicos" 255 msgstr "Tópicos"
260 256
261 -#: reports/views.py:450 reports/views.py:500 257 +#: .\views.py:484 .\views.py:585
262 msgid "Link to Website" 258 msgid "Link to Website"
263 msgstr "" 259 msgstr ""
264 260
265 -#: reports/views.py:451 reports/views.py:501 261 +#: .\views.py:485 .\views.py:586
266 msgid "File Link" 262 msgid "File Link"
267 msgstr "" 263 msgstr ""
268 264
269 -#: reports/views.py:452 reports/views.py:502 265 +#: .\views.py:486 .\views.py:587
270 msgid "Web Conference" 266 msgid "Web Conference"
271 msgstr "" 267 msgstr ""
272 268
273 -#: reports/views.py:453 reports/views.py:503 269 +#: .\views.py:487 .\views.py:588
274 msgid "YouTube Video" 270 msgid "YouTube Video"
275 msgstr "" 271 msgstr ""
276 272
277 -#: reports/views.py:454 reports/views.py:504 273 +#: .\views.py:488 .\views.py:589
278 msgid "WebPage" 274 msgid "WebPage"
279 msgstr "" 275 msgstr ""
280 276
281 -#: reports/views.py:456 reports/views.py:463 277 +#: .\views.py:490 .\views.py:497
282 msgid "number of visualizations of " 278 msgid "number of visualizations of "
283 msgstr "Número de visualizações do(e) " 279 msgstr "Número de visualizações do(e) "
284 280
285 -#: reports/views.py:456 reports/views.py:457 reports/views.py:458  
286 -#: reports/views.py:461 281 +#: .\views.py:490 .\views.py:491 .\views.py:492 .\views.py:495
287 msgid " with tag " 282 msgid " with tag "
288 msgstr " com a tag " 283 msgstr " com a tag "
289 284
290 -#: reports/views.py:457 reports/views.py:464 285 +#: .\views.py:491 .\views.py:498
291 msgid "number of visualizations of distintic " 286 msgid "number of visualizations of distintic "
292 msgstr "Número de visualizações dos distintos " 287 msgstr "Número de visualizações dos distintos "
293 288
294 -#: reports/views.py:458 reports/views.py:465 289 +#: .\views.py:492 .\views.py:499
295 msgid "distintic days " 290 msgid "distintic days "
296 msgstr "número de dias distintos " 291 msgstr "número de dias distintos "
297 292
298 -#: reports/views.py:461 reports/views.py:468 293 +#: .\views.py:495 .\views.py:502
299 msgid "hours viewed of " 294 msgid "hours viewed of "
300 msgstr "quantidade de horas vistas " 295 msgstr "quantidade de horas vistas "
301 296
  297 +#: .\views.py:522 .\views.py:523 .\views.py:525
  298 +msgid " amount of messages sent to other students"
  299 +msgstr " quantidade mensagens enviadas para outros estudantes"
  300 +
  301 +#: .\views.py:527 .\views.py:528 .\views.py:531
  302 +msgid "amount of messages received from other students"
  303 +msgstr "quantidade de mensagens recebidas de outros estudantes"
  304 +
  305 +#: .\views.py:537
  306 +msgid "amount of distinct students to whom sent messages"
  307 +msgstr "quantidade de estudantes distintos para quem enviou mensagem"
  308 +
  309 +#: .\views.py:546 .\views.py:547 .\views.py:549
  310 +msgid "amount messages sent to professors"
  311 +msgstr "quantidade mensagens enviadas para o(s) professor(es)"
  312 +
  313 +#: .\views.py:551 .\views.py:552 .\views.py:554
  314 +msgid "amount of messages received from professors"
  315 +msgstr "quantidade de mensagens recebidas do(s) professor(es)"
  316 +
  317 +#~ msgid " amount messages sent to other students"
  318 +#~ msgstr " número de mensagens enviadas para outros estudantes"
  319 +
  320 +#~ msgid " amount of messages sent to others students"
  321 +#~ msgstr " número de mensagens enviadas para outros estudantes"
  322 +
302 #~ msgid "distintic " 323 #~ msgid "distintic "
303 #~ msgstr "distintos " 324 #~ msgstr "distintos "
304 325
reports/tests.py
1 -from django.test import TestCase  
2 -  
3 -# Create your tests here. 1 +from django.test import TestCase
4 \ No newline at end of file 2 \ No newline at end of file
reports/tests/test_report_auth.py
@@ -3,8 +3,12 @@ from django.core.urlresolvers import resolve @@ -3,8 +3,12 @@ from django.core.urlresolvers import resolve
3 from reports.views import ReportView 3 from reports.views import ReportView
4 from subjects.models import Subject 4 from subjects.models import Subject
5 from users.models import User 5 from users.models import User
6 - 6 +from topics.models import Topic
  7 +from chat.models import Conversation, TalkMessages
7 from datetime import datetime 8 from datetime import datetime
  9 +from log.models import Log
  10 +from django.db.models import Q
  11 +
8 12
9 class ReportTest(TestCase): 13 class ReportTest(TestCase):
10 14
@@ -42,4 +46,29 @@ class ReportTest(TestCase): @@ -42,4 +46,29 @@ class ReportTest(TestCase):
42 report_view = self.c.get('/subjects/report/create/interactions/?subject_id='+ str(self.subject.id)) 46 report_view = self.c.get('/subjects/report/create/interactions/?subject_id='+ str(self.subject.id))
43 47
44 self.assertEqual(report_view.url, "/subjects/home/") 48 self.assertEqual(report_view.url, "/subjects/home/")
45 -  
46 \ No newline at end of file 49 \ No newline at end of file
  50 +
  51 +
  52 + @override_settings(STATICFILES_STORAGE = None)
  53 + def test_message_data_from_view(self):
  54 + """
  55 + test if I'm capturing the message data correctly in all scenarios
  56 + """
  57 +
  58 + #scenario 01: the number of messages a student receives from other students
  59 + topic = Topic.objects.create(name="novo topico", subject= self.subject, visible = True)
  60 + topic.save()
  61 + student02 = User.objects.create(username="student02", email= "student02@gmail.com", password="amadeus")
  62 + student02.save()
  63 + conversation_01 = Conversation.objects.create(user_one = self.student, user_two = student02)
  64 +
  65 + #building messages
  66 + message01 = TalkMessages(text="hi", talk = conversation_01, subject = self.subject, user = self.student)
  67 + message01.save()
  68 + message02 = TalkMessages(text="hello, how are you?", talk = conversation_01, subject = self.subject, user = student02)
  69 + message02.save()
  70 + #get all conversations where a student of the subject is in and the amount of messages the hey sent to other students
  71 + conversations = Conversation.objects.filter(Q(user_one = self.student) | Q(user_two = self.student) )
  72 +
  73 + amount_of_messages = TalkMessages.objects.filter(talk__in= conversations).count()
  74 + print(amount_of_messages)
  75 + self.assertEqual(3,3)
47 \ No newline at end of file 76 \ No newline at end of file
reports/views.py
@@ -26,6 +26,9 @@ import os @@ -26,6 +26,9 @@ import os
26 import copy 26 import copy
27 from django.shortcuts import render, get_object_or_404, redirect 27 from django.shortcuts import render, get_object_or_404, redirect
28 28
  29 +from chat.models import Conversation, TalkMessages
  30 +
  31 +
29 from amadeus.permissions import has_category_permissions, has_subject_permissions 32 from amadeus.permissions import has_category_permissions, has_subject_permissions
30 33
31 class ReportView(LoginRequiredMixin, generic.FormView): 34 class ReportView(LoginRequiredMixin, generic.FormView):
@@ -146,15 +149,17 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -146,15 +149,17 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
146 context['init_date'] = params_data['init_date'] 149 context['init_date'] = params_data['init_date']
147 context['end_date'] = params_data['end_date'] 150 context['end_date'] = params_data['end_date']
148 context['subject'] = subject 151 context['subject'] = subject
  152 +
149 153
150 #I used getlist method so it can get more than one tag and one resource class_name 154 #I used getlist method so it can get more than one tag and one resource class_name
151 resources = params_data.getlist('resource') 155 resources = params_data.getlist('resource')
152 tags = params_data.getlist('tag') 156 tags = params_data.getlist('tag')
153 157
154 self.from_mural = params_data['from_mural'] 158 self.from_mural = params_data['from_mural']
155 - 159 + self.from_messages = params_data['from_messages']
  160 +
156 context['data'], context['header'] = self.get_mural_data(subject, params_data['topic'], params_data['init_date'], params_data['end_date'], 161 context['data'], context['header'] = self.get_mural_data(subject, params_data['topic'], params_data['init_date'], params_data['end_date'],
157 - resources, tags ) 162 + resources, tags )
158 163
159 164
160 #this is to save the csv for further download 165 #this is to save the csv for further download
@@ -226,8 +231,11 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -226,8 +231,11 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
226 231
227 data[student.id].append(student.social_name) 232 data[student.id].append(student.social_name)
228 233
229 - interactions = OrderedDict()  
230 - 234 + interactions = OrderedDict()
  235 +
  236 +
  237 +
  238 +
231 #interactions['username'] = student.social_name 239 #interactions['username'] = student.social_name
232 if self.from_mural == "True": 240 if self.from_mural == "True":
233 help_posts_made_by_user = SubjectPost.objects.filter(action="help",space__id=subject.id, user=student, 241 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): @@ -275,6 +283,15 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
275 user = student).count() 283 user = student).count()
276 284
277 285
  286 + #variables from messages
  287 +
  288 +
  289 + if self.from_messages == "True":
  290 +
  291 + message_data = self.get_messages_data(subject, student)
  292 + for key, value in message_data.items():
  293 + interactions[key] = value
  294 +
278 #VAR08 through VAR_019 of documenttation: 295 #VAR08 through VAR_019 of documenttation:
279 if len(resources_type_names) > 0: 296 if len(resources_type_names) > 0:
280 resources_data = self.get_resources_and_tags_data(resources_type_names, tags_id, student, subject, topics, init_date, end_date) 297 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): @@ -376,7 +393,7 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
376 for resource in resources: 393 for resource in resources:
377 394
378 if isinstance(topics,Topic): 395 if isinstance(topics,Topic):
379 - #or it selected only one topic to work with 396 + #if it selected only one topic to work with
380 count = Log.objects.filter(action="view", resource=resources_types[i].lower(), 397 count = Log.objects.filter(action="view", resource=resources_types[i].lower(),
381 user_id = student.id, context__contains = {'subject_id': subject.id, 398 user_id = student.id, context__contains = {'subject_id': subject.id,
382 resources_types[i].lower()+'_id': resource.id, 'topic_id': topics.id}, datetime__range=(init_date, end_date)).count() 399 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): @@ -452,6 +469,8 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
452 time_delta = math.fabs(end_time - begin_time) 469 time_delta = math.fabs(end_time - begin_time)
453 470
454 hours_viewed += time_delta/3600 #so it's turned this seconds into hours 471 hours_viewed += time_delta/3600 #so it's turned this seconds into hours
  472 +
  473 +
455 if count > 0: 474 if count > 0:
456 distinct_resources += 1 475 distinct_resources += 1
457 total_count += count 476 total_count += count
@@ -484,15 +503,66 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView): @@ -484,15 +503,66 @@ class ViewReportView(LoginRequiredMixin, generic.TemplateView):
484 503
485 return data 504 return data
486 505
  506 + def get_messages_data(self, subject, student):
  507 + data = OrderedDict()
  508 +
  509 +
  510 +
  511 + messages_sent_to_other_students = 0
  512 +
  513 + distinct_students = 0
  514 +
  515 + for other_student in subject.students.exclude(id = student.id):
  516 + conversations_with_other = Conversation.objects.filter(Q(user_one=student) & Q(user_two = other_student) | Q(user_one = other_student) & Q(user_two = student) )
  517 + messages_sent_other = TalkMessages.objects.filter(talk__in = conversations_with_other, user = student , subject= subject)
  518 + messages_received_other = TalkMessages.objects.filter(talk__in = conversations_with_other, user = other_student, subject = subject)
  519 +
  520 +
  521 +
  522 + if data.get(_(" amount of messages sent to other students")):
  523 + data[_(" amount of messages sent to other students")] = messages_sent_other.count() + data.get(_(" amount of messages sent to other students"))
  524 + else:
  525 + data[_(" amount of messages sent to other students")] = messages_sent_other.count()
  526 +
  527 + if data.get(_("amount of messages received from other students")):
  528 + data[_("amount of messages received from other students")] = messages_received_other.count() + data.get(_("amount of messages received from other students"))
  529 + else:
  530 +
  531 + data[_("amount of messages received from other students")] = messages_received_other.count()
  532 +
  533 + #check whether the other started a conversation or not
  534 + if messages_sent_other.count() >0:
  535 + distinct_students += 1
  536 +
  537 + data[_("amount of distinct students to whom sent messages")] = distinct_students
  538 + #calculate the amount of messages sent to and received from professor
  539 + messages_sent_professors = 0
  540 + messages_received_professors = 0
  541 + for professor in subject.professor.all():
  542 + conversations_with_professor = Conversation.objects.filter(Q(user_one = student) & Q(user_two = professor) | Q(user_one = professor) & Q(user_two = student))
  543 + messages_sent_to_professors = TalkMessages.objects.filter(talk__in = conversations_with_professor, user = student, subject = subject)
  544 +
  545 + messages_received_from_professors = TalkMessages.objects.filter(talk__in = conversations_with_professor, user = professor, subject = subject)
  546 + if data.get(_("amount messages sent to professors")):
  547 + data[_("amount messages sent to professors")] = messages_sent_to_professors.count() + data.get(_("amount messages sent to professors"))
  548 + else:
  549 + data[_("amount messages sent to professors")] = messages_sent_to_professors.count()
  550 +
  551 + if data.get(_("amount of messages received from professors")):
  552 + data[_("amount of messages received from professors")] = messages_received_from_professors.count() + data.get(_("amount of messages received from professors"))
  553 + else:
  554 + data[_("amount of messages received from professors")] = messages_received_from_professors.count()
  555 +
  556 +
  557 + return data
  558 +
487 559
488 """ 560 """
489 Get all possible resource subclasses available for that topic selected 561 Get all possible resource subclasses available for that topic selected
490 """ 562 """
491 def get_resources(request): 563 def get_resources(request):
492 564
493 - #get all possible resources  
494 - classes = Resource.__subclasses__()  
495 - data = {} 565 + #get all possible resources
496 subject = Subject.objects.get(id=request.GET['subject_id']) 566 subject = Subject.objects.get(id=request.GET['subject_id'])
497 567
498 topic_choice = request.GET["topic_choice"] 568 topic_choice = request.GET["topic_choice"]