Spaces:
Running
Running
Se refactoriza la tabla en detalles de ssion
Browse files
tecnicas/controllers/views_controller/session_management/details_escala_controller.py
CHANGED
|
@@ -14,7 +14,7 @@ Encabezados de como deben de aparecer los datos juntos
|
|
| 14 |
from django.http import HttpRequest
|
| 15 |
from django.shortcuts import render, redirect
|
| 16 |
from django.urls import reverse
|
| 17 |
-
from tecnicas.models import SesionSensorial, Presentador, Participacion, Calificacion
|
| 18 |
from tecnicas.controllers import DatoController, PalabrasController, ParticipacionController
|
| 19 |
from .details_controller import DetallesController
|
| 20 |
from tecnicas.utils import defaultdict_to_dict, controller_error
|
|
@@ -44,16 +44,26 @@ class DetallesEscalasController(DetallesController):
|
|
| 44 |
}
|
| 45 |
self.context["sesion"] = self.session
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
# Recuperar la palabras de la tecnica
|
| 48 |
self.words = PalabrasController.getWordsInTechnique(
|
| 49 |
-
|
| 50 |
self.context["palabras"] = [word.nombre_palabra for word in self.words]
|
| 51 |
|
| 52 |
# Se recuperan las calificaciones
|
| 53 |
ratings_for_repetition = []
|
| 54 |
|
| 55 |
ratings = list(Calificacion.objects.filter(
|
| 56 |
-
id_tecnica=
|
| 57 |
|
| 58 |
if not ratings:
|
| 59 |
self.context["calificaciones"] = ratings_for_repetition
|
|
@@ -61,7 +71,7 @@ class DetallesEscalasController(DetallesController):
|
|
| 61 |
return self.context
|
| 62 |
|
| 63 |
data = DatoController.getWordValuesForConvecional(
|
| 64 |
-
ratings=ratings, technique=
|
| 65 |
|
| 66 |
ratings_for_repetition = defaultdict(
|
| 67 |
lambda: defaultdict(lambda: defaultdict(list)))
|
|
@@ -81,7 +91,7 @@ class DetallesEscalasController(DetallesController):
|
|
| 81 |
self.context["existen_calificaciones"] = True
|
| 82 |
|
| 83 |
# Se comprueba que ya no se pueda iniciar la repeticion
|
| 84 |
-
self.context["fin_repeticiones"] =
|
| 85 |
|
| 86 |
return self.context
|
| 87 |
|
|
|
|
| 14 |
from django.http import HttpRequest
|
| 15 |
from django.shortcuts import render, redirect
|
| 16 |
from django.urls import reverse
|
| 17 |
+
from tecnicas.models import SesionSensorial, Presentador, Participacion, Calificacion, Escala
|
| 18 |
from tecnicas.controllers import DatoController, PalabrasController, ParticipacionController
|
| 19 |
from .details_controller import DetallesController
|
| 20 |
from tecnicas.utils import defaultdict_to_dict, controller_error
|
|
|
|
| 44 |
}
|
| 45 |
self.context["sesion"] = self.session
|
| 46 |
|
| 47 |
+
technique = self.session.tecnica
|
| 48 |
+
|
| 49 |
+
# Datos de la escala usada
|
| 50 |
+
scale: Escala = technique.escala_tecnica
|
| 51 |
+
|
| 52 |
+
self.context["scale"] = {
|
| 53 |
+
"type": scale.id_tipo_escala.nombre_escala,
|
| 54 |
+
"size": scale.longitud
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
# Recuperar la palabras de la tecnica
|
| 58 |
self.words = PalabrasController.getWordsInTechnique(
|
| 59 |
+
technique)
|
| 60 |
self.context["palabras"] = [word.nombre_palabra for word in self.words]
|
| 61 |
|
| 62 |
# Se recuperan las calificaciones
|
| 63 |
ratings_for_repetition = []
|
| 64 |
|
| 65 |
ratings = list(Calificacion.objects.filter(
|
| 66 |
+
id_tecnica=technique))
|
| 67 |
|
| 68 |
if not ratings:
|
| 69 |
self.context["calificaciones"] = ratings_for_repetition
|
|
|
|
| 71 |
return self.context
|
| 72 |
|
| 73 |
data = DatoController.getWordValuesForConvecional(
|
| 74 |
+
ratings=ratings, technique=technique)
|
| 75 |
|
| 76 |
ratings_for_repetition = defaultdict(
|
| 77 |
lambda: defaultdict(lambda: defaultdict(list)))
|
|
|
|
| 91 |
self.context["existen_calificaciones"] = True
|
| 92 |
|
| 93 |
# Se comprueba que ya no se pueda iniciar la repeticion
|
| 94 |
+
self.context["fin_repeticiones"] = technique.repeticion >= technique.repeticiones_max
|
| 95 |
|
| 96 |
return self.context
|
| 97 |
|
tecnicas/templates/tecnicas/components/table-convencional.html
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
<section>
|
| 2 |
-
<h2 class="text-lg font-bold mb-3">Repetición {{ repeticion }}</h2>
|
| 3 |
-
|
| 4 |
<div class="overflow-x-auto rounded-lg border border-surface-general">
|
| 5 |
<table class="min-w-max w-full text-sm text-center border-collapse">
|
| 6 |
<thead class="bg-surface-sweet text-black font-semibold">
|
| 7 |
<tr>
|
|
|
|
| 8 |
<th class="py-2 px-3 border border-surface-general">Usuario</th>
|
| 9 |
<th class="py-2 px-3 border border-surface-general">Producto</th>
|
| 10 |
{% for palabra in palabras %}
|
|
@@ -13,26 +12,29 @@
|
|
| 13 |
</tr>
|
| 14 |
</thead>
|
| 15 |
<tbody class="bg-surface-ligt divide-y divide-gray-200">
|
| 16 |
-
{% for
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
{% endfor %}
|
| 30 |
-
{% if not match %}0{% endif %}
|
| 31 |
-
{% endwith %}
|
| 32 |
-
</td>
|
| 33 |
{% endfor %}
|
| 34 |
-
</tr>
|
| 35 |
-
{% endfor %}
|
| 36 |
{% endfor %}
|
| 37 |
</tbody>
|
| 38 |
</table>
|
|
|
|
| 1 |
<section>
|
|
|
|
|
|
|
| 2 |
<div class="overflow-x-auto rounded-lg border border-surface-general">
|
| 3 |
<table class="min-w-max w-full text-sm text-center border-collapse">
|
| 4 |
<thead class="bg-surface-sweet text-black font-semibold">
|
| 5 |
<tr>
|
| 6 |
+
<th class="py-2 px-3 border border-surface-general">Repetición</th>
|
| 7 |
<th class="py-2 px-3 border border-surface-general">Usuario</th>
|
| 8 |
<th class="py-2 px-3 border border-surface-general">Producto</th>
|
| 9 |
{% for palabra in palabras %}
|
|
|
|
| 12 |
</tr>
|
| 13 |
</thead>
|
| 14 |
<tbody class="bg-surface-ligt divide-y divide-gray-200">
|
| 15 |
+
{% for repeticion, catadores in calificaciones.items %}
|
| 16 |
+
{% for usuario, productos in catadores.items %}
|
| 17 |
+
{% for codigo, valores in productos.items %}
|
| 18 |
+
<tr>
|
| 19 |
+
<td class="py-2 px-3 border border-surface-general">{{ repeticion }}</td>
|
| 20 |
+
<td class="py-2 px-3 border border-surface-general">{{ usuario }}</td>
|
| 21 |
+
<td class="py-2 px-3 border border-surface-general">{{ codigo }}</td>
|
| 22 |
+
{% for palabra in palabras %}
|
| 23 |
+
<td class="py-2 px-3 border border-surface-general">
|
| 24 |
+
{% with match=False %}
|
| 25 |
+
{% for valor in valores %}
|
| 26 |
+
{% if valor.nombre_palabra == palabra %}
|
| 27 |
+
{{ valor.dato_valor }}
|
| 28 |
+
{% with match=True %}{% endwith %}
|
| 29 |
+
{% endif %}
|
| 30 |
+
{% endfor %}
|
| 31 |
+
{% if match %}0{% endif %}
|
| 32 |
+
{% endwith %}
|
| 33 |
+
</td>
|
| 34 |
+
{% endfor %}
|
| 35 |
+
</tr>
|
| 36 |
{% endfor %}
|
|
|
|
|
|
|
|
|
|
| 37 |
{% endfor %}
|
|
|
|
|
|
|
| 38 |
{% endfor %}
|
| 39 |
</tbody>
|
| 40 |
</table>
|
tecnicas/templates/tecnicas/manage_sesions/detalles-sesion.html
CHANGED
|
@@ -252,11 +252,15 @@
|
|
| 252 |
|
| 253 |
{% if existen_calificaciones %}
|
| 254 |
<article class="bg-surface-card p-4 max-sm:px-2 text-black rounded">
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
</article>
|
| 261 |
{% else %}
|
| 262 |
{% include "../components/error-message.html" with message='Sin calificaciones que mostrar aún' %}
|
|
|
|
| 252 |
|
| 253 |
{% if existen_calificaciones %}
|
| 254 |
<article class="bg-surface-card p-4 max-sm:px-2 text-black rounded">
|
| 255 |
+
<section class="text-xl space-y-4 space-x-4 mb-4">
|
| 256 |
+
<p class="inline italic underline font-semibold">
|
| 257 |
+
Tipo de escala: <span class="font-bold uppercase">{{ scale.type }}</span>
|
| 258 |
+
</p>
|
| 259 |
+
<p class="inline italic underline font-semibold">
|
| 260 |
+
Máximo valor por dato: <span class="font-bold">{{ scale.size }}</span>
|
| 261 |
+
</p>
|
| 262 |
+
</section>
|
| 263 |
+
{% include "../components/table-convencional.html" with calificaciones=calificaciones palabras=palabras %}
|
| 264 |
</article>
|
| 265 |
{% else %}
|
| 266 |
{% include "../components/error-message.html" with message='Sin calificaciones que mostrar aún' %}
|