Spaces:
Running
Running
Aplicada funcion para finalizar tecnica RATA
Browse files- tecnicas/controllers/__init__.py +1 -0
- tecnicas/controllers/views_controller/session_management/monitor_controller.py +54 -1
- tecnicas/controllers/views_controller/session_management/monitor_escalas_controller.py +18 -62
- tecnicas/controllers/views_controller/session_management/monitor_rata_controller.py +46 -0
- tecnicas/views/sessions_management/session_monitor.py +13 -2
tecnicas/controllers/__init__.py
CHANGED
|
@@ -23,6 +23,7 @@ from .views_controller.session_management.details_escala_controller import Detal
|
|
| 23 |
from .views_controller.session_management.details_rata_controller import DetallesRATAController
|
| 24 |
from .views_controller.session_management.monitor_controller import MonitorController
|
| 25 |
from .views_controller.session_management.monitor_escalas_controller import MonitorEscalasController
|
|
|
|
| 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
|
|
|
|
| 23 |
from .views_controller.session_management.details_rata_controller import DetallesRATAController
|
| 24 |
from .views_controller.session_management.monitor_controller import MonitorController
|
| 25 |
from .views_controller.session_management.monitor_escalas_controller import MonitorEscalasController
|
| 26 |
+
from .views_controller.session_management.monitor_rata_controller import MonitorRATAController
|
| 27 |
|
| 28 |
from .views_controller.sessions_tester.login_session_tester_controller import LoginSessionTesterController
|
| 29 |
from .views_controller.sessions_tester.init_session_tester_controller import InitSessionTesterController
|
tecnicas/controllers/views_controller/session_management/monitor_controller.py
CHANGED
|
@@ -1,6 +1,59 @@
|
|
| 1 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
|
| 4 |
class MonitorController():
|
|
|
|
|
|
|
|
|
|
| 5 |
def __init__(self, session: SesionSensorial):
|
| 6 |
self.sensorial_session = session
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import render
|
| 3 |
+
from tecnicas.models import SesionSensorial, Producto, EsAtributo, EsVocabulario
|
| 4 |
+
from tecnicas.controllers import ParticipacionController, SesionController
|
| 5 |
+
from tecnicas.utils import controller_error
|
| 6 |
|
| 7 |
|
| 8 |
class MonitorController():
|
| 9 |
+
url_view: str
|
| 10 |
+
previus_view: str
|
| 11 |
+
|
| 12 |
def __init__(self, session: SesionSensorial):
|
| 13 |
self.sensorial_session = session
|
| 14 |
+
|
| 15 |
+
def setContext(self):
|
| 16 |
+
self.participations = ParticipacionController.getParticipationsInTechinique(
|
| 17 |
+
self.sensorial_session.tecnica)
|
| 18 |
+
|
| 19 |
+
self.context = {
|
| 20 |
+
"code_session": self.sensorial_session.codigo_sesion,
|
| 21 |
+
"session_name": self.sensorial_session.nombre_sesion,
|
| 22 |
+
"max_testers": self.sensorial_session.tecnica.limite_catadores,
|
| 23 |
+
"current_testers": len(self.participations),
|
| 24 |
+
"active_testers": len([part for part in self.participations if part.activo]),
|
| 25 |
+
"participations": self.participations,
|
| 26 |
+
"use_technique": self.sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
def controlGetResponse(self, request: HttpRequest, error: str = "", message: str = ""):
|
| 30 |
+
self.setContext()
|
| 31 |
+
|
| 32 |
+
if error != "" or error:
|
| 33 |
+
self.context["error"] = error
|
| 34 |
+
if message != "" or message:
|
| 35 |
+
self.context["message"] = message
|
| 36 |
+
|
| 37 |
+
return render(request, self.url_view, self.context)
|
| 38 |
+
|
| 39 |
+
def getExpectedRatingsEscalasRapida(self):
|
| 40 |
+
num_products = Producto.objects.filter(
|
| 41 |
+
id_tecnica=self.sensorial_session.tecnica).count()
|
| 42 |
+
style_words = self.sensorial_session.tecnica.id_estilo
|
| 43 |
+
num_words: int
|
| 44 |
+
|
| 45 |
+
if style_words.nombre_estilo == "atributos":
|
| 46 |
+
num_words = EsAtributo.objects.get(
|
| 47 |
+
id_tecnica=self.sensorial_session.tecnica).palabras.count()
|
| 48 |
+
elif style_words.nombre_estilo == "vocabulario":
|
| 49 |
+
num_words = EsVocabulario.objects.get(
|
| 50 |
+
id_tecnica=self.sensorial_session.tecnica).id_vocabulario.palabras.count()
|
| 51 |
+
|
| 52 |
+
return num_products * num_words
|
| 53 |
+
|
| 54 |
+
def finishSession(self):
|
| 55 |
+
response = SesionController.finishRepetion(self.sensorial_session)
|
| 56 |
+
if isinstance(response, dict):
|
| 57 |
+
return controller_error(response["error"])
|
| 58 |
+
self.sensorial_session.refresh_from_db()
|
| 59 |
+
return self.sensorial_session
|
tecnicas/controllers/views_controller/session_management/monitor_escalas_controller.py
CHANGED
|
@@ -1,93 +1,49 @@
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
-
from tecnicas.models import
|
| 5 |
-
from tecnicas.controllers import
|
| 6 |
-
from tecnicas.utils import controller_error
|
| 7 |
from .monitor_controller import MonitorController
|
| 8 |
|
| 9 |
|
| 10 |
class MonitorEscalasController(MonitorController):
|
| 11 |
-
url_view = "tecnicas/manage_sesions/monitor-sesion.html"
|
| 12 |
-
|
| 13 |
def __init__(self, session: SesionController):
|
| 14 |
super().__init__(session)
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
def
|
| 17 |
-
self.setContext()
|
| 18 |
-
|
| 19 |
-
if error != "" or error:
|
| 20 |
-
self.context["error"] = error
|
| 21 |
-
if message != "" or message:
|
| 22 |
-
self.context["message"] = message
|
| 23 |
-
|
| 24 |
-
return render(request, self.url_view, self.context)
|
| 25 |
-
|
| 26 |
-
def controlPostResponseFinishSession(self, request: HttpRequest):
|
| 27 |
self.setContext()
|
| 28 |
-
(is_all_end, message) = self.
|
| 29 |
if not is_all_end:
|
| 30 |
self.context["error"] = message
|
| 31 |
-
return render(request,
|
| 32 |
response = self.finishSession()
|
| 33 |
if isinstance(response, dict):
|
| 34 |
self.context["error"] = response["error"]
|
| 35 |
-
return render(request,
|
| 36 |
self.context["message"] = message
|
| 37 |
-
return redirect(reverse(
|
| 38 |
-
|
| 39 |
-
def setContext(self):
|
| 40 |
-
self.participations = ParticipacionController.getParticipationsInTechinique(
|
| 41 |
-
self.sensorial_session.tecnica)
|
| 42 |
|
| 43 |
-
|
| 44 |
-
"code_session": self.sensorial_session.codigo_sesion,
|
| 45 |
-
"session_name": self.sensorial_session.nombre_sesion,
|
| 46 |
-
"max_testers": self.sensorial_session.tecnica.limite_catadores,
|
| 47 |
-
"current_testers": len(self.participations),
|
| 48 |
-
"active_testers": len([part for part in self.participations if part.activo]),
|
| 49 |
-
"participations": self.participations,
|
| 50 |
-
"use_technique": self.sensorial_session.tecnica.tipo_tecnica.nombre_tecnica
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
def getExpectedRatings(self):
|
| 54 |
-
num_products = Producto.objects.filter(
|
| 55 |
-
id_tecnica=self.sensorial_session.tecnica).count()
|
| 56 |
-
style_words = self.sensorial_session.tecnica.id_estilo
|
| 57 |
-
num_words: int
|
| 58 |
-
|
| 59 |
-
if style_words.nombre_estilo == "atributos":
|
| 60 |
-
num_words = EsAtributo.objects.get(
|
| 61 |
-
id_tecnica=self.sensorial_session.tecnica).palabras.count()
|
| 62 |
-
elif style_words.nombre_estilo == "vocabulario":
|
| 63 |
-
num_words = EsVocabulario.objects.get(
|
| 64 |
-
id_tecnica=self.sensorial_session.tecnica).id_vocabulario.palabras.count()
|
| 65 |
-
|
| 66 |
-
return num_products * num_words
|
| 67 |
-
|
| 68 |
-
def checkAllParticipantsEnded(self):
|
| 69 |
technique = self.sensorial_session.tecnica
|
| 70 |
|
| 71 |
-
expected_ratings_repetition = self.
|
| 72 |
|
| 73 |
-
all_participations =
|
| 74 |
-
|
| 75 |
|
| 76 |
if len(all_participations) < technique.limite_catadores:
|
| 77 |
return (False, "No se ha alcanzado el número máximo de Catadores")
|
| 78 |
|
| 79 |
for particiapation in all_participations:
|
| 80 |
-
num_ratings_now =
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
if num_ratings_now < expected_ratings_repetition:
|
| 84 |
return (False, "No todos los catadores han finalizado su evaluación")
|
| 85 |
|
| 86 |
return (True, "Puedes finalizar la sesión")
|
| 87 |
-
|
| 88 |
-
def finishSession(self):
|
| 89 |
-
response = SesionController.finishRepetion(self.sensorial_session)
|
| 90 |
-
if isinstance(response, dict):
|
| 91 |
-
return controller_error(response["error"])
|
| 92 |
-
self.sensorial_session.refresh_from_db()
|
| 93 |
-
return self.sensorial_session
|
|
|
|
| 1 |
from django.http import HttpRequest
|
| 2 |
from django.shortcuts import render, redirect
|
| 3 |
from django.urls import reverse
|
| 4 |
+
from tecnicas.models import Dato, Participacion
|
| 5 |
+
from tecnicas.controllers import SesionController
|
|
|
|
| 6 |
from .monitor_controller import MonitorController
|
| 7 |
|
| 8 |
|
| 9 |
class MonitorEscalasController(MonitorController):
|
|
|
|
|
|
|
| 10 |
def __init__(self, session: SesionController):
|
| 11 |
super().__init__(session)
|
| 12 |
+
self.url_view = "tecnicas/manage_sesions/monitor-sesion.html"
|
| 13 |
+
self.previus_view = "cata_system:detalles_sesion"
|
| 14 |
|
| 15 |
+
def controllPostFinishSession(self, request: HttpRequest):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
self.setContext()
|
| 17 |
+
(is_all_end, message) = self.checkAllFinish()
|
| 18 |
if not is_all_end:
|
| 19 |
self.context["error"] = message
|
| 20 |
+
return render(request, self.url_view, self.context)
|
| 21 |
response = self.finishSession()
|
| 22 |
if isinstance(response, dict):
|
| 23 |
self.context["error"] = response["error"]
|
| 24 |
+
return render(request, self.url_view, self.context)
|
| 25 |
self.context["message"] = message
|
| 26 |
+
return redirect(reverse(self.previus_view, kwargs={"session_code": self.sensorial_session.codigo_sesion}))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
def checkAllFinish(self):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
technique = self.sensorial_session.tecnica
|
| 30 |
|
| 31 |
+
expected_ratings_repetition = self.getExpectedRatingsEscalasRapida()
|
| 32 |
|
| 33 |
+
all_participations = list(
|
| 34 |
+
Participacion.objects.filter(tecnica=technique))
|
| 35 |
|
| 36 |
if len(all_participations) < technique.limite_catadores:
|
| 37 |
return (False, "No se ha alcanzado el número máximo de Catadores")
|
| 38 |
|
| 39 |
for particiapation in all_participations:
|
| 40 |
+
num_ratings_now = Dato.objects.filter(
|
| 41 |
+
id_calificacion__num_repeticion=technique.repeticion,
|
| 42 |
+
id_calificacion__id_catador=particiapation.catador,
|
| 43 |
+
id_calificacion__id_tecnica=technique
|
| 44 |
+
).count()
|
| 45 |
|
| 46 |
if num_ratings_now < expected_ratings_repetition:
|
| 47 |
return (False, "No todos los catadores han finalizado su evaluación")
|
| 48 |
|
| 49 |
return (True, "Puedes finalizar la sesión")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tecnicas/controllers/views_controller/session_management/monitor_rata_controller.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from django.http import HttpRequest
|
| 2 |
+
from django.shortcuts import render, redirect
|
| 3 |
+
from django.urls import reverse
|
| 4 |
+
from tecnicas.models import Dato, Participacion
|
| 5 |
+
from tecnicas.controllers import SesionController
|
| 6 |
+
from .monitor_controller import MonitorController
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class MonitorRATAController(MonitorController):
|
| 10 |
+
def __init__(self, session: SesionController):
|
| 11 |
+
super().__init__(session)
|
| 12 |
+
self.url_view = "tecnicas/manage_sesions/monitor-sesion.html"
|
| 13 |
+
self.previus_view = "cata_system:detalles_sesion"
|
| 14 |
+
|
| 15 |
+
def controllPostFinishSession(self, request: HttpRequest):
|
| 16 |
+
self.setContext()
|
| 17 |
+
(is_all_end, message) = self.checkAllFinish()
|
| 18 |
+
if not is_all_end:
|
| 19 |
+
self.context["error"] = message
|
| 20 |
+
return render(request, self.url_view, self.context)
|
| 21 |
+
response = self.finishSession()
|
| 22 |
+
if isinstance(response, dict):
|
| 23 |
+
self.context["error"] = response["error"]
|
| 24 |
+
return render(request, self.url_view, self.context)
|
| 25 |
+
self.context["message"] = message
|
| 26 |
+
return redirect(reverse(self.previus_view, kwargs={"session_code": self.sensorial_session.codigo_sesion}))
|
| 27 |
+
|
| 28 |
+
def checkAllFinish(self):
|
| 29 |
+
technique = self.sensorial_session.tecnica
|
| 30 |
+
|
| 31 |
+
expected_ratings_repetition = self.getExpectedRatingsEscalasRapida()
|
| 32 |
+
|
| 33 |
+
all_participations = list(
|
| 34 |
+
Participacion.objects.filter(tecnica=technique))
|
| 35 |
+
|
| 36 |
+
for particiapation in all_participations:
|
| 37 |
+
num_ratings_now = Dato.objects.filter(
|
| 38 |
+
id_calificacion__num_repeticion=technique.repeticion,
|
| 39 |
+
id_calificacion__id_catador=particiapation.catador,
|
| 40 |
+
id_calificacion__id_tecnica=technique
|
| 41 |
+
).count()
|
| 42 |
+
|
| 43 |
+
if num_ratings_now < expected_ratings_repetition:
|
| 44 |
+
return (False, "No todos los catadores han finalizado su evaluación")
|
| 45 |
+
|
| 46 |
+
return (True, "Puedes finalizar la sesión")
|
tecnicas/views/sessions_management/session_monitor.py
CHANGED
|
@@ -8,7 +8,7 @@ from django.http import HttpRequest, JsonResponse
|
|
| 8 |
from django.shortcuts import render, redirect
|
| 9 |
from django.urls import reverse
|
| 10 |
from tecnicas.models import SesionSensorial
|
| 11 |
-
from tecnicas.controllers import MonitorEscalasController
|
| 12 |
from tecnicas.utils import noValidTechnique
|
| 13 |
|
| 14 |
|
|
@@ -41,8 +41,19 @@ def sessionMonitor(req: HttpRequest, session_code: str):
|
|
| 41 |
if use_techinique == "escalas":
|
| 42 |
controll_view = MonitorEscalasController(sensorial_session)
|
| 43 |
action = req.POST["action"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
if action == "finish_session":
|
| 45 |
-
response = controll_view.
|
| 46 |
request=req)
|
| 47 |
else:
|
| 48 |
response = controll_view.controlGetResponse(
|
|
|
|
| 8 |
from django.shortcuts import render, redirect
|
| 9 |
from django.urls import reverse
|
| 10 |
from tecnicas.models import SesionSensorial
|
| 11 |
+
from tecnicas.controllers import MonitorEscalasController, MonitorRATAController
|
| 12 |
from tecnicas.utils import noValidTechnique
|
| 13 |
|
| 14 |
|
|
|
|
| 41 |
if use_techinique == "escalas":
|
| 42 |
controll_view = MonitorEscalasController(sensorial_session)
|
| 43 |
action = req.POST["action"]
|
| 44 |
+
|
| 45 |
+
if action == "finish_session":
|
| 46 |
+
response = controll_view.controllPostFinishSession(
|
| 47 |
+
request=req)
|
| 48 |
+
else:
|
| 49 |
+
response = controll_view.controlGetResponse(
|
| 50 |
+
request=req, error="No se ha definido la acción a realizar")
|
| 51 |
+
elif use_techinique == "rata":
|
| 52 |
+
controll_view = MonitorRATAController(sensorial_session)
|
| 53 |
+
action = req.POST["action"]
|
| 54 |
+
|
| 55 |
if action == "finish_session":
|
| 56 |
+
response = controll_view.controllPostFinishSession(
|
| 57 |
request=req)
|
| 58 |
else:
|
| 59 |
response = controll_view.controlGetResponse(
|