chartManD commited on
Commit
9d6dd50
·
1 Parent(s): 0a56c42

Correccion de guardado de datos con escalas continuas

Browse files
tecnicas/controllers/models_controller/dato_controller.py CHANGED
@@ -12,11 +12,7 @@ class DatoController():
12
  }
13
 
14
  self.data = Dato(**atributes)
15
-
16
- if isinstance(value_rating, bool):
17
- self.value_data = ValorBooleano(valor=value_rating)
18
- else:
19
- self.value_data = ValorDecimal(valor=value_rating)
20
 
21
  def setRating(self, new_rating: Calificacion):
22
  try:
@@ -39,15 +35,27 @@ class DatoController():
39
  except ValidationError as e:
40
  return controller_error(e.message)
41
 
42
- def setValue(self, new_value=None):
43
- if new_value:
44
- if isinstance(new_value, bool):
45
- self.value_data = ValorBooleano(valor=new_value)
46
- else:
47
- self.value_data = ValorDecimal(valor=new_value)
48
  else:
49
- self.value_data.id_dato = self.data
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
 
51
  return self.value_data
52
 
53
  def saveValue(self):
 
12
  }
13
 
14
  self.data = Dato(**atributes)
15
+ self.value_rating = value_rating
 
 
 
 
16
 
17
  def setRating(self, new_rating: Calificacion):
18
  try:
 
35
  except ValidationError as e:
36
  return controller_error(e.message)
37
 
38
+ def setValue(self):
39
+ if isinstance(self.value_rating, bool):
40
+ self.value_data = ValorBooleano(valor=self.value_rating)
41
+
 
 
42
  else:
43
+ type_scale = self.data.id_calificacion.id_tecnica.escala_tecnica.id_tipo_escala.nombre_escala
44
+
45
+
46
+ if type_scale == "continua":
47
+ decimal_value = self.value_rating/100
48
+ value_rounded = round(decimal_value)
49
+ self.value_data = ValorDecimal(valor=value_rounded)
50
+
51
+ print(self.value_rating)
52
+ print(decimal_value)
53
+ print(value_rounded)
54
+
55
+ else:
56
+ self.value_data = ValorDecimal(valor=self.value_rating)
57
 
58
+ self.value_data.id_dato = self.data
59
  return self.value_data
60
 
61
  def saveValue(self):
tecnicas/controllers/views_controller/sessions_tester/tests_forms/test_pf_controller.py CHANGED
@@ -173,6 +173,12 @@ class TestPFController(GenetalTestController):
173
 
174
  self.context["repetition"] = technique.repeticion - 2
175
 
 
 
 
 
 
 
176
  return render(request, self.current_directory, self.context)
177
 
178
  def getErrorRepetition(self, request: HttpRequest):
 
173
 
174
  self.context["repetition"] = technique.repeticion - 2
175
 
176
+ if self.context["type_scale"] == "continua":
177
+ self.context["size_scale"] = {
178
+ "max_size": scale.longitud * 100,
179
+ "middle_size": (scale.longitud * 100)/2
180
+ }
181
+
182
  return render(request, self.current_directory, self.context)
183
 
184
  def getErrorRepetition(self, request: HttpRequest):
tecnicas/controllers/views_controller/sessions_tester/tests_forms/test_scales_controller.py CHANGED
@@ -78,5 +78,10 @@ class TestScalesController(GenetalTestController):
78
  ctx["scale"] = scale
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)
 
78
  ctx["scale"] = scale
79
  ctx["type_scale"] = scale.id_tipo_escala.nombre_escala
80
  ctx["tags"] = EscalaController.getRelatedTagsInScale(scale=scale)
81
+ if ctx["type_scale"] == "continua":
82
+ ctx["size_scale"] = {
83
+ "max_size": scale.longitud * 100,
84
+ "middle_size": (scale.longitud * 100)/2
85
+ }
86
 
87
+ return render(request, self.current_directory, ctx)
tecnicas/templates/tecnicas/components/form-scale-continue.html CHANGED
@@ -6,10 +6,11 @@
6
  class="text-xl font-bold tracking-wide block mb-6 first-letter:uppercase">{{ word }}</label>
7
 
8
  <span class="hidden id-word">{{ word.id }}</span>
9
-
10
  <section class="block">
11
  <div class="relative mx-6">
12
- <input type="range" type="range" min="0" max="1000" value="500" name="rating-word"
 
13
  class="range range-md text-blue-400 [--range-bg:orange] [--range-thumb:blue] [--range-fill:0]"
14
  style="width: {{scale.longitud}}cm;">
15
 
 
6
  class="text-xl font-bold tracking-wide block mb-6 first-letter:uppercase">{{ word }}</label>
7
 
8
  <span class="hidden id-word">{{ word.id }}</span>
9
+
10
  <section class="block">
11
  <div class="relative mx-6">
12
+ <input type="range" type="range" min="0" max="{{ size_scale.max_size }}"
13
+ value="{{ size_scale.middle_size }}" name="rating-word"
14
  class="range range-md text-blue-400 [--range-bg:orange] [--range-thumb:blue] [--range-fill:0]"
15
  style="width: {{scale.longitud}}cm;">
16
 
tecnicas/templates/tecnicas/forms_tester/convencional.html CHANGED
@@ -104,7 +104,7 @@
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 %}
 
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 size_scale=size_scale %}
108
  {% endfor %}
109
  {% elif type_scale == "estructurada" %}
110
  {% for word in words %}
tecnicas/templates/tecnicas/forms_tester/test_pf_rating_list.html CHANGED
@@ -110,7 +110,7 @@
110
  {% with path_con="../components/form-scale-continue.html" path_str="../components/form-scale-structure.html" %}
111
  {% if type_scale == "continua" %}
112
  {% for word in words %}
113
- {% include path_con with word=word tags=tags scale=scale %}
114
  {% endfor %}
115
  {% elif type_scale == "estructurada" %}
116
  {% for word in words %}
 
110
  {% with path_con="../components/form-scale-continue.html" path_str="../components/form-scale-structure.html" %}
111
  {% if type_scale == "continua" %}
112
  {% for word in words %}
113
+ {% include path_con with word=word tags=tags scale=scale size_scale=size_scale %}
114
  {% endfor %}
115
  {% elif type_scale == "estructurada" %}
116
  {% for word in words %}