Spaces:
Sleeping
Sleeping
Ingreso a sesion con tecnica RATA
Browse files- tecnicas/controllers/__init__.py +1 -0
- tecnicas/controllers/views_controller/api_rating_controller.py +1 -1
- tecnicas/controllers/views_controller/session_management/details_escala_controller.py +12 -10
- tecnicas/controllers/views_controller/sessions_tester/convencional_scales_controller.py +149 -0
- tecnicas/controllers/views_controller/sessions_tester/init_session_tester_controller.py +3 -0
- tecnicas/models/dato.py +1 -1
- tecnicas/static/js/created-scale.js +2 -0
- tecnicas/templates/tecnicas/forms_tester/convencional.html +15 -9
- tecnicas/utils/general_controllers.py +2 -2
- tecnicas/views/apis/rating_word.py +5 -4
- tecnicas/views/sessions_management/session_details.py +1 -1
- tecnicas/views/tester_forms/convencional_scales.py +15 -74
tecnicas/controllers/__init__.py
CHANGED
|
@@ -26,6 +26,7 @@ from .views_controller.session_management.monitor_escalas_controller import Moni
|
|
| 26 |
|
| 27 |
from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
|
| 28 |
from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
|
|
|
|
| 29 |
|
| 30 |
from .views_controller.api_rating_controller import ApiRatingController
|
| 31 |
from .views_controller.tester_list_controller import TesterListController
|
|
|
|
| 26 |
|
| 27 |
from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
|
| 28 |
from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
|
| 29 |
+
from .views_controller.sessions_tester.convencional_scales_controller import ConvencionalScalesController
|
| 30 |
|
| 31 |
from .views_controller.api_rating_controller import ApiRatingController
|
| 32 |
from .views_controller.tester_list_controller import TesterListController
|
tecnicas/controllers/views_controller/api_rating_controller.py
CHANGED
|
@@ -40,7 +40,7 @@ class ApiRatingController():
|
|
| 40 |
if isinstance(value, dict):
|
| 41 |
return controller_error(value["error"])
|
| 42 |
|
| 43 |
-
def
|
| 44 |
validate = self.rating_controller.validateRating()
|
| 45 |
if isinstance(validate, dict):
|
| 46 |
return controller_error(validate["error"])
|
|
|
|
| 40 |
if isinstance(value, dict):
|
| 41 |
return controller_error(value["error"])
|
| 42 |
|
| 43 |
+
def controllPostScales(self) -> dict:
|
| 44 |
validate = self.rating_controller.validateRating()
|
| 45 |
if isinstance(validate, dict):
|
| 46 |
return controller_error(validate["error"])
|
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,
|
| 18 |
from tecnicas.controllers import DatoController, CalificacionController, PalabrasController, ParticipacionController
|
| 19 |
from .details_controller import DetallesController
|
| 20 |
from tecnicas.utils import defaultdict_to_dict, controller_error
|
|
@@ -85,23 +85,25 @@ class DetallesEscalasController(DetallesController):
|
|
| 85 |
|
| 86 |
return self.context
|
| 87 |
|
| 88 |
-
def startRepetition(self, presenter: Presentador):
|
| 89 |
creator = presenter
|
| 90 |
technique = self.session.tecnica
|
| 91 |
|
| 92 |
if creator.user.username != self.session.creadoPor.user.username:
|
| 93 |
-
return self.getResponse(error="Solo el presentador que crea la sesión puede iniciar la repetición")
|
| 94 |
elif self.session.activo:
|
| 95 |
-
return self.getResponse(error="La sesión ya está activada")
|
| 96 |
elif technique.repeticion >= technique.repeticiones_max:
|
| 97 |
-
return self.getResponse(error="Se ha alcanzado el número de repeticiones máxima")
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
-
if not is_update_participations:
|
| 103 |
-
return self.getResponse(error=message)
|
| 104 |
-
|
| 105 |
self.session.activo = True
|
| 106 |
technique.repeticion = technique.repeticion + 1
|
| 107 |
|
|
|
|
| 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
|
| 18 |
from tecnicas.controllers import DatoController, CalificacionController, PalabrasController, ParticipacionController
|
| 19 |
from .details_controller import DetallesController
|
| 20 |
from tecnicas.utils import defaultdict_to_dict, controller_error
|
|
|
|
| 85 |
|
| 86 |
return self.context
|
| 87 |
|
| 88 |
+
def startRepetition(self, presenter: Presentador, request: HttpRequest):
|
| 89 |
creator = presenter
|
| 90 |
technique = self.session.tecnica
|
| 91 |
|
| 92 |
if creator.user.username != self.session.creadoPor.user.username:
|
| 93 |
+
return self.getResponse(error="Solo el presentador que crea la sesión puede iniciar la repetición", request=request)
|
| 94 |
elif self.session.activo:
|
| 95 |
+
return self.getResponse(error="La sesión ya está activada", request=request)
|
| 96 |
elif technique.repeticion >= technique.repeticiones_max:
|
| 97 |
+
return self.getResponse(error="Se ha alcanzado el número de repeticiones máxima", request=request)
|
| 98 |
+
|
| 99 |
+
there_participacions = Participacion.objects.filter(tecnica=technique).exists()
|
| 100 |
|
| 101 |
+
if there_participacions:
|
| 102 |
+
(is_update_participations,
|
| 103 |
+
message) = ParticipacionController.outAllInSession(self.session)
|
| 104 |
+
if not is_update_participations:
|
| 105 |
+
return self.getResponse(error=message, request=request)
|
| 106 |
|
|
|
|
|
|
|
|
|
|
| 107 |
self.session.activo = True
|
| 108 |
technique.repeticion = technique.repeticion + 1
|
| 109 |
|
tecnicas/controllers/views_controller/sessions_tester/convencional_scales_controller.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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, Participacion, Producto
|
| 5 |
+
from tecnicas.controllers import PosicionController, CalificacionController, ParticipacionController, PalabrasController, EscalaController, DatoController
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class ConvencionalScalesController:
|
| 9 |
+
context = {}
|
| 10 |
+
current_directory = "tecnicas/forms_tester/convencional.html"
|
| 11 |
+
|
| 12 |
+
def __init__(self, sensorial_session: SesionSensorial, user_tester: Catador):
|
| 13 |
+
self.tester = user_tester
|
| 14 |
+
self.session = sensorial_session
|
| 15 |
+
|
| 16 |
+
def controllGetEscalas(self, request: HttpRequest):
|
| 17 |
+
technique = self.session.tecnica
|
| 18 |
+
self.participation = Participacion.objects.get(
|
| 19 |
+
tecnica=technique, catador=request.user.user_catador)
|
| 20 |
+
|
| 21 |
+
self.context["session"] = self.session
|
| 22 |
+
|
| 23 |
+
positions = PosicionController.getPostionsInOrder(
|
| 24 |
+
id_order=request.session["id_order"])
|
| 25 |
+
|
| 26 |
+
sorted_positions = sorted(positions, key=lambda posi: posi.posicion)
|
| 27 |
+
|
| 28 |
+
words = PalabrasController.getWordsInTechnique(technique=technique)
|
| 29 |
+
|
| 30 |
+
next_position = CalificacionController.checkProducsWithoutRating(
|
| 31 |
+
positions=sorted_positions,
|
| 32 |
+
user_cata=request.user.username,
|
| 33 |
+
id_technique=technique.id,
|
| 34 |
+
repetition=technique.repeticion,
|
| 35 |
+
technique=technique,
|
| 36 |
+
num_words=len(words)
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
if isinstance(next_position, dict):
|
| 40 |
+
updated_participation = ParticipacionController.finishSession(
|
| 41 |
+
self.participation)
|
| 42 |
+
params = {
|
| 43 |
+
"code_sesion": self.session.codigo_sesion
|
| 44 |
+
}
|
| 45 |
+
return redirect(reverse('cata_system:catador_init_session', kwargs=params))
|
| 46 |
+
|
| 47 |
+
if isinstance(next_position, list):
|
| 48 |
+
next_position = next_position[0]
|
| 49 |
+
|
| 50 |
+
self.context["product"] = next_position.id_producto
|
| 51 |
+
|
| 52 |
+
ratings_product = CalificacionController.getRatings(
|
| 53 |
+
technique=technique,
|
| 54 |
+
product=next_position.id_producto,
|
| 55 |
+
repetition=technique.repeticion,
|
| 56 |
+
user_tester=request.user.username
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
if isinstance(ratings_product, dict):
|
| 60 |
+
self.context["error"] = ratings_product["error"]
|
| 61 |
+
return render(request, self.current_directory, self.context)
|
| 62 |
+
elif not ratings_product:
|
| 63 |
+
self.context["words"] = words
|
| 64 |
+
else:
|
| 65 |
+
recoreded_data = DatoController.getRerecordedData(
|
| 66 |
+
ratings=ratings_product)
|
| 67 |
+
if not recoreded_data:
|
| 68 |
+
self.context["words"] = words
|
| 69 |
+
else:
|
| 70 |
+
words_to_use = PalabrasController.getWordsWithoutData(
|
| 71 |
+
recoreded_data=recoreded_data, words=words)
|
| 72 |
+
self.context["words"] = words_to_use
|
| 73 |
+
|
| 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 |
+
print(self.context)
|
| 82 |
+
return render(request, self.current_directory, self.context)
|
| 83 |
+
|
| 84 |
+
def controllGetRATA(self, request: HttpRequest):
|
| 85 |
+
technique = self.session.tecnica
|
| 86 |
+
self.participation = Participacion.objects.get(
|
| 87 |
+
tecnica=technique, catador=request.user.user_catador)
|
| 88 |
+
|
| 89 |
+
self.context["session"] = self.session
|
| 90 |
+
|
| 91 |
+
products_in_technique = Producto.objects.filter(id_tecnica=technique)
|
| 92 |
+
|
| 93 |
+
words = PalabrasController.getWordsInTechnique(technique=technique)
|
| 94 |
+
|
| 95 |
+
# Revisamos el producto que le falten calificaciones
|
| 96 |
+
for product_in in products_in_technique:
|
| 97 |
+
ratings_product = CalificacionController.getRatings(
|
| 98 |
+
technique=technique,
|
| 99 |
+
product=product_in,
|
| 100 |
+
repetition=technique.repeticion,
|
| 101 |
+
user_tester=request.user.username
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
if isinstance(ratings_product, dict):
|
| 105 |
+
self.context["error"] = ratings_product.get("error")
|
| 106 |
+
return render(request, self.current_directory, self.context)
|
| 107 |
+
|
| 108 |
+
# Sin calificaciones mandamos el producto actual y todas la palabras
|
| 109 |
+
if not ratings_product:
|
| 110 |
+
self.context["product"] = product_in
|
| 111 |
+
self.context["words"] = words
|
| 112 |
+
break
|
| 113 |
+
|
| 114 |
+
# Obtener los datos asociados parala calificacion para ver que palabras quedan por calificar
|
| 115 |
+
recoreded_data = DatoController.getRerecordedData(ratings=ratings_product)
|
| 116 |
+
|
| 117 |
+
if not recoreded_data:
|
| 118 |
+
# Si no hay datos entonces devolver el producto con todas las palabras
|
| 119 |
+
self.context["product"] = product_in
|
| 120 |
+
self.context["words"] = words
|
| 121 |
+
break
|
| 122 |
+
else:
|
| 123 |
+
words_to_use = PalabrasController.getWordsWithoutData(
|
| 124 |
+
recoreded_data=recoreded_data, words=words)
|
| 125 |
+
|
| 126 |
+
# Si quedan palabras por calificar mandar las palabras con el producto
|
| 127 |
+
if not isinstance(words_to_use, dict) and words_to_use:
|
| 128 |
+
self.context["product"] = product_in
|
| 129 |
+
self.context["words"] = words_to_use
|
| 130 |
+
break
|
| 131 |
+
|
| 132 |
+
# Si no hay producto que falta por calificar finalizar sesion para el Catador
|
| 133 |
+
if "product" not in self.context:
|
| 134 |
+
updated_participation = ParticipacionController.finishSession(
|
| 135 |
+
self.participation)
|
| 136 |
+
params = {
|
| 137 |
+
"code_sesion": self.session.codigo_sesion
|
| 138 |
+
}
|
| 139 |
+
return redirect(reverse('cata_system:catador_init_session', kwargs=params))
|
| 140 |
+
|
| 141 |
+
# Agregar informacion de la escala
|
| 142 |
+
scale = EscalaController.getScaleByTechnique(technique=technique)
|
| 143 |
+
self.context["scale"] = scale
|
| 144 |
+
self.context["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 145 |
+
|
| 146 |
+
use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 147 |
+
self.context["tags"] = use_tags
|
| 148 |
+
|
| 149 |
+
return render(request, self.current_directory, self.context)
|
tecnicas/controllers/views_controller/sessions_tester/init_session_tester_controller.py
CHANGED
|
@@ -37,6 +37,9 @@ class InitSessionTesterController():
|
|
| 37 |
if is_end:
|
| 38 |
context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
|
| 39 |
|
|
|
|
|
|
|
|
|
|
| 40 |
return render(request, self.current_direction, context)
|
| 41 |
|
| 42 |
def controllPostEscalas(self, request: HttpRequest):
|
|
|
|
| 37 |
if is_end:
|
| 38 |
context["message"] = "El catador ha terminado de realizar su evaluación, espere instrucciones del presentador"
|
| 39 |
|
| 40 |
+
if "error" in request.GET:
|
| 41 |
+
context["error"] = request.GET["error"]
|
| 42 |
+
|
| 43 |
return render(request, self.current_direction, context)
|
| 44 |
|
| 45 |
def controllPostEscalas(self, request: HttpRequest):
|
tecnicas/models/dato.py
CHANGED
|
@@ -11,4 +11,4 @@ class Dato(models.Model):
|
|
| 11 |
Calificacion, on_delete=models.CASCADE, related_name="dato_calificacion")
|
| 12 |
|
| 13 |
def __str__(self):
|
| 14 |
-
return f"{self.id_palabra.nombre_palabra} - {self.id_calificacion.id_producto.codigoProducto} - {self.id_calificacion.id_catador.
|
|
|
|
| 11 |
Calificacion, on_delete=models.CASCADE, related_name="dato_calificacion")
|
| 12 |
|
| 13 |
def __str__(self):
|
| 14 |
+
return f"{self.id_calificacion.id_tecnica.sesion_tecnica} - {self.id_palabra.nombre_palabra} - {self.id_calificacion.id_producto.codigoProducto} - {self.id_calificacion.id_catador.user.username}"
|
tecnicas/static/js/created-scale.js
CHANGED
|
@@ -54,11 +54,13 @@ async function sendRating(word) {
|
|
| 54 |
.querySelector(".id-product").textContent;
|
| 55 |
|
| 56 |
const idWord = formRatingWord.querySelector(".id-word").textContent;
|
|
|
|
| 57 |
|
| 58 |
dataForm.set("code-product", codeProduct);
|
| 59 |
dataForm.set("id-product", idProduct);
|
| 60 |
dataForm.set("name-word", word);
|
| 61 |
dataForm.set("id-word", idWord);
|
|
|
|
| 62 |
|
| 63 |
try {
|
| 64 |
const respone = await fetch(url, {
|
|
|
|
| 54 |
.querySelector(".id-product").textContent;
|
| 55 |
|
| 56 |
const idWord = formRatingWord.querySelector(".id-word").textContent;
|
| 57 |
+
const idTechnique = document.querySelector(".ct-input-id-tech").value
|
| 58 |
|
| 59 |
dataForm.set("code-product", codeProduct);
|
| 60 |
dataForm.set("id-product", idProduct);
|
| 61 |
dataForm.set("name-word", word);
|
| 62 |
dataForm.set("id-word", idWord);
|
| 63 |
+
dataForm.set("id-technique", idTechnique);
|
| 64 |
|
| 65 |
try {
|
| 66 |
const respone = await fetch(url, {
|
tecnicas/templates/tecnicas/forms_tester/convencional.html
CHANGED
|
@@ -53,6 +53,10 @@
|
|
| 53 |
</form>
|
| 54 |
</article>
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
{% if error %}
|
| 57 |
<hr>
|
| 58 |
<article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
|
|
@@ -97,15 +101,17 @@
|
|
| 97 |
|
| 98 |
<article
|
| 99 |
class="scales-container [&>*:not(:last-child)]:mb-5 min-lg:grid min-lg:items-start grid-cols-2 gap-3 justify-center items-center">
|
| 100 |
-
{%
|
| 101 |
-
{%
|
| 102 |
-
{%
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
{%
|
| 106 |
-
{%
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
| 109 |
</article>
|
| 110 |
</article>
|
| 111 |
</article>
|
|
|
|
| 53 |
</form>
|
| 54 |
</article>
|
| 55 |
|
| 56 |
+
<section class="hidden">
|
| 57 |
+
<input type="hidden" value="{{ session.tecnica.id }}" name="id-tecnica" class="ct-input-id-tech">
|
| 58 |
+
</section>
|
| 59 |
+
|
| 60 |
{% if error %}
|
| 61 |
<hr>
|
| 62 |
<article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
|
|
|
|
| 101 |
|
| 102 |
<article
|
| 103 |
class="scales-container [&>*:not(:last-child)]:mb-5 min-lg:grid min-lg:items-start grid-cols-2 gap-3 justify-center items-center">
|
| 104 |
+
{% with path_con="../components/form-scale-continue.html" path_str="../components/form-scale-structure.html" %}
|
| 105 |
+
{% if type_scale == "continua" %}
|
| 106 |
+
{% for word in words %}
|
| 107 |
+
{% include path_con with word=word tags=tags scale=scale id_tecnica=session.tecnica.id %}
|
| 108 |
+
{% endfor %}
|
| 109 |
+
{% elif type_scale == "estructurada" %}
|
| 110 |
+
{% for word in words %}
|
| 111 |
+
{% include path_str with word=word tags=tags scale=scale %}
|
| 112 |
+
{% endfor %}
|
| 113 |
+
{% endif %}
|
| 114 |
+
{% endwith %}
|
| 115 |
</article>
|
| 116 |
</article>
|
| 117 |
</article>
|
tecnicas/utils/general_controllers.py
CHANGED
|
@@ -17,7 +17,7 @@ def getId(value: object | int) -> int | None:
|
|
| 17 |
def noValidTechnique(params: dict, query_params: dict, name_view: str):
|
| 18 |
if query_params:
|
| 19 |
query_string = urlencode(query_params)
|
| 20 |
-
url_redireccion = f"{reverse(
|
| 21 |
else:
|
| 22 |
-
url_redireccion = f"{reverse(
|
| 23 |
return redirect(url_redireccion)
|
|
|
|
| 17 |
def noValidTechnique(params: dict, query_params: dict, name_view: str):
|
| 18 |
if query_params:
|
| 19 |
query_string = urlencode(query_params)
|
| 20 |
+
url_redireccion = f"{reverse(name_view, kwargs=params)}?{query_string}"
|
| 21 |
else:
|
| 22 |
+
url_redireccion = f"{reverse(name_view, kwargs=params)}"
|
| 23 |
return redirect(url_redireccion)
|
tecnicas/views/apis/rating_word.py
CHANGED
|
@@ -28,8 +28,8 @@
|
|
| 28 |
* Calquier otro metodo que se maneje mandar un error
|
| 29 |
'''
|
| 30 |
from django.http import HttpRequest, JsonResponse
|
| 31 |
-
from
|
| 32 |
-
from
|
| 33 |
import json
|
| 34 |
|
| 35 |
|
|
@@ -41,10 +41,11 @@ def reatingWord(req: HttpRequest):
|
|
| 41 |
received_rating = json.loads(req.POST.get("rating-word"))
|
| 42 |
received_id_word = json.loads(req.POST.get("id-word"))
|
| 43 |
received_id_product = json.loads(req.POST.get("id-product"))
|
|
|
|
| 44 |
|
| 45 |
view_controller = ApiRatingController(
|
| 46 |
rating_controller=CalificacionController(
|
| 47 |
-
technique=
|
| 48 |
product=received_id_product,
|
| 49 |
tester=req.user.user_catador
|
| 50 |
),
|
|
@@ -55,7 +56,7 @@ def reatingWord(req: HttpRequest):
|
|
| 55 |
)
|
| 56 |
)
|
| 57 |
|
| 58 |
-
response_data = view_controller.
|
| 59 |
|
| 60 |
return JsonResponse(response_data)
|
| 61 |
else:
|
|
|
|
| 28 |
* Calquier otro metodo que se maneje mandar un error
|
| 29 |
'''
|
| 30 |
from django.http import HttpRequest, JsonResponse
|
| 31 |
+
from tecnicas.controllers import ApiRatingController, CalificacionController, DatoController
|
| 32 |
+
from tecnicas.utils import general_error
|
| 33 |
import json
|
| 34 |
|
| 35 |
|
|
|
|
| 41 |
received_rating = json.loads(req.POST.get("rating-word"))
|
| 42 |
received_id_word = json.loads(req.POST.get("id-word"))
|
| 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 = ApiRatingController(
|
| 47 |
rating_controller=CalificacionController(
|
| 48 |
+
technique=id_technique,
|
| 49 |
product=received_id_product,
|
| 50 |
tester=req.user.user_catador
|
| 51 |
),
|
|
|
|
| 56 |
)
|
| 57 |
)
|
| 58 |
|
| 59 |
+
response_data = view_controller.controllPostScales()
|
| 60 |
|
| 61 |
return JsonResponse(response_data)
|
| 62 |
else:
|
tecnicas/views/sessions_management/session_details.py
CHANGED
|
@@ -42,7 +42,7 @@ def sessionDetails(req: HttpRequest, session_code: str):
|
|
| 42 |
|
| 43 |
if req.POST["action"] == "start_session":
|
| 44 |
response = controller_view.startRepetition(
|
| 45 |
-
presenter=req.user.user_presentador)
|
| 46 |
elif req.POST.get("action") == "delete_session":
|
| 47 |
controller_view.deleteSesorialSession()
|
| 48 |
response = redirect(
|
|
|
|
| 42 |
|
| 43 |
if req.POST["action"] == "start_session":
|
| 44 |
response = controller_view.startRepetition(
|
| 45 |
+
presenter=req.user.user_presentador, request=req)
|
| 46 |
elif req.POST.get("action") == "delete_session":
|
| 47 |
controller_view.deleteSesorialSession()
|
| 48 |
response = redirect(
|
tecnicas/views/tester_forms/convencional_scales.py
CHANGED
|
@@ -55,85 +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
|
| 59 |
-
from
|
| 60 |
-
from urllib.parse import urlencode
|
| 61 |
-
from tecnicas.models import Participacion
|
| 62 |
-
from tecnicas.controllers import SesionController, PosicionController, CalificacionController, ParticipacionController, PalabrasController, EscalaController, DatoController
|
| 63 |
|
| 64 |
|
| 65 |
def convencionalScales(req: HttpRequest, code_sesion: str):
|
| 66 |
-
if not "id_order" in req.session:
|
| 67 |
-
return redirect(reverse("cata_system:catador_main"))
|
| 68 |
-
|
| 69 |
session = SesionController.getSessionByCode(code_sesion)
|
| 70 |
-
|
| 71 |
-
participation = Participacion.objects.get(
|
| 72 |
-
tecnica=technique, catador=req.user.user_catador)
|
| 73 |
-
|
| 74 |
-
context = {
|
| 75 |
-
"session": session
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
req.session["id_technique"] = session.tecnica.id
|
| 79 |
|
| 80 |
if req.method == "GET":
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
next_position = CalificacionController.checkProducsWithoutRating(
|
| 89 |
-
positions=sorted_positions,
|
| 90 |
-
user_cata=req.user.username,
|
| 91 |
-
id_technique=session.tecnica.id,
|
| 92 |
-
repetition=session.tecnica.repeticion,
|
| 93 |
-
technique=technique,
|
| 94 |
-
num_words=len(words)
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
if isinstance(next_position, dict):
|
| 98 |
-
updated_participation = ParticipacionController.finishSession(
|
| 99 |
-
participation)
|
| 100 |
-
params = {
|
| 101 |
-
"code_sesion": code_sesion
|
| 102 |
-
}
|
| 103 |
-
return redirect(reverse('cata_system:catador_init_session', kwargs=params))
|
| 104 |
-
|
| 105 |
-
if isinstance(next_position, list):
|
| 106 |
-
next_position = next_position[0]
|
| 107 |
-
|
| 108 |
-
context["product"] = next_position.id_producto
|
| 109 |
-
|
| 110 |
-
ratings_product = CalificacionController.getRatings(
|
| 111 |
-
technique=technique,
|
| 112 |
-
product=next_position.id_producto,
|
| 113 |
-
repetition=technique.repeticion,
|
| 114 |
-
user_tester=req.user.username
|
| 115 |
-
)
|
| 116 |
-
|
| 117 |
-
if isinstance(ratings_product, dict):
|
| 118 |
-
context["error"] = ratings_product["error"]
|
| 119 |
-
return render(req, "tecnicas/forms_tester/convencional.html", context)
|
| 120 |
-
elif not ratings_product:
|
| 121 |
-
context["words"] = words
|
| 122 |
else:
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
words_to_use = PalabrasController.getWordsWithoutData(
|
| 129 |
-
recoreded_data=recoreded_data, words=words)
|
| 130 |
-
context["words"] = words_to_use
|
| 131 |
-
|
| 132 |
-
scale = EscalaController.getScaleByTechnique(technique=technique)
|
| 133 |
-
context["scale"] = scale
|
| 134 |
-
context["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 135 |
-
|
| 136 |
-
use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 137 |
-
context["tags"] = use_tags
|
| 138 |
|
| 139 |
-
return
|
|
|
|
| 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.controllers import SesionController, ConvencionalScalesController
|
| 59 |
+
from tecnicas.utils import noValidTechnique
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
def convencionalScales(req: HttpRequest, code_sesion: str):
|
|
|
|
|
|
|
|
|
|
| 63 |
session = SesionController.getSessionByCode(code_sesion)
|
| 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 |
+
respose = view_controller.controllGetEscalas(request=req)
|
| 71 |
+
elif type_technique == "rata":
|
| 72 |
+
respose = view_controller.controllGetRATA(request=req)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
else:
|
| 74 |
+
respose = noValidTechnique(
|
| 75 |
+
name_view='cata_system:catador_init_session',
|
| 76 |
+
params={"code_sesion": session.codigo_sesion},
|
| 77 |
+
query_params={"error": "No es posible poder usar esta técnica"}
|
| 78 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
+
return respose
|