chartManD commited on
Commit
a012906
·
1 Parent(s): 598b817

Replanteamiento de tabla para primera repeticion de PF

Browse files
tecnicas/controllers/views_controller/session_management/details_pf_controller.py CHANGED
@@ -20,7 +20,6 @@ class DetallesPFController(DetallesController):
20
  self.context = {
21
  "sesion": self.session,
22
  "use_technique": technique,
23
- "calificaciones": [],
24
  "existen_calificaciones": False,
25
  "tipo_escala": technique.escala_tecnica.id_tipo_escala.nombre_escala,
26
  "valor_max": technique.escala_tecnica.longitud,
@@ -41,13 +40,18 @@ class DetallesPFController(DetallesController):
41
 
42
  if curren_repetition == 1:
43
  self.context["fisrt_phase"] = self.getDataFirstPhase()
 
 
44
  elif curren_repetition == 2:
45
  self.context["fisrt_phase"] = self.getDataFirstPhase()
46
  self.context["second_phase"] = self.getDataSecondPhase()
 
 
47
  elif curren_repetition >= 3:
48
  self.context["fisrt_phase"] = self.getDataFirstPhase()
49
  self.context["second_phase"] = self.getDataSecondPhase()
50
  self.context["data_ratings"] = self.getDataRatings()
 
51
 
52
  return self.context
53
 
@@ -106,10 +110,64 @@ class DetallesPFController(DetallesController):
106
  'username': username,
107
  'words': words
108
  })
109
-
110
  return result
111
 
112
  def getDataRatings(self):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  lists_words_testers = self.context["second_phase"]
114
  technique = self.session.tecnica
115
 
@@ -131,6 +189,7 @@ class DetallesPFController(DetallesController):
131
 
132
  ratings_for_repetition = defaultdict(lambda: defaultdict(list))
133
 
 
134
  for item in data:
135
  rep = item["repeticion"]
136
  prod = item["producto_code"]
@@ -138,7 +197,7 @@ class DetallesPFController(DetallesController):
138
  ratings_for_repetition[rep-2][prod].append({
139
  "nombre_palabra": item["nombre_palabra"],
140
  "dato_valor": item["dato_valor"]
141
- })
142
 
143
  ratings_for_tester.append(
144
  {
@@ -148,29 +207,5 @@ class DetallesPFController(DetallesController):
148
  "words": list_tester["words"]
149
  }
150
  )
151
- self.context["existen_calificaciones"] = True
152
 
153
- return ratings_for_tester
154
-
155
- def getStatus(self, rep: int, activate: bool):
156
- status = ""
157
-
158
- if rep == 0 and not activate:
159
- status = "Listo para crear listas iniciales"
160
-
161
- elif rep == 1 and activate:
162
- status = "En primera fase, creación de listas iniciales"
163
- elif rep == 1 and not activate:
164
- status = "Listo para crear listas finales"
165
-
166
- elif rep == 2 and activate:
167
- status = "En segunda fase, creación de listas finales"
168
- elif rep == 2 and not activate:
169
- status = "Listo para calificaciones"
170
-
171
- elif rep > 2 and not activate:
172
- status = "Listo para calificaciones"
173
- elif rep > 2 and activate:
174
- status = "Catadores calificando"
175
-
176
- return status
 
20
  self.context = {
21
  "sesion": self.session,
22
  "use_technique": technique,
 
23
  "existen_calificaciones": False,
24
  "tipo_escala": technique.escala_tecnica.id_tipo_escala.nombre_escala,
25
  "valor_max": technique.escala_tecnica.longitud,
 
40
 
41
  if curren_repetition == 1:
42
  self.context["fisrt_phase"] = self.getDataFirstPhase()
43
+ self.context["repeticion"] = 0
44
+
45
  elif curren_repetition == 2:
46
  self.context["fisrt_phase"] = self.getDataFirstPhase()
47
  self.context["second_phase"] = self.getDataSecondPhase()
48
+ self.context["repeticion"] = 0
49
+
50
  elif curren_repetition >= 3:
51
  self.context["fisrt_phase"] = self.getDataFirstPhase()
52
  self.context["second_phase"] = self.getDataSecondPhase()
53
  self.context["data_ratings"] = self.getDataRatings()
54
+ self.context["repeticion"] = self.session.tecnica.repeticion - 2
55
 
56
  return self.context
57
 
 
110
  'username': username,
111
  'words': words
112
  })
