diff --git a/backend/app/main.py b/backend/app/main.py index 44cc9aa..8aa58f5 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -1062,12 +1062,12 @@ def create_answer( if not question: raise HTTPException(status_code=404, detail="Pregunta no encontrada") - # Calcular puntos según status + # Sistema simplificado: 1 punto por pregunta correcta points_earned = 0 if answer.status == "ok": - points_earned = question.points + points_earned = 1 elif answer.status == "warning": - points_earned = int(question.points * 0.5) + points_earned = 0.5 # Buscar si ya existe una respuesta para esta inspección y pregunta existing_answer = db.query(models.Answer).filter( diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 33cf08c..0e88db0 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1130,107 +1130,127 @@ function QuestionsManagerModal({ checklist, onClose }) {

⚡ Pregunta Condicional - Subpreguntas Anidadas (hasta 5 niveles)

-
-
- - -

- Esta pregunta aparecerá solo si se cumple la condición de la pregunta padre -

-
-
- - -

- La pregunta solo se mostrará con esta respuesta específica -

-
-
- - {/* Indicador de profundidad */} - {formData.parent_question_id && (() => { - const parentQ = questions.find(q => q.id === formData.parent_question_id) - const parentDepth = parentQ?.depth_level || 0 - const newDepth = parentDepth + 1 + {/* Solo permitir condicionales para boolean y single_choice */} + {(() => { + const currentType = formData.options?.type || formData.type + const allowConditional = ['boolean', 'single_choice'].includes(currentType) + + if (!allowConditional) { + return ( +
+

+ ℹ️ Las preguntas condicionales solo están disponibles para tipos Boolean y Opción Única +

+
+ ) + } return ( -
= 5 ? 'bg-red-50 border border-red-200' : 'bg-blue-100'}`}> -

- 📊 Profundidad: Nivel {newDepth} de 5 máximo - {newDepth >= 5 && ' ⚠️ Máximo alcanzado'} -

-
+ <> +
+
+ + +

+ Esta pregunta aparecerá solo si se cumple la condición de la pregunta padre +

+
+
+ + +

+ La pregunta solo se mostrará con esta respuesta específica +

+
+
+ + {/* Indicador de profundidad */} + {formData.parent_question_id && (() => { + const parentQ = questions.find(q => q.id === formData.parent_question_id) + const parentDepth = parentQ?.depth_level || 0 + const newDepth = parentDepth + 1 + + return ( +
= 5 ? 'bg-red-50 border border-red-200' : 'bg-blue-100'}`}> +

+ 📊 Profundidad: Nivel {newDepth} de 5 máximo + {newDepth >= 5 && ' ⚠️ Máximo alcanzado'} +

+
+ ) + })()} + ) })()} diff --git a/frontend/src/QuestionTypeEditor.jsx b/frontend/src/QuestionTypeEditor.jsx index 86b8153..82d48c1 100644 --- a/frontend/src/QuestionTypeEditor.jsx +++ b/frontend/src/QuestionTypeEditor.jsx @@ -101,9 +101,9 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) { case 'single_choice': case 'multiple_choice': newConfig.choices = [ - { value: 'option1', label: 'Opción 1', points: maxPoints }, - { value: 'option2', label: 'Opción 2', points: Math.floor(maxPoints / 2) }, - { value: 'option3', label: 'Opción 3', points: 0 } + { value: 'option1', label: 'Opción 1', status: 'ok' }, + { value: 'option2', label: 'Opción 2', status: 'warning' }, + { value: 'option3', label: 'Opción 3', status: 'critical' } ] newConfig.allow_other = false break @@ -112,7 +112,6 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) { newConfig.max = 5 newConfig.step = 1 newConfig.labels = { min: 'Muy malo', max: 'Excelente' } - newConfig.points_per_level = maxPoints / 5 break case 'text': newConfig.multiline = true @@ -152,7 +151,7 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) { const newChoices = [...config.choices, { value: `option${config.choices.length + 1}`, label: `Opción ${config.choices.length + 1}`, - points: 0 + status: 'ok' }] updateConfig({ choices: newChoices }) } @@ -232,29 +231,17 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) { className="w-full px-2 py-1 border border-gray-300 rounded mb-2 text-sm" placeholder="Texto de la opción" /> -
-
- - updateChoice(idx, 'points', parseInt(e.target.value) || 0)} - className="w-full px-2 py-1 border border-gray-300 rounded text-sm" - min="0" - /> -
-
- - -
+
+ +
))} @@ -295,14 +282,16 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) { />
- updateChoice(idx, 'points', parseInt(e.target.value) || 0)} +