Spaces:
Running
Running
Mostrando datos para la sesion con napping con modalidad sorting
Browse files
tecnicas/controllers/views_controller/session_management/details/details_napping_controller.py
CHANGED
|
@@ -3,7 +3,7 @@ from django.shortcuts import redirect
|
|
| 3 |
from django.urls import reverse
|
| 4 |
from django.db.models import F
|
| 5 |
from .details_controller import DetallesController
|
| 6 |
-
from tecnicas.models import SesionSensorial, Presentador, Modalidad, TecnicaModalidad, Catador, Participacion, DatoPunto, Calificacion
|
| 7 |
from tecnicas.utils import defaultdict_to_dict
|
| 8 |
from collections import defaultdict
|
| 9 |
|
|
@@ -117,6 +117,8 @@ class DetallesNappingController(DetallesController):
|
|
| 117 |
mod = TecnicaModalidad.objects.get(tecnica=self.session.tecnica)
|
| 118 |
if mod.modalidad.nombre == "perfil ultra flash":
|
| 119 |
self.setWordFrequencies(ratings)
|
|
|
|
|
|
|
| 120 |
|
| 121 |
self.context["there_data"] = True
|
| 122 |
|
|
@@ -152,6 +154,67 @@ class DetallesNappingController(DetallesController):
|
|
| 152 |
self.context["word_frequencies"] = word_frequencies_dict
|
| 153 |
self.context["all_words"] = all_words_sorted
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
def setIsEndSession(self):
|
| 156 |
if not self.session.activo and self.session.tecnica.repeticion < 1:
|
| 157 |
self.context["finished"] = False
|
|
|
|
| 3 |
from django.urls import reverse
|
| 4 |
from django.db.models import F
|
| 5 |
from .details_controller import DetallesController
|
| 6 |
+
from tecnicas.models import SesionSensorial, Presentador, Modalidad, TecnicaModalidad, Catador, Participacion, DatoPunto, Calificacion, GrupoProducto
|
| 7 |
from tecnicas.utils import defaultdict_to_dict
|
| 8 |
from collections import defaultdict
|
| 9 |
|
|
|
|
| 117 |
mod = TecnicaModalidad.objects.get(tecnica=self.session.tecnica)
|
| 118 |
if mod.modalidad.nombre == "perfil ultra flash":
|
| 119 |
self.setWordFrequencies(ratings)
|
| 120 |
+
elif mod.modalidad.nombre == "sorting":
|
| 121 |
+
self.setSortingData()
|
| 122 |
|
| 123 |
self.context["there_data"] = True
|
| 124 |
|
|
|
|
| 154 |
self.context["word_frequencies"] = word_frequencies_dict
|
| 155 |
self.context["all_words"] = all_words_sorted
|
| 156 |
|
| 157 |
+
def setSortingData(self):
|
| 158 |
+
# Get all ratings for this technique to access DatoPunto
|
| 159 |
+
ratings = Calificacion.objects.filter(id_tecnica=self.session.tecnica)
|
| 160 |
+
|
| 161 |
+
# Get coordinates for all products
|
| 162 |
+
coordinates = (
|
| 163 |
+
DatoPunto.objects.filter(calificacion__in=ratings)
|
| 164 |
+
.values(
|
| 165 |
+
producto=F("calificacion__id_producto__codigoProducto"),
|
| 166 |
+
producto_id=F("calificacion__id_producto__id"),
|
| 167 |
+
catador=F("calificacion__id_catador__user__username"),
|
| 168 |
+
catador_id=F("calificacion__id_catador__id"),
|
| 169 |
+
px=F("x"),
|
| 170 |
+
py=F("y"),
|
| 171 |
+
))
|
| 172 |
+
|
| 173 |
+
# Create a mapping of (catador_id, producto_id) -> coordinates
|
| 174 |
+
coord_map = {}
|
| 175 |
+
for coord in coordinates:
|
| 176 |
+
key = (coord["catador_id"], coord["producto_id"])
|
| 177 |
+
coord_map[key] = {
|
| 178 |
+
"px": coord["px"],
|
| 179 |
+
"py": coord["py"],
|
| 180 |
+
"producto": coord["producto"],
|
| 181 |
+
"catador": coord["catador"]
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
# Get all groups with their products and words
|
| 185 |
+
grupos = (
|
| 186 |
+
GrupoProducto.objects.filter(tecnica=self.session.tecnica)
|
| 187 |
+
.prefetch_related("productos", "palabras")
|
| 188 |
+
.select_related("catador__user")
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
# Create a mapping of (catador_id, producto_id) -> words
|
| 192 |
+
words_map = defaultdict(list)
|
| 193 |
+
for grupo in grupos:
|
| 194 |
+
catador_id = grupo.catador.id
|
| 195 |
+
words = [palabra.nombre_palabra for palabra in grupo.palabras.all()]
|
| 196 |
+
words_str = ";".join(words) if words else ""
|
| 197 |
+
|
| 198 |
+
for producto in grupo.productos.all():
|
| 199 |
+
key = (catador_id, producto.id)
|
| 200 |
+
words_map[key] = words_str
|
| 201 |
+
|
| 202 |
+
# Structure final data: product -> catador -> {px, py, words}
|
| 203 |
+
sorting_data = defaultdict(dict)
|
| 204 |
+
|
| 205 |
+
for key, coord_data in coord_map.items():
|
| 206 |
+
catador_id, producto_id = key
|
| 207 |
+
producto_code = coord_data["producto"]
|
| 208 |
+
catador_username = coord_data["catador"]
|
| 209 |
+
|
| 210 |
+
sorting_data[producto_code][catador_username] = {
|
| 211 |
+
"px": coord_data["px"],
|
| 212 |
+
"py": coord_data["py"],
|
| 213 |
+
"words": words_map.get(key, "")
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
self.context["sorting_data"] = defaultdict_to_dict(sorting_data)
|
| 217 |
+
|
| 218 |
def setIsEndSession(self):
|
| 219 |
if not self.session.activo and self.session.tecnica.repeticion < 1:
|
| 220 |
self.context["finished"] = False
|
tecnicas/templates/tecnicas/components/table-napping-sorting.html
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% load custom_filters %}
|
| 2 |
+
<article class="space-y-4 text-black">
|
| 3 |
+
<h2 class="font-bold text-xl text-center">
|
| 4 |
+
Datos de Napping con Sorting
|
| 5 |
+
</h2>
|
| 6 |
+
|
| 7 |
+
<div class="overflow-x-auto rounded-lg border border-surface-general">
|
| 8 |
+
<table id="generic-donwload-table" class="min-w-max w-full text-sm text-center border-collapse">
|
| 9 |
+
<thead class="bg-surface-sweet font-semibold">
|
| 10 |
+
<tr>
|
| 11 |
+
<th class="py-2 px-3 border border-surface-general">Producto</th>
|
| 12 |
+
{% for tester in testers %}
|
| 13 |
+
<th class="py-2 px-3 border border-surface-general uppercase">
|
| 14 |
+
X{{ forloop.counter }}
|
| 15 |
+
</th>
|
| 16 |
+
<th class="py-2 px-3 border border-surface-general uppercase">
|
| 17 |
+
Y{{ forloop.counter }}
|
| 18 |
+
</th>
|
| 19 |
+
<th class="py-2 px-3 border border-surface-general uppercase">
|
| 20 |
+
C{{ forloop.counter }}
|
| 21 |
+
</th>
|
| 22 |
+
{% endfor %}
|
| 23 |
+
</tr>
|
| 24 |
+
</thead>
|
| 25 |
+
<tbody class="bg-surface-ligt divide-y divide-gray-200">
|
| 26 |
+
{% for product, data_per_tester in sorting_data.items %}
|
| 27 |
+
<tr>
|
| 28 |
+
<td class="py-2 px-3 border border-surface-general">{{ product }}</td>
|
| 29 |
+
{% for tester in testers %}
|
| 30 |
+
{% with data=data_per_tester|get_item:tester.user.username %}
|
| 31 |
+
<td class="py-2 px-3 border border-surface-general">
|
| 32 |
+
{{ data.px }}
|
| 33 |
+
</td>
|
| 34 |
+
<td class="py-2 px-3 border border-surface-general">
|
| 35 |
+
{{ data.py }}
|
| 36 |
+
</td>
|
| 37 |
+
<td class="py-2 px-3 border border-surface-general">
|
| 38 |
+
{{ data.words }}
|
| 39 |
+
</td>
|
| 40 |
+
{% endwith %}
|
| 41 |
+
{% endfor %}
|
| 42 |
+
</tr>
|
| 43 |
+
{% endfor %}
|
| 44 |
+
</tbody>
|
| 45 |
+
</table>
|
| 46 |
+
</div>
|
| 47 |
+
</article>
|
tecnicas/templates/tecnicas/manage_sesions/details-session-napping.html
CHANGED
|
@@ -194,6 +194,8 @@
|
|
| 194 |
{% if there_data %}
|
| 195 |
{% if mode == "perfil ultra flash" %}
|
| 196 |
{% include "../components/table-napping-puf.html" with testers=testers coordinates_no_mode=coordinates_no_mode word_frequencies=word_frequencies all_words=all_words %}
|
|
|
|
|
|
|
| 197 |
{% else %}
|
| 198 |
{% include "../components/table-napping-no-mode.html" with testers=testers coordinates_no_mode=coordinates_no_mode %}
|
| 199 |
{% endif %}
|
|
|
|
| 194 |
{% if there_data %}
|
| 195 |
{% if mode == "perfil ultra flash" %}
|
| 196 |
{% include "../components/table-napping-puf.html" with testers=testers coordinates_no_mode=coordinates_no_mode word_frequencies=word_frequencies all_words=all_words %}
|
| 197 |
+
{% elif mode == "sorting" %}
|
| 198 |
+
{% include "../components/table-napping-sorting.html" with testers=testers sorting_data=sorting_data %}
|
| 199 |
{% else %}
|
| 200 |
{% include "../components/table-napping-no-mode.html" with testers=testers coordinates_no_mode=coordinates_no_mode %}
|
| 201 |
{% endif %}
|