113
+
114
  return result
115
 
116
  def getDataRatings(self):
117
+ technique = self.session.tecnica
118
+
119
+ if technique.repeticion > 3:
120
+ return self.getDataRatingsFinal()
121
+
122
+ elif technique.repeticion == 3:
123
+ return self.getDataRatingsInitial()
124
+
125
+ def getStatus(self, rep: int, activate: bool):
126
+ status = ""
127
+
128
+ if rep == 0 and not activate:
129
+ status = "Listo para crear listas iniciales"
130
+
131
+ elif rep == 1 and activate:
132
+ status = "En primera fase, creación de listas iniciales"
133
+ elif rep == 1 and not activate:
134
+ status = "Listo para crear listas finales"
135
+
136
+ elif rep == 2 and activate:
137
+ status = "En segunda fase, creación de listas finales"
138
+ elif rep == 2 and not activate:
139
+ status = "Listo para calificaciones"
140
+
141
+ elif rep > 2 and not activate:
142
+ status = "Listo para calificaciones"
143
+ elif rep > 2 and activate:
144
+ status = "Catadores calificando"
145
+
146
+ return status
147
+
148
+ def getDataRatingsInitial(self):
149
+ ratings = list(Calificacion.objects.filter(id_tecnica=self.session.tecnica, num_repeticion=3))
150
+
151
+ if ratings:
152
+ raw_data = DatoController.getWordValuesForConvecional(
153
+ technique=self.session.tecnica,
154
+ ratings=ratings
155
+ )
156
+
157
+ structured_data = defaultdict(lambda: defaultdict(list))
158
+
159
+ for item in raw_data:
160
+ prod_code = item["producto_code"]
161
+ username = item["usuario_catador"]
162
+
163
+ structured_data[prod_code][username].append({
164
+ "palabra": item["nombre_palabra"],
165
+ "valor": item["dato_valor"]
166
+ })
167
+
168
+ return defaultdict_to_dict(structured_data)
169
+
170
+ def getDataRatingsFinal(self):
171
  lists_words_testers = self.context["second_phase"]
172
  technique = self.session.tecnica
173
 
 
189
 
190
  ratings_for_repetition = defaultdict(lambda: defaultdict(list))
191
 
192
+ # Estructurar los datos
193
  for item in data:
194
  rep = item["repeticion"]
195
  prod = item["producto_code"]
 
197
  ratings_for_repetition[rep-2][prod].append({
198
  "nombre_palabra": item["nombre_palabra"],
199
  "dato_valor": item["dato_valor"]
200
+ })
201
 
202
  ratings_for_tester.append(
203
  {
 
207
  "words": list_tester["words"]
208
  }
209
  )
 
210
 
211
+ return ratings_for_tester
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tecnicas/templates/tecnicas/components/table_pf_all.html ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% load custom_filters %}
2
+ <section>
3
+ <div class="overflow-x-auto rounded-lg border border-surface-general">
4
+ <table class="min-w-max w-full text-sm text-center border-collapse">
5
+ <thead class="bg-surface-sweet text-black font-semibold">
6
+ <tr>
7
+ <th rowspan="2" class="py-2 px-3 border border-surface-general">Producto</th>
8
+ {% for user_data in second_phase %}
9
+ <th colspan="{{ user_data.words|length }}" class="py-2 px-3 border border-surface-general">
10
+ {{ user_data.username }}
11
+ </th>
12
+ {% endfor %}
13
+ </tr>
14
+ <tr>
15
+ {% for user_data in second_phase %}
16
+ {% for word in user_data.words %}
17
+ <th class="py-2 px-3 border border-surface-general text-xs">
18
+ {{ word.nombre_palabra }}
19
+ </th>
20
+ {% endfor %}
21
+ {% endfor %}
22
+ </tr>
23
+ </thead>
24
+ <tbody class="bg-surface-ligt divide-y divide-gray-200">
25
+ {% for product_code, users_ratings in data_ratings.items %}
26
+ <tr>
27
+ <td class="py-2 px-3 border border-surface-general font-medium">{{ product_code }}</td>
28
+
29
+ {% for user_data in second_phase %}
30
+ {% with user_ratings=users_ratings|get_item:user_data.username %}
31
+ {% for word in user_data.words %}
32
+ <td class="py-2 px-3 border border-surface-general">
33
+ {% if user_ratings %}
34
+ {% for rating in user_ratings %}
35
+ {% if rating.palabra == word.nombre_palabra %}
36
+ {{ rating.valor }}
37
+ {% endif %}
38
+ {% endfor %}
39
+ {% else %}
40
+ -
41
+ {% endif %}
42
+ </td>
43
+ {% endfor %}
44
+ {% endwith %}
45
+ {% endfor %}
46
+ </tr>
47
+ {% endfor %}
48
+ </tbody>
49
+ </table>
50
+ </div>
51
+ </section>
tecnicas/templates/tecnicas/manage_sesions/details-session-pf.html CHANGED
@@ -90,6 +90,13 @@
90
  </p>
