back 1.0.38 y front 1.0.39 cambios en condicionales de sub preguntas, solo boleanos

This commit is contained in:
2025-11-25 22:43:14 -03:00
parent 1ef07ad2c5
commit 4c8938a24e
4 changed files with 147 additions and 138 deletions

View File

@@ -1062,12 +1062,12 @@ def create_answer(
if not question: if not question:
raise HTTPException(status_code=404, detail="Pregunta no encontrada") raise HTTPException(status_code=404, detail="Pregunta no encontrada")
# Calcular puntos según status # Sistema simplificado: 1 punto por pregunta correcta
points_earned = 0 points_earned = 0
if answer.status == "ok": if answer.status == "ok":
points_earned = question.points points_earned = 1
elif answer.status == "warning": 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 # Buscar si ya existe una respuesta para esta inspección y pregunta
existing_answer = db.query(models.Answer).filter( existing_answer = db.query(models.Answer).filter(

View File

@@ -1130,6 +1130,23 @@ function QuestionsManagerModal({ checklist, onClose }) {
<h4 className="text-sm font-semibold text-blue-900 mb-3"> <h4 className="text-sm font-semibold text-blue-900 mb-3">
Pregunta Condicional - Subpreguntas Anidadas (hasta 5 niveles) Pregunta Condicional - Subpreguntas Anidadas (hasta 5 niveles)
</h4> </h4>
{/* 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 (
<div className="p-3 bg-gray-50 rounded-lg border border-gray-200">
<p className="text-sm text-gray-600">
Las preguntas condicionales solo están disponibles para tipos <strong>Boolean</strong> y <strong>Opción Única</strong>
</p>
</div>
)
}
return (
<>
<div className="grid grid-cols-2 gap-4"> <div className="grid grid-cols-2 gap-4">
<div> <div>
<label className="block text-sm font-medium text-gray-700 mb-1"> <label className="block text-sm font-medium text-gray-700 mb-1">
@@ -1233,6 +1250,9 @@ function QuestionsManagerModal({ checklist, onClose }) {
</div> </div>
) )
})()} })()}
</>
)
})()}
</div> </div>
{/* AI Prompt - Solo visible si el checklist tiene IA habilitada */} {/* AI Prompt - Solo visible si el checklist tiene IA habilitada */}

View File

@@ -101,9 +101,9 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) {
case 'single_choice': case 'single_choice':
case 'multiple_choice': case 'multiple_choice':
newConfig.choices = [ newConfig.choices = [
{ value: 'option1', label: 'Opción 1', points: maxPoints }, { value: 'option1', label: 'Opción 1', status: 'ok' },
{ value: 'option2', label: 'Opción 2', points: Math.floor(maxPoints / 2) }, { value: 'option2', label: 'Opción 2', status: 'warning' },
{ value: 'option3', label: 'Opción 3', points: 0 } { value: 'option3', label: 'Opción 3', status: 'critical' }
] ]
newConfig.allow_other = false newConfig.allow_other = false
break break
@@ -112,7 +112,6 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) {
newConfig.max = 5 newConfig.max = 5
newConfig.step = 1 newConfig.step = 1
newConfig.labels = { min: 'Muy malo', max: 'Excelente' } newConfig.labels = { min: 'Muy malo', max: 'Excelente' }
newConfig.points_per_level = maxPoints / 5
break break
case 'text': case 'text':
newConfig.multiline = true newConfig.multiline = true
@@ -152,7 +151,7 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) {
const newChoices = [...config.choices, { const newChoices = [...config.choices, {
value: `option${config.choices.length + 1}`, value: `option${config.choices.length + 1}`,
label: `Opción ${config.choices.length + 1}`, label: `Opción ${config.choices.length + 1}`,
points: 0 status: 'ok'
}] }]
updateConfig({ choices: newChoices }) updateConfig({ choices: newChoices })
} }
@@ -232,31 +231,19 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) {
className="w-full px-2 py-1 border border-gray-300 rounded mb-2 text-sm" className="w-full px-2 py-1 border border-gray-300 rounded mb-2 text-sm"
placeholder="Texto de la opción" placeholder="Texto de la opción"
/> />
<div className="grid grid-cols-2 gap-2">
<div> <div>
<label className="block text-xs text-gray-500 mb-1">Puntos</label> <label className="block text-xs text-gray-500 mb-1">Estado (Determina Puntuación)</label>
<input
type="number"
value={choice.points}
onChange={(e) => updateChoice(idx, 'points', parseInt(e.target.value) || 0)}
className="w-full px-2 py-1 border border-gray-300 rounded text-sm"
min="0"
/>
</div>
<div>
<label className="block text-xs text-gray-500 mb-1">Estado</label>
<select <select
value={choice.status || 'info'} value={choice.status || 'ok'}
onChange={(e) => updateChoice(idx, 'status', e.target.value)} onChange={(e) => updateChoice(idx, 'status', e.target.value)}
className="w-full px-2 py-1 border border-gray-300 rounded text-sm" className="w-full px-2 py-1 border border-gray-300 rounded text-sm"
> >
{STATUS_OPTIONS.map(s => ( <option value="ok"> OK (1pt)</option>
<option key={s.value} value={s.value}>{s.label}</option> <option value="warning"> Advertencia (0.5pt)</option>
))} <option value="critical"> Crítico (0pt)</option>
</select> </select>
</div> </div>
</div> </div>
</div>
))} ))}
</div> </div>
</div> </div>
@@ -295,14 +282,16 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) {
/> />
</div> </div>
<div> <div>
<input <select
type="number" value={choice.status || 'ok'}
value={choice.points} onChange={(e) => updateChoice(idx, 'status', e.target.value)}
onChange={(e) => updateChoice(idx, 'points', parseInt(e.target.value) || 0)}
className="w-full px-2 py-1 border border-gray-300 rounded text-sm" className="w-full px-2 py-1 border border-gray-300 rounded text-sm"
placeholder="Puntos" title="Define la puntuación: OK=1pt, Advertencia=0.5pt, Crítico=0pt"
min="0" >
/> <option value="ok"> OK (1pt)</option>
<option value="warning"> Advertencia (0.5pt)</option>
<option value="critical"> Crítico (0pt)</option>
</select>
</div> </div>
</div> </div>
<button <button

View File

@@ -6,7 +6,7 @@ export default function Sidebar({ user, activeTab, setActiveTab, sidebarOpen, se
{sidebarOpen && ( {sidebarOpen && (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<div className="w-8 h-8 bg-gradient-to-br from-indigo-500 to-purple-500 rounded-lg flex items-center justify-center"> <div className="w-8 h-8 bg-gradient-to-br from-indigo-500 to-purple-500 rounded-lg flex items-center justify-center">
<span className="text-white font-bold text-lg">S</span> <span className="text-white font-bold text-lg">A</span>
</div> </div>
<h2 className="text-xl font-bold bg-gradient-to-r from-indigo-400 to-purple-400 bg-clip-text text-transparent">Ayutec</h2> <h2 className="text-xl font-bold bg-gradient-to-r from-indigo-400 to-purple-400 bg-clip-text text-transparent">Ayutec</h2>
</div> </div>