Spaces:
Sleeping
Sleeping
Se craea diseño de escalas continuas, preparacion para guardar dato
Browse files
tecnicas/static/js/created-scale.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function checkSendRating(word) {
|
| 2 |
+
const btnCheck = document.querySelector(`.ct-btn-check-${word}`);
|
| 3 |
+
const btnSend = document.querySelector(`.ct-btn-submit-${word}`);
|
| 4 |
+
const btnCancel = document.querySelector(`.ct-btn-cancel-${word}`);
|
| 5 |
+
|
| 6 |
+
btnCheck.classList.add("hidden");
|
| 7 |
+
btnSend.classList.remove("hidden");
|
| 8 |
+
btnCancel.classList.remove("hidden");
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
function cancelSendRating(word) {
|
| 12 |
+
const btnCheck = document.querySelector(`.ct-btn-check-${word}`);
|
| 13 |
+
const btnSend = document.querySelector(`.ct-btn-submit-${word}`);
|
| 14 |
+
const btnCancel = document.querySelector(`.ct-btn-cancel-${word}`);
|
| 15 |
+
|
| 16 |
+
btnCheck.classList.remove("hidden");
|
| 17 |
+
btnSend.classList.add("hidden");
|
| 18 |
+
btnCancel.classList.add("hidden");
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
async function sendRating(word) {
|
| 22 |
+
const formRatingWord = document.querySelector(`.form-rating-${word}`);
|
| 23 |
+
console.log(formRatingWord);
|
| 24 |
+
|
| 25 |
+
const dataForm = new FormData(this);
|
| 26 |
+
const url = "/cata/testers/api/ratingword";
|
| 27 |
+
|
| 28 |
+
try {
|
| 29 |
+
const respone = await fetch(url, {
|
| 30 |
+
method: "POST",
|
| 31 |
+
headers: {
|
| 32 |
+
"X-CSRFToken": dataForm.get("csrfmiddlewaretoken"),
|
| 33 |
+
},
|
| 34 |
+
body: dataForm,
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
const jsonResponse = await respone.json();
|
| 38 |
+
|
| 39 |
+
if (jsonResponse.error) {
|
| 40 |
+
console.log(jsonResponse.error);
|
| 41 |
+
return;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
console.log(jsonResponse);
|
| 45 |
+
} catch (error) {
|
| 46 |
+
console.log("Error:", error);
|
| 47 |
+
}
|
| 48 |
+
}
|
tecnicas/templates/tecnicas/forms_tester/convencional.html
CHANGED
|
@@ -1,7 +1,31 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
| 2 |
|
| 3 |
{% block title %}Convencional{% endblock %}
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
{% block content %}
|
| 6 |
<article class="w-full flex flex-col justify-center items-center bg-gray-600 mt-10 mb-10">
|
| 7 |
<article class="flex flex-col gap-8 bg-gray-400 p-10 rounded">
|
|
@@ -13,7 +37,6 @@
|
|
| 13 |
|
| 14 |
{% if error %}
|
| 15 |
<hr>
|
| 16 |
-
|
| 17 |
<article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
|
| 18 |
<p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
|
| 19 |
{{ error }}
|
|
@@ -21,38 +44,118 @@
|
|
| 21 |
</article>
|
| 22 |
{% endif %}
|
| 23 |
|
| 24 |
-
<article>
|
| 25 |
-
<
|
| 26 |
-
{
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
</article>
|
| 41 |
|
| 42 |
-
<article>
|
| 43 |
-
<
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</article>
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
</article>
|
|
|
|
| 53 |
</article>
|
| 54 |
</article>
|
| 55 |
{% endblock %}
|
| 56 |
|
| 57 |
{% block extra_js %}
|
|
|
|
| 58 |
{% endblock %}
|
|
|
|
| 1 |
+
{% extends 'tecnicas/layouts/base.html' %}
|
| 2 |
+
|
| 3 |
+
{% load static %}
|
| 4 |
|
| 5 |
{% block title %}Convencional{% endblock %}
|
| 6 |
|
| 7 |
+
{% block extra_css %}
|
| 8 |
+
<style>
|
| 9 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 10 |
+
-webkit-appearance: none;
|
| 11 |
+
appearance: none;
|
| 12 |
+
width: 24px;
|
| 13 |
+
height: 24px;
|
| 14 |
+
border-radius: 50%;
|
| 15 |
+
background: var(--color-blue-500);
|
| 16 |
+
cursor: pointer;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
input[type="range"]::-moz-range-thumb {
|
| 20 |
+
width: 24px;
|
| 21 |
+
height: 24px;
|
| 22 |
+
border-radius: 50%;
|
| 23 |
+
background: #3b82f6;
|
| 24 |
+
cursor: pointer;
|
| 25 |
+
}
|
| 26 |
+
</style>
|
| 27 |
+
{% endblock %}
|
| 28 |
+
|
| 29 |
{% block content %}
|
| 30 |
<article class="w-full flex flex-col justify-center items-center bg-gray-600 mt-10 mb-10">
|
| 31 |
<article class="flex flex-col gap-8 bg-gray-400 p-10 rounded">
|
|
|
|
| 37 |
|
| 38 |
{% if error %}
|
| 39 |
<hr>
|
|
|
|
| 40 |
<article class="bg-red-600 p-4 text-white rounded-xl ct-notification-error">
|
| 41 |
<p class="block font-sans text-white text-xl antialiased font-bold uppercase tracking-wider text-center">
|
| 42 |
{{ error }}
|
|
|
|
| 44 |
</article>
|
| 45 |
{% endif %}
|
| 46 |
|
| 47 |
+
<article class="hidden">
|
| 48 |
+
<ul class="list-words">
|
| 49 |
+
{% for word in words %}
|
| 50 |
+
<li class="item-word">
|
| 51 |
+
<p class="word-id">
|
| 52 |
+
{{ word.id }}
|
| 53 |
+
</p>
|
| 54 |
+
<p class="word-name">
|
| 55 |
+
{{ word.nombre_palabra }}
|
| 56 |
+
</p>
|
| 57 |
+
</li>
|
| 58 |
+
{% endfor %}
|
| 59 |
+
</ul>
|
| 60 |
|
| 61 |
+
<ul class="list-tags">
|
| 62 |
+
{% for tag in tags %}
|
| 63 |
+
<li class="item-tag">
|
| 64 |
+
<p class="tag-id">
|
| 65 |
+
{{ tag.posicion }}
|
| 66 |
+
</p>
|
| 67 |
+
<p class="tag-name">
|
| 68 |
+
{{ tag.id_etiqueta }}
|
| 69 |
+
</p>
|
| 70 |
+
</li>
|
| 71 |
+
{% endfor %}
|
| 72 |
+
</ul>
|
| 73 |
|
| 74 |
+
<div class="scale-data">
|
| 75 |
+
<p class="scale-type">
|
| 76 |
+
{{ scale.id_tipo_escala }}
|
| 77 |
+
</p>
|
| 78 |
+
<p class="scale-size">
|
| 79 |
+
{{ scale.longitud }}
|
| 80 |
+
</p>
|
| 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 |
+
{% if type_scale == "continua" %}
|
| 101 |
+
<article class="scale-continue-container [&>*:not(:last-child)]:mb-5">
|
| 102 |
+
{% for word in words %}
|
| 103 |
+
<form action="" method="post" class="form-rating-{{word}}">
|
| 104 |
+
{% csrf_token %}
|
| 105 |
+
<article class="bg-gray-200 p-6 rounded-lg mb-3">
|
| 106 |
+
<label for="id-range-word-{{word}}"
|
| 107 |
+
class="text-xl font-bold tracking-wide block mb-6 first-letter:uppercase">{{ word }}</label>
|
| 108 |
+
|
| 109 |
+
<section class="block">
|
| 110 |
+
<div class="relative">
|
| 111 |
+
<input id="id-range-word-{{word}}" type="range" min="0" max="1000" value="500"
|
| 112 |
+
name="rating-word"
|
| 113 |
+
class="w-full h-2 bg-gray-400 rounded-lg appearance-none cursor-pointer slider">
|
| 114 |
+
|
| 115 |
+
<div class="absolute top-0 left-0 w-0.5 transform -translate-x-1/2 h-full bg-red-500 z-10">
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<div
|
| 119 |
+
class="absolute top-1/5 left-1/2 w-0.5 transform -translate-x-1/2 h-4/5 bg-red-500 z-10">
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<div class="absolute top-0 right-0 w-0.5 transform -translate-x-1/2 h-full bg-red-500 z-10">
|
| 123 |
+
</div>
|
| 124 |
+
</div>
|
| 125 |
+
|
| 126 |
+
<div class="flex justify-between mt-4">
|
| 127 |
+
{% for tag in tags %}
|
| 128 |
+
<div class="flex flex-col items-start text-left w-[120px]">
|
| 129 |
+
<span class="text-sm font-medium text-gray-700 break-words first-letter:capitalize">
|
| 130 |
+
{{ tag.id_etiqueta }}
|
| 131 |
+
</span>
|
| 132 |
+
</div>
|
| 133 |
+
{% endfor %}
|
| 134 |
+
</div>
|
| 135 |
+
</section>
|
| 136 |
+
</article>
|
| 137 |
+
<article class="flex justify-end gap-2">
|
| 138 |
+
<button type="button" onclick="checkSendRating('{{word}}')"
|
| 139 |
+
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">
|
| 140 |
+
¿Guardar calificación?
|
| 141 |
+
</button>
|
| 142 |
+
<button type="button" onclick="sendRating('{{word}}')"
|
| 143 |
+
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">
|
| 144 |
+
Estoy seguro
|
| 145 |
+
</button>
|
| 146 |
+
<button type="button" onclick="cancelSendRating('{{word}}')"
|
| 147 |
+
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">
|
| 148 |
+
Cancelar
|
| 149 |
+
</button>
|
| 150 |
+
</article>
|
| 151 |
+
</form>
|
| 152 |
+
{% endfor %}
|
| 153 |
</article>
|
| 154 |
+
{% endif %}
|
| 155 |
</article>
|
| 156 |
</article>
|
| 157 |
{% endblock %}
|
| 158 |
|
| 159 |
{% block extra_js %}
|
| 160 |
+
<script src="{% static 'js/created-scale.js' %}"></script>
|
| 161 |
{% endblock %}
|
tecnicas/views/tester_forms/convencional_scales.py
CHANGED
|
@@ -96,6 +96,7 @@ def convencionalScales(req: HttpRequest):
|
|
| 96 |
|
| 97 |
scale = EscalaController.getScaleByTechnique(technique=technique)
|
| 98 |
context["scale"] = scale
|
|
|
|
| 99 |
|
| 100 |
use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 101 |
context["tags"] = use_tags
|
|
|
|
| 96 |
|
| 97 |
scale = EscalaController.getScaleByTechnique(technique=technique)
|
| 98 |
context["scale"] = scale
|
| 99 |
+
context["type_scale"] = scale.id_tipo_escala.nombre_escala
|
| 100 |
|
| 101 |
use_tags = EscalaController.getRelatedTagsInScale(scale=scale)
|
| 102 |
context["tags"] = use_tags
|