chartManD commited on
Commit
c9de8df
·
1 Parent(s): 468d1ca

Ingreso de Catador a sesion con CATA

Browse files
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/static/js/test-cata.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener("DOMContentLoaded", () => {
2
+ const form = document.getElementById("wordsForm");
3
+
4
+ form.addEventListener("submit", (e) => {
5
+ e.preventDefault(); // prevenimos envío por defecto
6
+ const checkboxes = form.querySelectorAll('input[type="checkbox"]');
7
+ const unchecked = Array.from(checkboxes).filter((cb) => !cb.checked);
8
+
9
+ if (unchecked.length > 0) {
10
+ const confirmLeaveBlank = confirm(
11
+ "Algunas palabras no han sido marcadas. ¿Deseas continuar dejando esas casillas en blanco?"
12
+ );
13
+
14
+ if (!confirmLeaveBlank) {
15
+ return;
16
+ }
17
+ }
18
+
19
+ // form.submit();
20
+ });
21
+ });
tecnicas/templates/tecnicas/forms_tester/cata.html CHANGED
@@ -7,7 +7,7 @@
7
  {% block content %}
8
  <article class="cts-container-main">
9
  <article class="cts-wrap-content text-black">
10
- <header class="text-center flex-row 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>
@@ -61,61 +61,34 @@
61
  </p>
62
  </div>
63
  </section>
64
- <section class="flex flex-col bg-red-200 py-2 px-4 rounded-lg min-sm:hidden">
65
- <p>
66
- El largo de estas escalas puede afectar la vista en dispositivos móviles. Para ver el resto de la
67
- escala puede deslizar con el dedo a la derecha o la izquierda sin tocar la escala.
68
- </p>
69
- </section>
70
  </article>
71
 
72
- <article class="words-check-container w-full max-w-3xl mx-auto p-6 bg-base-200 rounded-xl shadow-lg">
 
73
  <form id="wordsForm" method="POST" class="flex flex-col gap-4">
74
  {% csrf_token %}
75
- {% for word in words %}
76
- <label
77
- class="flex items-center justify-between bg-base-100 p-4 rounded-lg shadow-sm hover:shadow-md transition-all">
78
- <span class="text-lg font-medium">{{ word }}</span>
79
- <input type="checkbox" name="word_{{ word.id }}" class="checkbox checkbox-primary"
80
- data-word-id="{{ word.id }}" />
81
- </label>
82
- {% empty %}
83
- <p class="text-center text-gray-500">No hay palabras disponibles.</p>
84
- {% endfor %}
85
-
86
- <button type="submit" class="btn btn-primary mt-6">
 
87
  Enviar calificaciones
88
  </button>
89
  </form>
90
  </article>
91
  </article>
92
  </article>
93
-
94
- <script>
95
- document.addEventListener("DOMContentLoaded", () => {
96
- const form = document.getElementById("wordsForm")
97
-
98
- form.addEventListener("submit", (e) => {
99
- e.preventDefault() // prevenimos envío por defecto
100
- const checkboxes = form.querySelectorAll('input[type="checkbox"]')
101
- const unchecked = Array.from(checkboxes).filter(cb => !cb.checked)
102
-
103
- if (unchecked.length > 0) {
104
- const confirmLeaveBlank = confirm(
105
- "Algunas palabras no han sido marcadas. ¿Deseas continuar dejando esas casillas en blanco?"
106
- )
107
-
108
- if (!confirmLeaveBlank) {
109
- return
110
- }
111
- }
112
-
113
- form.submit()
114
- })
115
- });
116
- </script>
117
  {% endblock %}
118
 
119
  {% block extra_js %}
120
  <script src="{% static 'js/actions-form.js' %}"></script>
 
121
  {% endblock %}
 
7
  {% block content %}
8
  <article class="cts-container-main">
9
  <article class="cts-wrap-content text-black">
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>
 
61
  </p>
62
  </div>
63
  </section>
 
 
 
 
 
 
64
  </article>
65
 
66
+ <article
67
+ class="words-check-container bg-surface-card w-full max-w-3xl mx-auto p-6 bg-base-200 rounded-xl shadow-lg">
68
  <form id="wordsForm" method="POST" class="flex flex-col gap-4">
69
  {% csrf_token %}
70
+ <div class="grid lg:grid-cols-4 md:grid-cols-3 grid-cols-2 gap-4">
71
+ {% for word in words %}
72
+ <label
73
+ class="flex items-center justify-between bg-surface-sweet p-4 gap-2 rounded-lg shadow-sm hover:shadow-md transition-all">
74
+ <span class="text-lg font-medium">{{ word }}</span>
75
+ <input type="checkbox" name="word_{{ word.id }}" class="checkbox checkbox-md checkbox-secondary"
76
+ data-word-id="{{ word.id }}" />
77
+ </label>
78
+ {% empty %}
79
+ <p class="text-center text-gray-500">No hay palabras disponibles.</p>
80
+ {% endfor %}
81
+ </div>
82
+ <button type="submit" class="cts-btn-general cts-btn-primary btn-push mt-6">
83
  Enviar calificaciones
84
  </button>
85
  </form>
86
  </article>
87
  </article>
88
  </article>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  {% endblock %}
90
 
91
  {% block extra_js %}
92
  <script src="{% static 'js/actions-form.js' %}"></script>
93
+ <script src="{% static 'js/test-cata.js' %}"></script>
94
  {% endblock %}
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,