Spaces:
Sleeping
Sleeping
Merge pull request #33 from CascoArcilla/HU9
Browse files- tecnicas/controllers/__init__.py +5 -2
- tecnicas/controllers/api_controller/rating_cata_controller.py +78 -0
- tecnicas/controllers/{views_controller/api_rating_controller.py → api_controller/rating_sacales_controller.py} +2 -2
- tecnicas/controllers/models_controller/calificacion_controller.py +1 -1
- tecnicas/controllers/views_controller/session_management/details_cata_controller.py +19 -7
- tecnicas/controllers/views_controller/sessions_tester/general_test_controller.py +14 -0
- tecnicas/controllers/views_controller/sessions_tester/init_session_tester_controller.py +7 -0
- tecnicas/controllers/views_controller/sessions_tester/test_cata_controller.py +55 -0
- tecnicas/controllers/views_controller/sessions_tester/test_rata_controller.py +81 -0
- tecnicas/controllers/views_controller/sessions_tester/{convencional_scales_controller.py → test_scales_controller.py} +8 -84
- tecnicas/static/js/created-scale.js +1 -1
- tecnicas/static/js/test-cata.js +128 -0
- tecnicas/templates/tecnicas/components/{table-convencional.html → table-scales.html} +5 -1
- tecnicas/templates/tecnicas/components/table_cata.html +50 -0
- tecnicas/templates/tecnicas/forms_tester/cata.html +119 -0
- tecnicas/templates/tecnicas/manage_sesions/detalles-sesion-cata.html +1 -1
- tecnicas/templates/tecnicas/manage_sesions/detalles-sesion.html +1 -1
- tecnicas/urls.py +11 -3
- tecnicas/views/__init__.py +4 -2
- tecnicas/views/apis/rating_word_cata.py +23 -0
- tecnicas/views/apis/{rating_word.py → rating_word_scales.py} +4 -4
- tecnicas/views/sessions_management/session_details.py +1 -1
- tecnicas/views/sessions_management/session_monitor.py +1 -1
- tecnicas/views/tester_forms/cata_test.py +12 -0
- tecnicas/views/tester_forms/convencional_scales.py +11 -6
- tecnicas/views/tester_forms/init_tester_form.py +2 -1
tecnicas/controllers/__init__.py
CHANGED
|
@@ -28,11 +28,14 @@ from .views_controller.session_management.monitor_rata_controller import Monitor
|
|
| 28 |
|
| 29 |
from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
|
| 30 |
from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
|
| 31 |
-
from .views_controller.sessions_tester.convencional_scales_controller import ConvencionalScalesController
|
| 32 |
from .views_controller.sessions_tester.list_sessions_tester_controller import ListSessionsTesterController
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
from .views_controller.vocabulary_manage.create_vocabulary_controller import CreateVocabularyController
|
| 35 |
from .views_controller.vocabulary_manage.list_vocabulary_controller import ListVocabularyController
|
| 36 |
|
| 37 |
-
from .
|
|
|
|
| 38 |
from .views_controller.tester_list_controller import TesterListController
|
|
|
|
| 28 |
|
| 29 |
from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
|
| 30 |
from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
|
|
|
|
| 31 |
from .views_controller.sessions_tester.list_sessions_tester_controller import ListSessionsTesterController
|
| 32 |
+
from .views_controller.sessions_tester.test_scales_controller import TestScalesController
|
| 33 |
+
from .views_controller.sessions_tester.test_rata_controller import TestRataController
|
| 34 |
+
from .views_controller.sessions_tester.test_cata_controller import TestCataController
|
| 35 |
|
| 36 |
from .views_controller.vocabulary_manage.create_vocabulary_controller import CreateVocabularyController
|
| 37 |
from .views_controller.vocabulary_manage.list_vocabulary_controller import ListVocabularyController
|
| 38 |
|
| 39 |
+
from .api_controller.rating_sacales_controller import RatingScalesController
|
| 40 |
+
from .api_controller.rating_cata_controller import RatingCataController
|
| 41 |
from .views_controller.tester_list_controller import TesterListController
|
tecnicas/controllers/api_controller/rating_cata_controller.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import JsonResponse, HttpRequest
|
| 2 |
+
from django.db import transaction
|
| 3 |
+
from tecnicas.models import Calificacion, Dato, ValorBooleano, Participacion, Palabra
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class RatingCataController():
|
| 7 |
+
def __init__(self):
|
| 8 |
+
pass
|
| 9 |
+
|
| 10 |
+
@staticmethod
|
| 11 |
+
def saveRatingWords(request: HttpRequest, data_words: list[dict], data_prodct: dict):
|
| 12 |
+
try:
|
| 13 |
+
with transaction.atomic():
|
| 14 |
+
participation = Participacion.objects.get(
|
| 15 |
+
id=request.session["id_participation"])
|
| 16 |
+
if not participation:
|
| 17 |
+
raise ValueError("No está autorizado en la sesión")
|
| 18 |
+
|
| 19 |
+
ids_words = []
|
| 20 |
+
words_values = {}
|
| 21 |
+
|
| 22 |
+
# Acoplar datos para usar
|
| 23 |
+
for da_wo in data_words:
|
| 24 |
+
ids_words.append(da_wo["id"])
|
| 25 |
+
words_values[da_wo["word"]] = da_wo["is_check"]
|
| 26 |
+
|
| 27 |
+
words_for_rating = Palabra.objects.filter(id__in=ids_words)
|
| 28 |
+
if not words_for_rating:
|
| 29 |
+
raise ValueError("No se han encontrado sus palabras")
|
| 30 |
+
|
| 31 |
+
technique = participation.tecnica
|
| 32 |
+
|
| 33 |
+
# Creando la calificacion
|
| 34 |
+
(rating, creataed) = Calificacion.objects.get_or_create(
|
| 35 |
+
num_repeticion=technique.repeticion,
|
| 36 |
+
id_producto_id=data_prodct["id"],
|
| 37 |
+
id_tecnica=technique,
|
| 38 |
+
id_catador=request.user.user_catador
|
| 39 |
+
)
|
| 40 |
+
if not rating:
|
| 41 |
+
raise ValueError("Problemas al crear la calificación")
|
| 42 |
+
|
| 43 |
+
# Guardando datos
|
| 44 |
+
data_for_save = []
|
| 45 |
+
for word in words_for_rating:
|
| 46 |
+
data_for_save.append(Dato(
|
| 47 |
+
id_palabra=word,
|
| 48 |
+
id_calificacion=rating
|
| 49 |
+
))
|
| 50 |
+
|
| 51 |
+
Dato.objects.bulk_create(data_for_save)
|
| 52 |
+
data_saved = Dato.objects.filter(
|
| 53 |
+
id_calificacion=rating).only("id_palabra")
|
| 54 |
+
if not data_saved:
|
| 55 |
+
raise ValueError("Problemas al crear los datos")
|
| 56 |
+
|
| 57 |
+
# Guardando valores de datos
|
| 58 |
+
values_for_save = []
|
| 59 |
+
for data in data_saved:
|
| 60 |
+
word_for_rating = data.id_palabra.nombre_palabra
|
| 61 |
+
values_for_save.append(
|
| 62 |
+
ValorBooleano(
|
| 63 |
+
id_dato=data,
|
| 64 |
+
valor=words_values[word_for_rating]
|
| 65 |
+
)
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
ValorBooleano.objects.bulk_create(values_for_save)
|
| 69 |
+
values_saves = ValorBooleano.objects.filter(
|
| 70 |
+
id_dato__id_calificacion=rating).count()
|
| 71 |
+
if not values_saves:
|
| 72 |
+
raise ValueError("Error al guardar los datos")
|
| 73 |
+
|
| 74 |
+
return JsonResponse({"message": "Valores guardados"})
|
| 75 |
+
|
| 76 |
+
except ValueError as e:
|
| 77 |
+
print(f"Error de calificacion: {e}")
|
| 78 |
+
return JsonResponse({"error": e}, statusstatus=500)
|
tecnicas/controllers/{views_controller/api_rating_controller.py → api_controller/rating_sacales_controller.py}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
from
|
| 2 |
from ...utils import controller_error
|
| 3 |
|
| 4 |
|
| 5 |
-
class
|
| 6 |
def __init__(self, rating_controller: CalificacionController, data_controller: DatoController):
|
| 7 |
self.rating_controller = rating_controller
|
| 8 |
self.data_controller = data_controller
|
|
|
|
| 1 |
+
from .. import CalificacionController, DatoController
|
| 2 |
from ...utils import controller_error
|
| 3 |
|
| 4 |
|
| 5 |
+
class RatingScalesController():
|
| 6 |
def __init__(self, rating_controller: CalificacionController, data_controller: DatoController):
|
| 7 |
self.rating_controller = rating_controller
|
| 8 |
self.data_controller = data_controller
|
tecnicas/controllers/models_controller/calificacion_controller.py
CHANGED
|
@@ -21,7 +21,7 @@ class CalificacionController():
|
|
| 21 |
@staticmethod
|
| 22 |
def getRatingsByTechnique(technique: Tecnica):
|
| 23 |
repetition = technique.repeticion
|
| 24 |
-
ratings = list(Calificacion.objects.filter(id_tecnica=technique))
|
| 25 |
return ratings
|
| 26 |
|
| 27 |
@staticmethod
|
|
|
|
| 21 |
@staticmethod
|
| 22 |
def getRatingsByTechnique(technique: Tecnica):
|
| 23 |
repetition = technique.repeticion
|
| 24 |
+
ratings = list(Calificacion.objects.filter(id_tecnica=technique, num_repeticion=repetition))
|
| 25 |
return ratings
|
| 26 |
|
| 27 |
@staticmethod
|
tecnicas/controllers/views_controller/session_management/details_cata_controller.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
-
from
|
| 4 |
-
from tecnicas.
|
|
|
|
| 5 |
from tecnicas.utils import defaultdict_to_dict
|
| 6 |
from .details_controller import DetallesController
|
| 7 |
from collections import defaultdict
|
|
@@ -29,16 +30,27 @@ class DetallesCATAController(DetallesController):
|
|
| 29 |
# Intentar recuperar las calificaciones
|
| 30 |
ratings_for_repetition = []
|
| 31 |
|
| 32 |
-
ratings =
|
| 33 |
-
|
| 34 |
|
| 35 |
-
if
|
| 36 |
self.context["calificaciones"] = ratings_for_repetition
|
| 37 |
self.context["existen_calificaciones"] = False
|
| 38 |
return self.context
|
| 39 |
|
| 40 |
-
data =
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
ratings_for_repetition = defaultdict(
|
| 44 |
lambda: defaultdict(lambda: defaultdict(list)))
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
+
from django.db.models import F
|
| 4 |
+
from tecnicas.models import SesionSensorial, Calificacion, ValorBooleano
|
| 5 |
+
from tecnicas.controllers import PalabrasController, DatoController
|
| 6 |
from tecnicas.utils import defaultdict_to_dict
|
| 7 |
from .details_controller import DetallesController
|
| 8 |
from collections import defaultdict
|
|
|
|
| 30 |
# Intentar recuperar las calificaciones
|
| 31 |
ratings_for_repetition = []
|
| 32 |
|
| 33 |
+
ratings = list(Calificacion.objects.filter(
|
| 34 |
+
id_tecnica=technique))
|
| 35 |
|
| 36 |
+
if not ratings:
|
| 37 |
self.context["calificaciones"] = ratings_for_repetition
|
| 38 |
self.context["existen_calificaciones"] = False
|
| 39 |
return self.context
|
| 40 |
|
| 41 |
+
data = (
|
| 42 |
+
ValorBooleano.objects
|
| 43 |
+
.filter(id_dato__id_calificacion__in=ratings)
|
| 44 |
+
.values(
|
| 45 |
+
nombre_palabra=F("id_dato__id_palabra__nombre_palabra"),
|
| 46 |
+
repeticion=F("id_dato__id_calificacion__num_repeticion"),
|
| 47 |
+
producto_code=F(
|
| 48 |
+
"id_dato__id_calificacion__id_producto__codigoProducto"),
|
| 49 |
+
usuario_catador=F(
|
| 50 |
+
"id_dato__id_calificacion__id_catador__user__username"),
|
| 51 |
+
dato_valor=F("valor")
|
| 52 |
+
)
|
| 53 |
+
)
|
| 54 |
|
| 55 |
ratings_for_repetition = defaultdict(
|
| 56 |
lambda: defaultdict(lambda: defaultdict(list)))
|
tecnicas/controllers/views_controller/sessions_tester/general_test_controller.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import redirect, render
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from tecnicas.models import SesionSensorial, Catador
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class GenetalTestController():
|
| 8 |
+
previus_directory = "cata_system:catador_init_session"
|
| 9 |
+
context = {}
|
| 10 |
+
current_directory: str
|
| 11 |
+
|
| 12 |
+
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 13 |
+
self.tester = user_tester
|
| 14 |
+
self.session = sensorial_session
|
tecnicas/controllers/views_controller/sessions_tester/init_session_tester_controller.py
CHANGED
|
@@ -13,6 +13,7 @@ class InitSessionTesterController():
|
|
| 13 |
order: Orden | dict
|
| 14 |
current_direction = "tecnicas/forms_tester/init_session.html"
|
| 15 |
escalas_direction = "cata_system:session_convencional"
|
|
|
|
| 16 |
|
| 17 |
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 18 |
self.tester = user_tester
|
|
@@ -65,13 +66,19 @@ class InitSessionTesterController():
|
|
| 65 |
return render(request, self.current_direction, context)
|
| 66 |
|
| 67 |
request.session["id_participation"] = update_participation.id
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
return redirect(reverse(self.escalas_direction, kwargs=parameters))
|
|
|
|
| 69 |
elif request.POST["action"] == "exit_session":
|
| 70 |
response = ParticipacionController.outSession(
|
| 71 |
tester=request.user.user_catador, session=self.session)
|
| 72 |
if isinstance(response, dict):
|
| 73 |
context["error"] = response["error"]
|
| 74 |
return render(request, self.current_direction, context)
|
|
|
|
| 75 |
else:
|
| 76 |
context["error"] = "Acción sin especificar"
|
| 77 |
return render(request, self.current_direction, context)
|
|
|
|
| 13 |
order: Orden | dict
|
| 14 |
current_direction = "tecnicas/forms_tester/init_session.html"
|
| 15 |
escalas_direction = "cata_system:session_convencional"
|
| 16 |
+
cata_cirection = "cata_system:session_cata"
|
| 17 |
|
| 18 |
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 19 |
self.tester = user_tester
|
|
|
|
| 66 |
return render(request, self.current_direction, context)
|
| 67 |
|
| 68 |
request.session["id_participation"] = update_participation.id
|
| 69 |
+
|
| 70 |
+
if self.session.tecnica.tipo_tecnica.nombre_tecnica == "cata":
|
| 71 |
+
return redirect(reverse(self.cata_cirection, kwargs=parameters))
|
| 72 |
+
|
| 73 |
return redirect(reverse(self.escalas_direction, kwargs=parameters))
|
| 74 |
+
|
| 75 |
elif request.POST["action"] == "exit_session":
|
| 76 |
response = ParticipacionController.outSession(
|
| 77 |
tester=request.user.user_catador, session=self.session)
|
| 78 |
if isinstance(response, dict):
|
| 79 |
context["error"] = response["error"]
|
| 80 |
return render(request, self.current_direction, context)
|
| 81 |
+
|
| 82 |
else:
|
| 83 |
context["error"] = "Acción sin especificar"
|
| 84 |
return render(request, self.current_direction, context)
|
tecnicas/controllers/views_controller/sessions_tester/test_cata_controller.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import redirect, render
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from tecnicas.models import Producto, Participacion, Palabra, Calificacion
|
| 5 |
+
from tecnicas.controllers import PalabrasController, ParticipacionController
|
| 6 |
+
from .general_test_controller import GenetalTestController
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class TestCataController(GenetalTestController):
|
| 10 |
+
def __init__(self, sensorial_session, user_tester):
|
| 11 |
+
super().__init__(sensorial_session, user_tester)
|
| 12 |
+
self.current_directory = "tecnicas/forms_tester/cata.html"
|
| 13 |
+
|
| 14 |
+
def controllGet(self, request: HttpRequest):
|
| 15 |
+
technique = self.session.tecnica
|
| 16 |
+
self.participation = Participacion.objects.get(
|
| 17 |
+
tecnica=technique, catador=request.user.user_catador)
|
| 18 |
+
|
| 19 |
+
self.context["session"] = self.session
|
| 20 |
+
|
| 21 |
+
products_in_technique = Producto.objects.filter(id_tecnica=technique)
|
| 22 |
+
|
| 23 |
+
words = PalabrasController.getWordsInTechnique(technique=technique)
|
| 24 |
+
|
| 25 |
+
use_product: Producto = None
|
| 26 |
+
use_words: list[Palabra] = None
|
| 27 |
+
|
| 28 |
+
# Revisamos el producto que le falten calificaciones
|
| 29 |
+
for current_product in products_in_technique:
|
| 30 |
+
try:
|
| 31 |
+
rating = Calificacion.objects.get(
|
| 32 |
+
num_repeticion=technique.repeticion,
|
| 33 |
+
id_producto=current_product,
|
| 34 |
+
id_tecnica=technique,
|
| 35 |
+
id_catador=self.tester
|
| 36 |
+
)
|
| 37 |
+
except Calificacion.DoesNotExist:
|
| 38 |
+
# Si no hay calificacion mandamos el producto actual y todas la palabras
|
| 39 |
+
use_product = current_product
|
| 40 |
+
use_words = words
|
| 41 |
+
break
|
| 42 |
+
|
| 43 |
+
# Si no hay producto que falta por calificar finalizar sesion para el Catador
|
| 44 |
+
if not use_product:
|
| 45 |
+
updated_participation = ParticipacionController.finishSession(
|
| 46 |
+
self.participation)
|
| 47 |
+
params = {
|
| 48 |
+
"code_sesion": self.session.codigo_sesion
|
| 49 |
+
}
|
| 50 |
+
return redirect(reverse(self.previus_directory, kwargs=params))
|
| 51 |
+
|
| 52 |
+
self.context["product"] = use_product
|
| 53 |
+
self.context["words"] = use_words
|
| 54 |
+
|
| 55 |
+
return render(request, self.current_directory, self.context)
|
tecnicas/controllers/views_controller/sessions_tester/test_rata_controller.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import redirect, render
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from tecnicas.models import Participacion, Producto, Calificacion, Palabra
|
| 5 |
+
from tecnicas.controllers import ParticipacionController, PalabrasController, EscalaController
|
| 6 |
+
from .general_test_controller import GenetalTestController
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class TestRataController(GenetalTestController):
|
| 10 |
+
def __init__(self, sensorial_session, user_tester):
|
| 11 |
+
super().__init__(sensorial_session, user_tester)
|
| 12 |
+
self.current_directory = "tecnicas/forms_tester/convencional.html"
|
| 13 |
+
|
| 14 |
+
def controllGet(self, request: HttpRequest):
|
| 15 |
+
technique = self.session.tecnica
|
| 16 |
+
self.participation = Participacion.objects.get(
|
| 17 |
+
tecnica=technique, catador=request.user.user_catador)
|
| 18 |
+
|
| 19 |
+
self.context["session"] = self.session
|
| 20 |
+
|
| 21 |
+
products_in_technique = Producto.objects.filter(id_tecnica=technique)
|
| 22 |
+
|
| 23 |
+
words = PalabrasController.getWordsInTechnique(technique=technique)
|
| 24 |
+
|
| 25 |
+
use_product: Producto = None
|
| 26 |
+
use_words: list[Palabra] = None
|
| 27 |
+
|
| 28 |
+
# Revisamos el producto que le falten calificaciones
|
| 29 |
+
for current_product in products_in_technique:
|
| 30 |
+
try:
|
| 31 |
+
rating = Calificacion.objects.get(
|
| 32 |
+
num_repeticion=technique.repeticion,
|
| 33 |
+
id_producto=current_product,
|
| 34 |
+
id_tecnica=technique,
|
| 35 |
+
id_catador=self.tester
|
| 36 |
+
)
|
| 37 |
+
except Calificacion.DoesNotExist:
|
| 38 |
+
# Si no hay calificacion mandamos el producto actual y todas la palabras
|
| 39 |
+
use_product = current_product
|
| 40 |
+
use_words = words
|
| 41 |
+
break
|
| 42 |
+
|
| 43 |
+
# Obtener los datos asociados para la calificacion para ver que palabras quedan por calificar
|
| 44 |
+
recoreded_data = rating.dato_calificacion.all()
|
| 45 |
+
|
| 46 |
+
if not recoreded_data:
|
| 47 |
+
# Si no hay datos entonces devolver el producto con todas las palabras
|
| 48 |
+
use_product = current_product
|
| 49 |
+
use_words = words
|
| 50 |
+
break
|
| 51 |
+
else:
|
| 52 |
+
words_to_use = PalabrasController.getWordsWithoutData(
|
| 53 |
+
recoreded_data=recoreded_data, words=words)
|
| 54 |
+
|
| 55 |
+
# Si quedan palabras por calificar mandar las palabras con el producto
|
| 56 |
+
if not isinstance(words_to_use, dict) and words_to_use:
|
| 57 |
+
use_product = current_product
|
| 58 |
+
use_words = words_to_use
|
| 59 |
+
break
|
| 60 |
+
|
| 61 |
+
# Si no hay producto que falta por calificar finalizar sesion para el Catador
|
| 62 |
+
if not use_product:
|
| 63 |
+
updated_participation = ParticipacionController.finishSession(
|
| 64 |
+
self.participation)
|
| 65 |
+
params = {
|
| 66 |
+
"code_sesion": self.session.codigo_sesion
|
| 67 |
+
}
|
| 68 |
+
return redirect(reverse(self.previus_directory, kwargs=params))
|
| 69 |
+
|
| 70 |
+
self.context["product"] = use_product
|
| 71 |
+
self.context["words"] = use_words
|
| 72 |
+
|
| 73 |
+
# Agregar informacion de la escala
|
| 74 |
+
scale = EscalaController.getScaleByTechnique(technique=technique)
|
| 75 |
+
self.context["scale"] = scale
|
| 76 |
+
self.context["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 77 |
+
|
| 78 |
+
use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 79 |
+
self.context["tags"] = use_tags
|
| 80 |
+
|
| 81 |
+
return render(request, self.current_directory, self.context)
|
tecnicas/controllers/views_controller/sessions_tester/{convencional_scales_controller.py → test_scales_controller.py}
RENAMED
|
@@ -2,19 +2,16 @@ from django.http import HttpRequest
|
|
| 2 |
from django.shortcuts import redirect, render
|
| 3 |
from django.urls import reverse
|
| 4 |
from tecnicas.models import SesionSensorial, Catador, Participacion, Producto, Calificacion, Palabra
|
| 5 |
-
from tecnicas.controllers import PosicionController, CalificacionController, ParticipacionController, PalabrasController, EscalaController
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
-
class
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
def
|
| 14 |
-
self.tester = user_tester
|
| 15 |
-
self.session = sensorial_session
|
| 16 |
-
|
| 17 |
-
def controllGetEscalas(self, request: HttpRequest):
|
| 18 |
technique = self.session.tecnica
|
| 19 |
self.participation = Participacion.objects.get(
|
| 20 |
tecnica=technique, catador=request.user.user_catador)
|
|
@@ -82,77 +79,4 @@ class ConvencionalScalesController:
|
|
| 82 |
ctx["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 83 |
ctx["tags"] = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 84 |
|
| 85 |
-
return render(request, self.current_directory, ctx)
|
| 86 |
-
|
| 87 |
-
def controllGetRATA(self, request: HttpRequest):
|
| 88 |
-
technique = self.session.tecnica
|
| 89 |
-
self.participation = Participacion.objects.get(
|
| 90 |
-
tecnica=technique, catador=request.user.user_catador)
|
| 91 |
-
|
| 92 |
-
self.context["session"] = self.session
|
| 93 |
-
|
| 94 |
-
products_in_technique = Producto.objects.filter(id_tecnica=technique)
|
| 95 |
-
|
| 96 |
-
words = PalabrasController.getWordsInTechnique(technique=technique)
|
| 97 |
-
|
| 98 |
-
use_product: Producto = None
|
| 99 |
-
use_words: list[Palabra] = None
|
| 100 |
-
|
| 101 |
-
# Revisamos el producto que le falten calificaciones
|
| 102 |
-
for current_product in products_in_technique:
|
| 103 |
-
try:
|
| 104 |
-
rating = Calificacion.objects.get(
|
| 105 |
-
num_repeticion=technique.repeticion,
|
| 106 |
-
id_producto=current_product,
|
| 107 |
-
id_tecnica=technique,
|
| 108 |
-
id_catador=self.tester
|
| 109 |
-
)
|
| 110 |
-
there_rating = True
|
| 111 |
-
except Calificacion.DoesNotExist:
|
| 112 |
-
there_rating = False
|
| 113 |
-
|
| 114 |
-
# Si no hay calificacion mandamos el producto actual y todas la palabras
|
| 115 |
-
if not there_rating:
|
| 116 |
-
use_product = current_product
|
| 117 |
-
use_words = words
|
| 118 |
-
break
|
| 119 |
-
|
| 120 |
-
# Obtener los datos asociados para la calificacion para ver que palabras quedan por calificar
|
| 121 |
-
recoreded_data = rating.dato_calificacion.all()
|
| 122 |
-
|
| 123 |
-
if not recoreded_data:
|
| 124 |
-
# Si no hay datos entonces devolver el producto con todas las palabras
|
| 125 |
-
use_product = current_product
|
| 126 |
-
use_words = words
|
| 127 |
-
break
|
| 128 |
-
else:
|
| 129 |
-
words_to_use = PalabrasController.getWordsWithoutData(
|
| 130 |
-
recoreded_data=recoreded_data, words=words)
|
| 131 |
-
|
| 132 |
-
# Si quedan palabras por calificar mandar las palabras con el producto
|
| 133 |
-
if not isinstance(words_to_use, dict) and words_to_use:
|
| 134 |
-
use_product = current_product
|
| 135 |
-
use_words = words_to_use
|
| 136 |
-
break
|
| 137 |
-
|
| 138 |
-
# Si no hay producto que falta por calificar finalizar sesion para el Catador
|
| 139 |
-
if not use_product:
|
| 140 |
-
updated_participation = ParticipacionController.finishSession(
|
| 141 |
-
self.participation)
|
| 142 |
-
params = {
|
| 143 |
-
"code_sesion": self.session.codigo_sesion
|
| 144 |
-
}
|
| 145 |
-
return redirect(reverse(self.previus_directory, kwargs=params))
|
| 146 |
-
|
| 147 |
-
self.context["product"] = use_product
|
| 148 |
-
self.context["words"] = use_words
|
| 149 |
-
|
| 150 |
-
# Agregar informacion de la escala
|
| 151 |
-
scale = EscalaController.getScaleByTechnique(technique=technique)
|
| 152 |
-
self.context["scale"] = scale
|
| 153 |
-
self.context["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 154 |
-
|
| 155 |
-
use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 156 |
-
self.context["tags"] = use_tags
|
| 157 |
-
|
| 158 |
-
return render(request, self.current_directory, self.context)
|
|
|
|
| 2 |
from django.shortcuts import redirect, render
|
| 3 |
from django.urls import reverse
|
| 4 |
from tecnicas.models import SesionSensorial, Catador, Participacion, Producto, Calificacion, Palabra
|
| 5 |
+
from tecnicas.controllers import PosicionController, CalificacionController, ParticipacionController, PalabrasController, EscalaController
|
| 6 |
+
from .general_test_controller import GenetalTestController
|
| 7 |
|
| 8 |
|
| 9 |
+
class TestScalesController(GenetalTestController):
|
| 10 |
+
def __init__(self, sensorial_session, user_tester):
|
| 11 |
+
super().__init__(sensorial_session, user_tester)
|
| 12 |
+
self.current_directory = "tecnicas/forms_tester/convencional.html"
|
| 13 |
|
| 14 |
+
def controllGet(self, request: HttpRequest):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
technique = self.session.tecnica
|
| 16 |
self.participation = Participacion.objects.get(
|
| 17 |
tecnica=technique, catador=request.user.user_catador)
|
|
|
|
| 79 |
ctx["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 80 |
ctx["tags"] = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 81 |
|
| 82 |
+
return render(request, self.current_directory, ctx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/static/js/created-scale.js
CHANGED
|
@@ -44,7 +44,7 @@ async function sendRating(word) {
|
|
| 44 |
const formRatingWord = document.querySelector(`.form-rating-${word}`);
|
| 45 |
|
| 46 |
const dataForm = new FormData(formRatingWord);
|
| 47 |
-
const url = "/cata/testers/api/ratingword";
|
| 48 |
|
| 49 |
const codeProduct = document
|
| 50 |
.querySelector(".ct-product-rating")
|
|
|
|
| 44 |
const formRatingWord = document.querySelector(`.form-rating-${word}`);
|
| 45 |
|
| 46 |
const dataForm = new FormData(formRatingWord);
|
| 47 |
+
const url = "/cata/testers/api/ratingword/escalas";
|
| 48 |
|
| 49 |
const codeProduct = document
|
| 50 |
.querySelector(".ct-product-rating")
|
tecnicas/static/js/test-cata.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener("DOMContentLoaded", () => {
|
| 2 |
+
const containFormData = document.querySelector(".words-check-container");
|
| 3 |
+
|
| 4 |
+
const form = document.getElementById("wordsForm");
|
| 5 |
+
const csrfToken = document.querySelector("[name=csrfmiddlewaretoken]").value;
|
| 6 |
+
const message = document.getElementById("response-message");
|
| 7 |
+
|
| 8 |
+
const modal = document.getElementById("confirmModal");
|
| 9 |
+
const modalContent = document.getElementById("confirmModalContent");
|
| 10 |
+
const cancelBtn = document.getElementById("cancelBtn");
|
| 11 |
+
const confirmBtn = document.getElementById("confirmBtn");
|
| 12 |
+
|
| 13 |
+
const URL = "/cata/testers/api/ratingword/cata";
|
| 14 |
+
|
| 15 |
+
const checkboxes = form.querySelectorAll('input[type="checkbox"]');
|
| 16 |
+
checkboxes.forEach((cb) => (cb.checked = false));
|
| 17 |
+
|
| 18 |
+
let wordsData = [];
|
| 19 |
+
|
| 20 |
+
form.addEventListener("submit", (e) => {
|
| 21 |
+
e.preventDefault();
|
| 22 |
+
|
| 23 |
+
const checkboxes = form.querySelectorAll('input[type="checkbox"]');
|
| 24 |
+
wordsData = Array.from(checkboxes).map((cb) => ({
|
| 25 |
+
id: parseInt(cb.dataset.wordId),
|
| 26 |
+
word: cb.dataset.wordName,
|
| 27 |
+
is_check: cb.checked,
|
| 28 |
+
}));
|
| 29 |
+
|
| 30 |
+
showModal(wordsData);
|
| 31 |
+
});
|
| 32 |
+
|
| 33 |
+
function showModal(words) {
|
| 34 |
+
const checkedWords = words.filter((w) => w.is_check);
|
| 35 |
+
const uncheckedWords = words.filter((w) => !w.is_check);
|
| 36 |
+
|
| 37 |
+
modalContent.innerHTML = `
|
| 38 |
+
<div>
|
| 39 |
+
<p class="font-semibold text-green-600">Palabras seleccionadas:</p>
|
| 40 |
+
<ul class="flex flex-wrap gap-2">
|
| 41 |
+
${
|
| 42 |
+
checkedWords.length > 0
|
| 43 |
+
? checkedWords
|
| 44 |
+
.map(
|
| 45 |
+
(w) =>
|
| 46 |
+
`<li class="border-r border-b p-1">${w.word}</li>`
|
| 47 |
+
)
|
| 48 |
+
.join("")
|
| 49 |
+
: '<li class="border-b p-1 w-full">Ninguna</li>'
|
| 50 |
+
}
|
| 51 |
+
</ul>
|
| 52 |
+
</div>
|
| 53 |
+
<div class="mt-3">
|
| 54 |
+
<p class="font-semibold text-red-600">Palabras no seleccionadas:</p>
|
| 55 |
+
<ul class="flex flex-wrap gap-2">
|
| 56 |
+
${
|
| 57 |
+
uncheckedWords.length > 0
|
| 58 |
+
? uncheckedWords
|
| 59 |
+
.map(
|
| 60 |
+
(w) =>
|
| 61 |
+
`<li class="border-r border-b p-1">${w.word}</li>`
|
| 62 |
+
)
|
| 63 |
+
.join("")
|
| 64 |
+
: '<li class="border-b p-1 w-full">Todas seleccionadas</li>'
|
| 65 |
+
}
|
| 66 |
+
</ul>
|
| 67 |
+
</div>
|
| 68 |
+
`;
|
| 69 |
+
modal.classList.remove("hidden");
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
cancelBtn.addEventListener("click", () => {
|
| 73 |
+
modalContent.innerHTML = "";
|
| 74 |
+
modal.classList.add("hidden");
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
confirmBtn.addEventListener("click", async () => {
|
| 78 |
+
modal.classList.add("hidden");
|
| 79 |
+
const dataProduct = {
|
| 80 |
+
id: parseInt(document.querySelector(".id-product").textContent),
|
| 81 |
+
code: document.querySelector(".code-product").textContent,
|
| 82 |
+
};
|
| 83 |
+
|
| 84 |
+
try {
|
| 85 |
+
const response = await fetch(URL, {
|
| 86 |
+
method: "POST",
|
| 87 |
+
headers: {
|
| 88 |
+
"Content-Type": "application/json",
|
| 89 |
+
"X-CSRFToken": csrfToken,
|
| 90 |
+
"X-Requested-With": "XMLHttpRequest",
|
| 91 |
+
},
|
| 92 |
+
body: JSON.stringify({ words: wordsData, product: dataProduct }),
|
| 93 |
+
});
|
| 94 |
+
|
| 95 |
+
if (!response.ok) {
|
| 96 |
+
message.textContent = "Error en la respuesta del servidor";
|
| 97 |
+
message.classList.remove("hidden");
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
const result = await response.json();
|
| 101 |
+
const messError = result.error;
|
| 102 |
+
|
| 103 |
+
console.log(messError);
|
| 104 |
+
|
| 105 |
+
if (messError) {
|
| 106 |
+
message.textContent = messError;
|
| 107 |
+
return;
|
| 108 |
+
}
|
| 109 |
+
containFormData.innerHTML = `
|
| 110 |
+
<section class="space-y-4">
|
| 111 |
+
<h3 class="text-xl font-bold">
|
| 112 |
+
Exito al guardar
|
| 113 |
+
</h3>
|
| 114 |
+
<p class="text-sm italic">
|
| 115 |
+
${result.message}
|
| 116 |
+
</p>
|
| 117 |
+
<button type="button" class="cts-btn-general cts-btn-primary btn-push" onclick="window.location.reload();">
|
| 118 |
+
Siguiente Producto
|
| 119 |
+
</button>
|
| 120 |
+
</section>
|
| 121 |
+
`;
|
| 122 |
+
} catch (err) {
|
| 123 |
+
console.error(err);
|
| 124 |
+
message.textContent = "Error en la respuesta del servidor";
|
| 125 |
+
message.classList.remove("hidden");
|
| 126 |
+
}
|
| 127 |
+
});
|
| 128 |
+
});
|
tecnicas/templates/tecnicas/components/{table-convencional.html → table-scales.html}
RENAMED
|
@@ -4,7 +4,9 @@
|
|
| 4 |
<table id="convencional-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 class="py-2 px-3 border border-surface-general">Repetición</th>
|
|
|
|
| 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 %}
|
|
@@ -17,7 +19,9 @@
|
|
| 17 |
{% for usuario, productos in catadores.items %}
|
| 18 |
{% for codigo, valores in productos.items %}
|
| 19 |
<tr>
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
<td class="py-2 px-3 border border-surface-general">{{ usuario }}</td>
|
| 22 |
<td class="py-2 px-3 border border-surface-general">{{ codigo }}</td>
|
| 23 |
{% for palabra in palabras %}
|
|
|
|
| 4 |
<table id="convencional-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 |
+
{% if sesion.tecnica.tipo_tecnica.nombre_tecnica != "rata" %}
|
| 8 |
<th class="py-2 px-3 border border-surface-general">Repetición</th>
|
| 9 |
+
{% endif %}
|
| 10 |
<th class="py-2 px-3 border border-surface-general">Usuario</th>
|
| 11 |
<th class="py-2 px-3 border border-surface-general">Producto</th>
|
| 12 |
{% for palabra in palabras %}
|
|
|
|
| 19 |
{% for usuario, productos in catadores.items %}
|
| 20 |
{% for codigo, valores in productos.items %}
|
| 21 |
<tr>
|
| 22 |
+
{% if sesion.tecnica.tipo_tecnica.nombre_tecnica != "rata" %}
|
| 23 |
+
<td class="py-2 px-3 border border-surface-general">{{ repeticion }}</td>
|
| 24 |
+
{% endif %}
|
| 25 |
<td class="py-2 px-3 border border-surface-general">{{ usuario }}</td>
|
| 26 |
<td class="py-2 px-3 border border-surface-general">{{ codigo }}</td>
|
| 27 |
{% for palabra in palabras %}
|
tecnicas/templates/tecnicas/components/table_cata.html
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% load static %}
|
| 2 |
+
<section>
|
| 3 |
+
<div class="overflow-x-auto rounded-lg border border-surface-general">
|
| 4 |
+
<table id="convencional-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 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 %}
|
| 10 |
+
<th class="py-2 px-3 border border-surface-general uppercase">{{ palabra }}</th>
|
| 11 |
+
{% endfor %}
|
| 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">{{ usuario }}</td>
|
| 20 |
+
<td class="py-2 px-3 border border-surface-general">{{ codigo }}</td>
|
| 21 |
+
{% for palabra in palabras %}
|
| 22 |
+
<td class="py-2 px-3 border border-surface-general">
|
| 23 |
+
{% for valor in valores %}
|
| 24 |
+
{% if valor.nombre_palabra == palabra %}
|
| 25 |
+
{% if valor.dato_valor %}
|
| 26 |
+
1
|
| 27 |
+
{% else %}
|
| 28 |
+
0
|
| 29 |
+
{% endif %}
|
| 30 |
+
{% endif %}
|
| 31 |
+
{% endfor %}
|
| 32 |
+
</td>
|
| 33 |
+
{% endfor %}
|
| 34 |
+
</tr>
|
| 35 |
+
{% endfor %}
|
| 36 |
+
{% endfor %}
|
| 37 |
+
{% endfor %}
|
| 38 |
+
</tbody>
|
| 39 |
+
</table>
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
<div class="flex justify-end mt-3">
|
| 43 |
+
<button id="download-csv-btn" class="cts-btn-general cts-btn-primary btn-push"
|
| 44 |
+
data-session-name="{% if sesion and sesion.nombre_sesion %}{{ sesion.nombre_sesion }}{% else %}{% endif %}"
|
| 45 |
+
data-session-code="{% if sesion and sesion.codigo_sesion %}{{ sesion.codigo_sesion }}{% else %}{% endif %}">
|
| 46 |
+
Descargar CSV
|
| 47 |
+
</button>
|
| 48 |
+
</div>
|
| 49 |
+
</section>
|
| 50 |
+
<script src="{% static 'js/download-table-csv.js' %}"></script>
|
tecnicas/templates/tecnicas/forms_tester/cata.html
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends 'tecnicas/layouts/base.html' %}
|
| 2 |
+
|
| 3 |
+
{% load static %}
|
| 4 |
+
|
| 5 |
+
{% block title %}Convencional{% endblock %}
|
| 6 |
+
|
| 7 |
+
{% block content %}
|
| 8 |
+
<article class="cts-container-main">
|
| 9 |
+
<article class="cts-wrap-content text-black relative">
|
| 10 |
+
<header class="text-center flex-row max-sm:flex-col w-full items-stretch flex justify-around flex-wrap gap-2">
|
| 11 |
+
<h1 class="rounded font-bold text-2xl bg-surface-ligt p-4 flex-1">
|
| 12 |
+
Sesión usando <br>técnica
|
| 13 |
+
<span class="uppercase">{{ session.tecnica.tipo_tecnica }}</span>
|
| 14 |
+
</h1>
|
| 15 |
+
<button class="cts-btn-general cts-btn-error btn-push" onclick="exit_sesion('form-actions')">
|
| 16 |
+
Salir de la sesión
|
| 17 |
+
</button>
|
| 18 |
+
</header>
|
| 19 |
+
|
| 20 |
+
<article class="hidden">
|
| 21 |
+
<form action="{% url 'cata_system:catador_init_session' code_sesion=session.codigo_sesion %}" method="post"
|
| 22 |
+
class="form-actions">
|
| 23 |
+
{% csrf_token %}
|
| 24 |
+
<input type="hidden" name="action" class="action-input">
|
| 25 |
+
</form>
|
| 26 |
+
</article>
|
| 27 |
+
|
| 28 |
+
<section class="hidden">
|
| 29 |
+
<input type="hidden" value="{{ session.tecnica.id }}" name="id-tecnica" class="ct-input-id-tech">
|
| 30 |
+
</section>
|
| 31 |
+
|
| 32 |
+
{% if error %}
|
| 33 |
+
{% include "../components/error-message.html" with message=error %}
|
| 34 |
+
{% endif %}
|
| 35 |
+
{% if message %}
|
| 36 |
+
{% include "../components/error-message.html" with message=message %}
|
| 37 |
+
{% endif %}
|
| 38 |
+
|
| 39 |
+
<article class="rounded flex flex-col gap-4">
|
| 40 |
+
<section class="flex items-center justify-center bg-surface-ligt p-2 rounded-lg">
|
| 41 |
+
<p class="text-lg font-medium text-center">
|
| 42 |
+
{{ session.tecnica.instrucciones }}
|
| 43 |
+
</p>
|
| 44 |
+
</section>
|
| 45 |
+
<section class="flex items-center justify-center flex-wrap gap-4">
|
| 46 |
+
<div class="bg-surface-ligt p-2 rounded-lg flex-1">
|
| 47 |
+
<p class="text-lg font-bold text-center">
|
| 48 |
+
Producto:
|
| 49 |
+
</p>
|
| 50 |
+
<p class="text-2xl font-bold text-center ct-product-rating">
|
| 51 |
+
<span class="code-product">{{ product }}</span>
|
| 52 |
+
<span class="hidden id-product">{{ product.id }}</span>
|
| 53 |
+
</p>
|
| 54 |
+
</div>
|
| 55 |
+
<div class="bg-surface-ligt p-2 rounded-lg flex-1">
|
| 56 |
+
<p class="text-lg font-bold text-center">
|
| 57 |
+
Repetición:
|
| 58 |
+
</p>
|
| 59 |
+
<p class="text-2xl font-bold text-center">
|
| 60 |
+
{{ session.tecnica.repeticion }}
|
| 61 |
+
</p>
|
| 62 |
+
</div>
|
| 63 |
+
</section>
|
| 64 |
+
</article>
|
| 65 |
+
|
| 66 |
+
<p id="response-message"
|
| 67 |
+
class="text-white font-bold text-lg text-center bg-red-400 px-2 py-4 rounded-lg hidden">
|
| 68 |
+
Soy el mensaje para responder
|
| 69 |
+
</p>
|
| 70 |
+
|
| 71 |
+
<article
|
| 72 |
+
class="words-check-container bg-surface-card w-full max-w-3xl mx-auto p-6 bg-base-200 rounded-xl shadow-lg text-center">
|
| 73 |
+
<form id="wordsForm" method="POST" class="flex flex-col gap-4">
|
| 74 |
+
{% csrf_token %}
|
| 75 |
+
<div class="grid lg:grid-cols-4 md:grid-cols-3 grid-cols-2 gap-4">
|
| 76 |
+
{% for word in words %}
|
| 77 |
+
<label
|
| 78 |
+
class="flex items-center justify-between bg-surface-sweet p-4 gap-2 rounded-lg shadow-sm hover:shadow-md transition-all">
|
| 79 |
+
<span class="text-lg font-medium">{{ word }}</span>
|
| 80 |
+
<input type="checkbox" name="word_{{ word.id }}" class="checkbox checkbox-primary"
|
| 81 |
+
data-word-id="{{ word.id }}" data-word-name="{{ word }}" />
|
| 82 |
+
</label>
|
| 83 |
+
{% empty %}
|
| 84 |
+
<p class="text-center text-gray-500">No hay palabras disponibles.</p>
|
| 85 |
+
{% endfor %}
|
| 86 |
+
</div>
|
| 87 |
+
<button type="submit" class="cts-btn-general cts-btn-primary btn-push mt-6">
|
| 88 |
+
Enviar calificaciones
|
| 89 |
+
</button>
|
| 90 |
+
</form>
|
| 91 |
+
</article>
|
| 92 |
+
|
| 93 |
+
<section id="confirmModal"
|
| 94 |
+
class="absolute w-full h-full left-0 top-0 flex justify-center items-center bg-gray-500/70 hidden">
|
| 95 |
+
<div class="absolute max-w-xl bg-surface-card shadow-lg rounded-lg p-4">
|
| 96 |
+
<div class="space-y-4">
|
| 97 |
+
<h3 class="font-bold text-lg mb-4">Confirma tu elección</h3>
|
| 98 |
+
<div id="confirmModalContent" class="space-y-2 max-h-60 overflow-y-auto">
|
| 99 |
+
</div>
|
| 100 |
+
<div>
|
| 101 |
+
<button id="cancelBtn" class="cts-btn-general-compress cts-btn-secondary btn-push py-1 px-4">
|
| 102 |
+
Cancelar
|
| 103 |
+
</button>
|
| 104 |
+
<button id="confirmBtn" class="cts-btn-general-compress cts-btn-primary btn-push py-1 px-4">
|
| 105 |
+
Confirmar
|
| 106 |
+
</button>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
</section>
|
| 111 |
+
|
| 112 |
+
</article>
|
| 113 |
+
</article>
|
| 114 |
+
{% endblock %}
|
| 115 |
+
|
| 116 |
+
{% block extra_js %}
|
| 117 |
+
<script src="{% static 'js/actions-form.js' %}"></script>
|
| 118 |
+
<script src="{% static 'js/test-cata.js' %}"></script>
|
| 119 |
+
{% endblock %}
|
tecnicas/templates/tecnicas/manage_sesions/detalles-sesion-cata.html
CHANGED
|
@@ -218,7 +218,7 @@
|
|
| 218 |
</p>
|
| 219 |
</section>
|
| 220 |
{% if existen_calificaciones %}
|
| 221 |
-
{% include "../components/
|
| 222 |
{% else %}
|
| 223 |
{% include "../components/error-message.html" with message='Sin calificaciones que mostrar aún' %}
|
| 224 |
{% endif %}
|
|
|
|
| 218 |
</p>
|
| 219 |
</section>
|
| 220 |
{% if existen_calificaciones %}
|
| 221 |
+
{% include "../components/table_cata.html" with calificaciones=calificaciones palabras=palabras sesion=sesion %}
|
| 222 |
{% else %}
|
| 223 |
{% include "../components/error-message.html" with message='Sin calificaciones que mostrar aún' %}
|
| 224 |
{% endif %}
|
tecnicas/templates/tecnicas/manage_sesions/detalles-sesion.html
CHANGED
|
@@ -260,7 +260,7 @@
|
|
| 260 |
Máximo valor por dato: <span class="font-bold">{{ scale.size }}</span>
|
| 261 |
</p>
|
| 262 |
</section>
|
| 263 |
-
{% include "../components/table-
|
| 264 |
</article>
|
| 265 |
{% else %}
|
| 266 |
{% include "../components/error-message.html" with message='Sin calificaciones que mostrar aún' %}
|
|
|
|
| 260 |
Máximo valor por dato: <span class="font-bold">{{ scale.size }}</span>
|
| 261 |
</p>
|
| 262 |
</section>
|
| 263 |
+
{% include "../components/table-scales.html" with calificaciones=calificaciones palabras=palabras sesion=sesion %}
|
| 264 |
</article>
|
| 265 |
{% else %}
|
| 266 |
{% include "../components/error-message.html" with message='Sin calificaciones que mostrar aún' %}
|
tecnicas/urls.py
CHANGED
|
@@ -110,6 +110,10 @@ urlpatterns = [
|
|
| 110 |
views.convencionalScales,
|
| 111 |
name="session_convencional"),
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
# APIs
|
| 115 |
path("presenter/api/nueva-etiqueta",
|
|
@@ -124,7 +128,11 @@ urlpatterns = [
|
|
| 124 |
views.wordsVocabulary,
|
| 125 |
name="api_palabras_vocabulary"),
|
| 126 |
|
| 127 |
-
path("testers/api/ratingword",
|
| 128 |
-
views.
|
| 129 |
-
name="
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
]
|
|
|
|
| 110 |
views.convencionalScales,
|
| 111 |
name="session_convencional"),
|
| 112 |
|
| 113 |
+
path("testers/init-session/<str:code_sesion>/cata",
|
| 114 |
+
views.cataTest,
|
| 115 |
+
name="session_cata"),
|
| 116 |
+
|
| 117 |
|
| 118 |
# APIs
|
| 119 |
path("presenter/api/nueva-etiqueta",
|
|
|
|
| 128 |
views.wordsVocabulary,
|
| 129 |
name="api_palabras_vocabulary"),
|
| 130 |
|
| 131 |
+
path("testers/api/ratingword/escalas",
|
| 132 |
+
views.ratingWordScales,
|
| 133 |
+
name="api_rating_word_scalas"),
|
| 134 |
+
|
| 135 |
+
path("testers/api/ratingword/cata",
|
| 136 |
+
views.ratingWordCata,
|
| 137 |
+
name="api_rating_word_cata"),
|
| 138 |
]
|
tecnicas/views/__init__.py
CHANGED
|
@@ -25,10 +25,12 @@ from .vocabulary_management.list_vocabulary import listVocabulary
|
|
| 25 |
from .apis.api_tag import newTag
|
| 26 |
from .apis.api_words import words
|
| 27 |
from .apis.api_words import wordsVocabulary
|
| 28 |
-
from .apis.
|
|
|
|
| 29 |
|
| 30 |
from .tester_forms.init_tester_form import initTesterForm
|
| 31 |
-
from .tester_forms.convencional_scales import convencionalScales
|
| 32 |
from .tester_forms.panel_main_tester import mainPanelTester
|
| 33 |
from .tester_forms.login_session import loginSessionTester
|
| 34 |
from .tester_forms.sessions_list_tester import sessionsListTester
|
|
|
|
|
|
|
|
|
| 25 |
from .apis.api_tag import newTag
|
| 26 |
from .apis.api_words import words
|
| 27 |
from .apis.api_words import wordsVocabulary
|
| 28 |
+
from .apis.rating_word_scales import ratingWordScales
|
| 29 |
+
from .apis.rating_word_cata import ratingWordCata
|
| 30 |
|
| 31 |
from .tester_forms.init_tester_form import initTesterForm
|
|
|
|
| 32 |
from .tester_forms.panel_main_tester import mainPanelTester
|
| 33 |
from .tester_forms.login_session import loginSessionTester
|
| 34 |
from .tester_forms.sessions_list_tester import sessionsListTester
|
| 35 |
+
from .tester_forms.convencional_scales import convencionalScales
|
| 36 |
+
from .tester_forms.cata_test import cataTest
|
tecnicas/views/apis/rating_word_cata.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest, JsonResponse
|
| 2 |
+
from tecnicas.utils import general_error
|
| 3 |
+
from tecnicas.controllers import RatingCataController
|
| 4 |
+
import json
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def ratingWordCata(req: HttpRequest):
|
| 8 |
+
if req.method == "POST":
|
| 9 |
+
try:
|
| 10 |
+
data = json.loads(req.body.decode("utf-8"))
|
| 11 |
+
raw_words = data.get("words", [])
|
| 12 |
+
raw_product = data.get("product", [])
|
| 13 |
+
|
| 14 |
+
response = RatingCataController.saveRatingWords(
|
| 15 |
+
request=req, data_words=raw_words, data_prodct=raw_product)
|
| 16 |
+
return response
|
| 17 |
+
return JsonResponse({"message": "Error procesando datos"})
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print("Error:", e)
|
| 20 |
+
return JsonResponse({"error": "Error procesando datos"}, status=400)
|
| 21 |
+
|
| 22 |
+
else:
|
| 23 |
+
return JsonResponse({"error": "Método no permitido"}, status=405)
|
tecnicas/views/apis/{rating_word.py → rating_word_scales.py}
RENAMED
|
@@ -28,12 +28,12 @@
|
|
| 28 |
* Calquier otro metodo que se maneje mandar un error
|
| 29 |
'''
|
| 30 |
from django.http import HttpRequest, JsonResponse
|
| 31 |
-
from tecnicas.controllers import
|
| 32 |
from tecnicas.utils import general_error
|
| 33 |
import json
|
| 34 |
|
| 35 |
|
| 36 |
-
def
|
| 37 |
if req.method == "POST":
|
| 38 |
if not req.POST["rating-word"] or not req.POST["id-word"] or not req.POST["id-product"]:
|
| 39 |
return JsonResponse({"error": "No se mandó información necesaria para la calificación"})
|
|
@@ -43,7 +43,7 @@ def reatingWord(req: HttpRequest):
|
|
| 43 |
received_id_product = json.loads(req.POST.get("id-product"))
|
| 44 |
id_technique = json.loads(req.POST.get("id-technique"))
|
| 45 |
|
| 46 |
-
view_controller =
|
| 47 |
rating_controller=CalificacionController(
|
| 48 |
technique=id_technique,
|
| 49 |
product=received_id_product,
|
|
@@ -60,4 +60,4 @@ def reatingWord(req: HttpRequest):
|
|
| 60 |
|
| 61 |
return JsonResponse(response_data)
|
| 62 |
else:
|
| 63 |
-
return general_error("No puede usar este método aquí")
|
|
|
|
| 28 |
* Calquier otro metodo que se maneje mandar un error
|
| 29 |
'''
|
| 30 |
from django.http import HttpRequest, JsonResponse
|
| 31 |
+
from tecnicas.controllers import RatingScalesController, CalificacionController, DatoController
|
| 32 |
from tecnicas.utils import general_error
|
| 33 |
import json
|
| 34 |
|
| 35 |
|
| 36 |
+
def ratingWordScales(req: HttpRequest):
|
| 37 |
if req.method == "POST":
|
| 38 |
if not req.POST["rating-word"] or not req.POST["id-word"] or not req.POST["id-product"]:
|
| 39 |
return JsonResponse({"error": "No se mandó información necesaria para la calificación"})
|
|
|
|
| 43 |
received_id_product = json.loads(req.POST.get("id-product"))
|
| 44 |
id_technique = json.loads(req.POST.get("id-technique"))
|
| 45 |
|
| 46 |
+
view_controller = RatingScalesController(
|
| 47 |
rating_controller=CalificacionController(
|
| 48 |
technique=id_technique,
|
| 49 |
product=received_id_product,
|
|
|
|
| 60 |
|
| 61 |
return JsonResponse(response_data)
|
| 62 |
else:
|
| 63 |
+
return general_error("No puede usar este método aquí")
|
tecnicas/views/sessions_management/session_details.py
CHANGED
|
@@ -35,8 +35,8 @@ def sessionDetails(req: HttpRequest, session_code: str):
|
|
| 35 |
},
|
| 36 |
name_view="cata_system:panel_sesiones"
|
| 37 |
)
|
| 38 |
-
|
| 39 |
return response
|
|
|
|
| 40 |
elif req.method == "POST":
|
| 41 |
sensorial_session = SesionSensorial.objects.get(
|
| 42 |
codigo_sesion=session_code)
|
|
|
|
| 35 |
},
|
| 36 |
name_view="cata_system:panel_sesiones"
|
| 37 |
)
|
|
|
|
| 38 |
return response
|
| 39 |
+
|
| 40 |
elif req.method == "POST":
|
| 41 |
sensorial_session = SesionSensorial.objects.get(
|
| 42 |
codigo_sesion=session_code)
|
tecnicas/views/sessions_management/session_monitor.py
CHANGED
|
@@ -47,7 +47,7 @@ def sessionMonitor(req: HttpRequest, session_code: str):
|
|
| 47 |
else:
|
| 48 |
response = controll_view.controlGetResponse(
|
| 49 |
request=req, error="No se ha definido la acción a realizar")
|
| 50 |
-
elif use_techinique == "rata":
|
| 51 |
controll_view = MonitorRATAController(sensorial_session)
|
| 52 |
action = req.POST["action"]
|
| 53 |
|
|
|
|
| 47 |
else:
|
| 48 |
response = controll_view.controlGetResponse(
|
| 49 |
request=req, error="No se ha definido la acción a realizar")
|
| 50 |
+
elif use_techinique == "rata" or use_techinique == "cata":
|
| 51 |
controll_view = MonitorRATAController(sensorial_session)
|
| 52 |
action = req.POST["action"]
|
| 53 |
|
tecnicas/views/tester_forms/cata_test.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from tecnicas.models import SesionSensorial
|
| 3 |
+
from tecnicas.controllers import TestCataController
|
| 4 |
+
from tecnicas.utils import noValidTechnique
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def cataTest(req: HttpRequest, code_sesion: str):
|
| 8 |
+
if req.method == "GET":
|
| 9 |
+
session = SesionSensorial.objects.get(codigo_sesion=code_sesion)
|
| 10 |
+
controll_view = TestCataController(
|
| 11 |
+
sensorial_session=session, user_tester=req.user.user_catador)
|
| 12 |
+
return controll_view.controllGet(request=req)
|
tecnicas/views/tester_forms/convencional_scales.py
CHANGED
|
@@ -55,21 +55,26 @@
|
|
| 55 |
- Cata segmento en el que se divide debe tener la etiqueda correspondiente por debajo
|
| 56 |
'''
|
| 57 |
from django.http import HttpRequest
|
| 58 |
-
from tecnicas.
|
|
|
|
| 59 |
from tecnicas.utils import noValidTechnique
|
| 60 |
|
| 61 |
|
| 62 |
def convencionalScales(req: HttpRequest, code_sesion: str):
|
| 63 |
-
session =
|
| 64 |
type_technique = session.tecnica.tipo_tecnica.nombre_tecnica
|
| 65 |
|
| 66 |
if req.method == "GET":
|
| 67 |
-
view_controller = ConvencionalScalesController(
|
| 68 |
-
sensorial_session=session, user_tester=req.user.user_catador)
|
| 69 |
if type_technique == "escalas":
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
elif type_technique == "rata":
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
else:
|
| 74 |
respose = noValidTechnique(
|
| 75 |
name_view='cata_system:catador_init_session',
|
|
|
|
| 55 |
- Cata segmento en el que se divide debe tener la etiqueda correspondiente por debajo
|
| 56 |
'''
|
| 57 |
from django.http import HttpRequest
|
| 58 |
+
from tecnicas.models import SesionSensorial
|
| 59 |
+
from tecnicas.controllers import TestRataController, TestScalesController
|
| 60 |
from tecnicas.utils import noValidTechnique
|
| 61 |
|
| 62 |
|
| 63 |
def convencionalScales(req: HttpRequest, code_sesion: str):
|
| 64 |
+
session = SesionSensorial.objects.get(codigo_sesion=code_sesion)
|
| 65 |
type_technique = session.tecnica.tipo_tecnica.nombre_tecnica
|
| 66 |
|
| 67 |
if req.method == "GET":
|
|
|
|
|
|
|
| 68 |
if type_technique == "escalas":
|
| 69 |
+
view_controller = TestScalesController(
|
| 70 |
+
sensorial_session=session, user_tester=req.user.user_catador)
|
| 71 |
+
respose = view_controller.controllGet(request=req)
|
| 72 |
+
|
| 73 |
elif type_technique == "rata":
|
| 74 |
+
view_controller = TestRataController(
|
| 75 |
+
sensorial_session=session, user_tester=req.user.user_catador)
|
| 76 |
+
respose = view_controller.controllGet(request=req)
|
| 77 |
+
|
| 78 |
else:
|
| 79 |
respose = noValidTechnique(
|
| 80 |
name_view='cata_system:catador_init_session',
|
tecnicas/views/tester_forms/init_tester_form.py
CHANGED
|
@@ -28,8 +28,9 @@ def initTesterForm(req: HttpRequest, code_sesion: str):
|
|
| 28 |
|
| 29 |
return response
|
| 30 |
elif req.method == "POST":
|
| 31 |
-
if type_technique == "escalas" or type_technique == "rata":
|
| 32 |
response = view_controller.controllPostEscalas(request=req)
|
|
|
|
| 33 |
else:
|
| 34 |
context = {
|
| 35 |
"session": session,
|
|
|
|
| 28 |
|
| 29 |
return response
|
| 30 |
elif req.method == "POST":
|
| 31 |
+
if type_technique == "escalas" or type_technique == "rata" or type_technique == "cata":
|
| 32 |
response = view_controller.controllPostEscalas(request=req)
|
| 33 |
+
|
| 34 |
else:
|
| 35 |
context = {
|
| 36 |
"session": session,
|