diff --git a/src/components/Question.vue b/src/components/Question.vue
index 694cc05..20822be 100644
--- a/src/components/Question.vue
+++ b/src/components/Question.vue
@@ -31,8 +31,30 @@ const displayPopup = ref(false);
function showHidePopup() {
displayPopup.value = !displayPopup.value;
}
-const h = ref();
-const d = ref();
+function validatePopup() {
+ const calcule = Math.round((h.value * 100) / d.value);
+ const regexp = /[^0-9]*([0-9]{2})/g;
+ const answersLength = props.question.answers.length;
+ const answerIndex = props.question.answers.find((answer, index) => {
+ const values = Array.from(answer.title.matchAll(regexp), (m) => m[1]);
+ if (values.length > 0) {
+ const min = values.length == 1 ? 0 : values[0];
+ const max = values.length == 1 ? values[0] : values[1];
+ if (calcule >= min && calcule <= max) {
+ return true;
+ }
+ }
+ if (answersLength == index + 1) {
+ return true;
+ }
+ });
+ document.querySelector(
+ "input[id=" + `question_${props.question.id}_answer_${answerIndex.id}` + "]"
+ ).checked = true;
+ showHidePopup();
+}
+const h = ref(0);
+const d = ref(0);
@@ -80,24 +102,34 @@ const d = ref();
-
-
-
-
-
-
+
+
+
+