91
  </section>
92
 
 
 
 
 
 
 
 
93
  <section
94
  class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
95
  <p class="font-sans">
@@ -212,7 +219,7 @@
212
  <section class="">
213
  <header class="text-center">
214
  <h3 class="text-xl font-bold">Tercera fase</h3>
215
- <p class="text-lg">Listas finales de Catadores</p>
216
  </header>
217
 
218
  <article class="text-xl space-y-4 space-x-4 mb-4">
@@ -224,19 +231,27 @@
224
  </p>
225
  </article>
226
 
227
- {% if data_ratings %}
228
- <article class="overflow-x-auto py-2 space-y-4">
229
- {% for data_tester in data_ratings %}
230
- {% include "../components/table_pf.html" with data=data_tester session_name=sesion.nombre_sesion session_code=sesion.codigo_sesion %}
231
- {% endfor %}
232
- </article>
233
- <div class="flex justify-end mt-3">
234
- <button id="download-csv-btn" class="cts-btn-general cts-btn-primary btn-push">
235
- Descargar datos como CSV en zip
236
- </button>
237
- </div>
238
  {% else %}
239
- {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  {% endif %}
241
  </section>
242
  </article>
 
90
  </p>
91
  </section>
92
 
93
+ <section
94
+ class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
95
+ <p class="font-sans">
96
+ <b>Repetición Actual</b> {{ repeticion }}
97
+ </p>
98
+ </section>
99
+
100
  <section
101
  class="bg-surface-card flex flex-wrap items-center justify-center max-sm:justify-normal gap-x-2 p-4 rounded-2xl">
102
  <p class="font-sans">
 
219
  <section class="">
220
  <header class="text-center">
221
  <h3 class="text-xl font-bold">Tercera fase</h3>
222
+ <p class="text-lg">Califiaciones de Catadores</p>
223
  </header>
224
 
225
  <article class="text-xl space-y-4 space-x-4 mb-4">
 
231
  </p>
232
  </article>
233
 
234
+ {% if repeticion == 1 %}
235
+ {% if data_ratings %}
236
+ {% include "../components/table_pf_all.html" with second_phase=second_phase data_ratings=data_ratings %}
237
+ {% else %}
238
+ {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
239
+ {% endif %}
 
 
 
 
 
240
  {% else %}
241
+ {% if data_ratings %}
242
+ <article class="overflow-x-auto py-2 space-y-4">
243
+ {% for data_tester in data_ratings %}
244
+ {% include "../components/table_pf.html" with data=data_tester session_name=sesion.nombre_sesion session_code=sesion.codigo_sesion %}
245
+ {% endfor %}
246
+ </article>
247
+ <div class="flex justify-end mt-3">
248
+ <button id="download-csv-btn" class="cts-btn-general cts-btn-primary btn-push">
249
+ Descargar datos como CSV en zip
250
+ </button>
251
+ </div>
252
+ {% else %}
253
+ {% include "../components/error-message.html" with message='Sin datos por mostrar aún' %}
254
+ {% endif %}
255
  {% endif %}
256
  </section>
257
  </article>
tecnicas/templatetags/__init__.py ADDED
File without changes
tecnicas/templatetags/custom_filters.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from django import template
2
+
3
+ register = template.Library()
4
+
5
+ @register.filter
6
+ def get_item(dictionary, key):
7
+ return dictionary.get(key)