chartManD commited on
Commit
16f734b
·
1 Parent(s): e1798ac

Se agrega boton para continuar con la siguinte palabra a calificar (convencional)

Browse files
tecnicas/static/js/created-scale.js CHANGED
@@ -1,3 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  function checkSendRating(word) {
2
  const btnCheck = document.querySelector(`.ct-btn-check-${word}`);
3
  const btnSend = document.querySelector(`.ct-btn-submit-${word}`);
@@ -19,6 +38,9 @@ function cancelSendRating(word) {
19
  }
20
 
21
  async function sendRating(word) {
 
 
 
22
  const formRatingWord = document.querySelector(`.form-rating-${word}`);
23
 
24
  const dataForm = new FormData(formRatingWord);
@@ -38,12 +60,14 @@ async function sendRating(word) {
38
  const jsonResponse = await respone.json();
39
 
40
  if (jsonResponse.error) {
41
- console.log(jsonResponse.error);
42
  return;
43
  }
44
 
45
- console.log(jsonResponse);
46
  remplaceForm(formRatingWord, jsonResponse.message);
 
 
 
47
  } catch (error) {
48
  console.log("Error:", error);
49
  }
@@ -54,8 +78,8 @@ function remplaceForm(oldForm, message) {
54
  const thankYouMessage = document.createElement("p");
55
  const messageResponse = document.createElement("p");
56
 
57
- thankYouMessage.textContent =
58
- "Palabra calificada, gracias por la participación";
59
  messageResponse.textContent = message;
60
 
61
  articleContainer.classList.add(
@@ -72,3 +96,112 @@ function remplaceForm(oldForm, message) {
72
  articleContainer.appendChild(messageResponse);
73
  oldForm.replaceWith(articleContainer);
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const BTN_CLASS_STYLE = [
2
+ "text-lg",
3
+ "tracking-wider",
4
+ "font-medium",
5
+ "p-2",
6
+ "px-4",
7
+ "border-b-2",
8
+ "active:border-b-0",
9
+ "active:border-t-2",
10
+ "active:border-blue-500",
11
+ "border-blue-800",
12
+ "transition-all",
13
+ "rounded-xl",
14
+ "bg-blue-500",
15
+ "text-white",
16
+ "w-fit",
17
+ "disabled:bg-amber-600",
18
+ ];
19
+
20
  function checkSendRating(word) {
21
  const btnCheck = document.querySelector(`.ct-btn-check-${word}`);
22
  const btnSend = document.querySelector(`.ct-btn-submit-${word}`);
 
38
  }
39
 
40
  async function sendRating(word) {
41
+ const containerBtn = document.querySelector(`.actions-${word}`);
42
+ addOrRemoveWaitSpin(containerBtn);
43
+
44
  const formRatingWord = document.querySelector(`.form-rating-${word}`);
45
 
46
  const dataForm = new FormData(formRatingWord);
 
60
  const jsonResponse = await respone.json();
61
 
62
  if (jsonResponse.error) {
63
+ addOrRemoveWaitSpin(containerBtn, false, jsonResponse.error);
64
  return;
65
  }
66
 
 
67
  remplaceForm(formRatingWord, jsonResponse.message);
68
+ if (isEndedRatingWords()) {
69
+ addBtnNextWord();
70
+ }
71
  } catch (error) {
72
  console.log("Error:", error);
73
  }
 
78
  const thankYouMessage = document.createElement("p");
79
  const messageResponse = document.createElement("p");
80
 
81
+ thankYouMessage.innerHTML =
82
+ "Palabra calificada,<br>gracias por la participación";
83
  messageResponse.textContent = message;
84
 
85
  articleContainer.classList.add(
 
96
  articleContainer.appendChild(messageResponse);
97
  oldForm.replaceWith(articleContainer);
98
  }
99
+
100
+ function addBtnNextWord() {
101
+ const thankYouMessage = document.createElement("p");
102
+ thankYouMessage.textContent = "Has finalizado con este producto";
103
+ thankYouMessage.classList.add("text-2xl", "font-bold", "mb-3");
104
+
105
+ const btnNesxtWord = document.createElement("button");
106
+ btnNesxtWord.classList.add(...BTN_CLASS_STYLE, "ct-btn-next-word");
107
+ btnNesxtWord.textContent = "Siguiente palabra";
108
+ btnNesxtWord.addEventListener("click", nextWord);
109
+
110
+ const articleContainer = document.createElement("article");
111
+ articleContainer.classList.add(
112
+ "bg-gray-200",
113
+ "p-6",
114
+ "rounded-lg",
115
+ "mb-3",
116
+ "text-center"
117
+ );
118
+
119
+ articleContainer.appendChild(thankYouMessage);
120
+ articleContainer.appendChild(btnNesxtWord);
121
+
122
+ const scalesContainer = document.querySelector(".scales-container");
123
+ scalesContainer.innerHTML = "";
124
+ scalesContainer.appendChild(articleContainer);
125
+ }
126
+
127
+ function isEndedRatingWords() {
128
+ const currentNumerWords = document.querySelectorAll(
129
+ 'form[class*="form-rating-"]'
130
+ ).length;
131
+
132
+ return !currentNumerWords;
133
+ }
134
+
135
+ /**
136
+ *
137
+ * @param {Event} e
138
+ */
139
+ function nextWord(e) {
140
+ location.reload();
141
+ }
142
+
143
+ function createSpinCharge() {
144
+ const divSpin = document.createElement("div");
145
+
146
+ divSpin.classList.add(
147
+ "w-10",
148
+ "h-10",
149
+ "rounded-full",
150
+ "border-4",
151
+ "border-t-4",
152
+ "border-gray-200",
153
+ "border-t-blue-600",
154
+ "animate-spin"
155
+ );
156
+
157
+ return divSpin;
158
+ }
159
+
160
+ /**
161
+ *
162
+ * @param {Element} containerBtn
163
+ */
164
+ function addOrRemoveWaitSpin(containerBtn, render = true, error = false) {
165
+ const actions = containerBtn.querySelector(`.btns-container`);
166
+
167
+ if (render) {
168
+ containerBtn.innerHTML = "";
169
+ const spin = createSpinCharge();
170
+ actions.classList.add("hidden");
171
+ containerBtn.appendChild(spin);
172
+ containerBtn.appendChild(actions);
173
+ containerBtn.classList.remove("items-end");
174
+ containerBtn.classList.add("items-center");
175
+ }
176
+
177
+ if (!render) {
178
+ containerBtn.innerHTML = "";
179
+
180
+ if (error) {
181
+ containerBtn.appendChild(createErrorSubmit(error));
182
+ }
183
+
184
+ containerBtn.append(actions);
185
+ actions.classList.remove("hidden");
186
+ containerBtn.classList.remove("items-center");
187
+ containerBtn.classList.add("items-end");
188
+ }
189
+ }
190
+
191
+ function createErrorSubmit(errorMessage) {
192
+ const containerError = document.createElement("div");
193
+ containerError.classList.add(
194
+ "w-full",
195
+ "p-2",
196
+ "bg-red-400",
197
+ "font-bold",
198
+ "text-center",
199
+ "rounded-lg"
200
+ );
201
+
202
+ const errorP = document.createElement("p");
203
+ errorP.textContent = errorMessage;
204
+
205
+ containerError.appendChild(errorP);
206
+ return containerError;
207
+ }
tecnicas/templates/tecnicas/forms_tester/convencional.html CHANGED
@@ -81,23 +81,33 @@
81
  </div>
82
  </article>
83
 
84
- <article class="rounded grid grid-cols-2 max-sm:grid-cols-1 gap-4">
85
- <section class="flex flex-col items-center justify-center bg-gray-200 p-2 rounded-lg">
86
  <p class="text-lg font-medium text-center">
87
  {{ session.tecnica.instrucciones }}
88
  </p>
89
  </section>
90
- <section class="flex flex-col items-center justify-center bg-gray-200 p-2 rounded-lg">
91
- <p class="text-lg font-bold text-center">
92
- Producto:
93
- </p>
94
- <p class="text-2xl font-bold text-center">
95
- {{ product }}
96
- </p>
 
 
 
 
 
 
 
 
 
 
97
  </section>
98
  </article>
99
 
100
- <article class="scale-continue-container [&>*:not(:last-child)]:mb-5 flex flex-col items-center justify-center">
101
  {% if type_scale == "continua" %}
102
  {% for word in words %}
103
  <form action="" method="post" class="form-rating-{{word}}">
@@ -125,29 +135,39 @@
125
  </div>
126
 
127
  <div class="flex justify-between mt-4">
128
- {% for tag in tags %}
129
  <div class="flex flex-col items-start text-left w-[100px]">
130
- <span class="text-xs font-medium text-gray-700 break-words first-letter:capitalize">
131
- {{ tag.id_etiqueta }}
 
 
 
 
 
 
 
 
 
 
132
  </span>
133
  </div>
134
- {% endfor %}
135
  </div>
136
  </section>
137
  </article>
138
- <article class="flex justify-end gap-2">
139
- <button type="button" onclick="checkSendRating('{{word}}')"
140
- class="ct-btn-check-{{word}} text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-blue-500 border-blue-800 transition-all rounded-xl bg-blue-500 text-white w-fit disabled:bg-amber-600">
141
- ¿Guardar calificación?
142
- </button>
143
- <button type="button" onclick="sendRating('{{word}}')"
144
- class="ct-btn-submit-{{word}} text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-green-500 border-green-800 transition-all rounded-xl bg-green-500 text-white w-fit disabled:bg-amber-600 hidden">
145
- Estoy seguro
146
- </button>
147
- <button type="button" onclick="cancelSendRating('{{word}}')"
148
- class="ct-btn-cancel-{{word}} text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-orange-500 border-orange-800 transition-all rounded-xl bg-orange-500 text-white w-fit disabled:bg-amber-600 hidden">
149
- Cancelar
150
- </button>
 
 
151
  </article>
152
  </form>
153
  {% endfor %}
 
81
  </div>
82
  </article>
83
 
84
+ <article class="rounded flex flex-col gap-4">
85
+ <section class="flex items-center justify-center bg-gray-200 p-2 rounded-lg">
86
  <p class="text-lg font-medium text-center">
87
  {{ session.tecnica.instrucciones }}
88
  </p>
89
  </section>
90
+ <section class="flex items-center justify-center flex-wrap gap-4">
91
+ <div class="bg-gray-200 p-2 rounded-lg flex-1">
92
+ <p class="text-lg font-bold text-center">
93
+ Producto:
94
+ </p>
95
+ <p class="text-2xl font-bold text-center">
96
+ {{ product }}
97
+ </p>
98
+ </div>
99
+ <div class="bg-gray-200 p-2 rounded-lg flex-1">
100
+ <p class="text-lg font-bold text-center">
101
+ Repetición:
102
+ </p>
103
+ <p class="text-2xl font-bold text-center">
104
+ {{ session.tecnica.repecion }}
105
+ </p>
106
+ </div>
107
  </section>
108
  </article>
109
 
110
+ <article class="scales-container [&>*:not(:last-child)]:mb-5 flex flex-col items-center justify-center">
111
  {% if type_scale == "continua" %}
112
  {% for word in words %}
113
  <form action="" method="post" class="form-rating-{{word}}">
 
135
  </div>
136
 
137
  <div class="flex justify-between mt-4">
 
138
  <div class="flex flex-col items-start text-left w-[100px]">
139
+ <span class="text-xs font-medium text-gray-700 break-words first-letter:capitalize">
140
+ {{ tags.0.id_etiqueta }}
141
+ </span>
142
+ </div>
143
+ <div class="flex flex-col items-start text-center w-[100px]">
144
+ <span class="text-xs font-medium text-gray-700 break-words first-letter:capitalize">
145
+ {{ tags.1.id_etiqueta }}
146
+ </span>
147
+ </div>
148
+ <div class="flex flex-col items-start text-right w-[100px]">
149
+ <span class="text-xs font-medium text-gray-700 break-words first-letter:capitalize">
150
+ {{ tags.2.id_etiqueta }}
151
  </span>
152
  </div>
 
153
  </div>
154
  </section>
155
  </article>
156
+ <article class="flex flex-col justify-center gap-2 items-end actions-{{word}}">
157
+ <section class="flex justify-end items-center gap-2 btns-container">
158
+ <button type="button" onclick="checkSendRating('{{word}}')"
159
+ class="ct-btn-check-{{word}} text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-blue-500 border-blue-800 transition-all rounded-xl bg-blue-500 text-white w-fit disabled:bg-amber-600">
160
+ ¿Guardar calificación?
161
+ </button>
162
+ <button type="button" onclick="sendRating('{{word}}')"
163
+ class="ct-btn-submit-{{word}} text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-green-500 border-green-800 transition-all rounded-xl bg-green-500 text-white w-fit disabled:bg-amber-600 hidden">
164
+ Estoy seguro
165
+ </button>
166
+ <button type="button" onclick="cancelSendRating('{{word}}')"
167
+ class="ct-btn-cancel-{{word}} text-lg tracking-wider font-medium p-2 px-4 border-b-2 active:border-b-0 active:border-t-2 active:border-orange-500 border-orange-800 transition-all rounded-xl bg-orange-500 text-white w-fit disabled:bg-amber-600 hidden">
168
+ Cancelar
169
+ </button>
170
+ </section>
171
  </article>
172
  </form>
173
  {% endfor %}
tecnicas/views/tester_forms/convencional_scales.py CHANGED
@@ -46,7 +46,7 @@ from ...controllers import SesionController, PosicionController, CalificacionCon
46
  - Cada palabra debe contar con su input segun el tipo
47
  - Para cada input se debe poder guardar la calificacion
48
  - Anstes de guardar la calificacion preguntar por la confirmacion a la hora de guardar el dato
49
- - Especficar las etiquetas por debajo del input de ripo ranto
50
  - Para las escalas de tipo continua
51
  - La longitud de la barra de la escala debe ser igual al tamaño que se especifico en la configuracion
52
  - Contar con un input de tipo range
@@ -57,7 +57,7 @@ from ...controllers import SesionController, PosicionController, CalificacionCon
57
  - Su longitud sera tan largo como el contendor que lo aloja
58
  - La barra se divide segun el numero de etiquetas que estas posean
59
  - Cata longitud debe poser una marca y solo estas seran las unicas posibles respuestas
60
- - Cata segmento en el que se dibide debe tener la etiqueda correspondiente por debaj
61
  '''
62
 
63
 
 
46
  - Cada palabra debe contar con su input segun el tipo
47
  - Para cada input se debe poder guardar la calificacion
48
  - Anstes de guardar la calificacion preguntar por la confirmacion a la hora de guardar el dato
49
+ - Especficar las etiquetas por debajo del input de ripo rango
50
  - Para las escalas de tipo continua
51
  - La longitud de la barra de la escala debe ser igual al tamaño que se especifico en la configuracion
52
  - Contar con un input de tipo range
 
57
  - Su longitud sera tan largo como el contendor que lo aloja
58
  - La barra se divide segun el numero de etiquetas que estas posean
59
  - Cata longitud debe poser una marca y solo estas seran las unicas posibles respuestas
60
+ - Cata segmento en el que se divide debe tener la etiqueda correspondiente por debajo
61
  '''
62
 
63