back 1.0.38 y front 1.0.39 cambios en condicionales de sub preguntas, solo boleanos
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -1130,6 +1130,23 @@ function QuestionsManagerModal({ checklist, onClose }) {
|
||||
<h4 className="text-sm font-semibold text-blue-900 mb-3">
|
||||
⚡ Pregunta Condicional - Subpreguntas Anidadas (hasta 5 niveles)
|
||||
</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>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
@@ -1233,6 +1250,9 @@ function QuestionsManagerModal({ checklist, onClose }) {
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
</>
|
||||
)
|
||||
})()}
|
||||
</div>
|
||||
|
||||
{/* AI Prompt - Solo visible si el checklist tiene IA habilitada */}
|
||||
|
||||
@@ -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,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"
|
||||
placeholder="Texto de la opción"
|
||||
/>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<div>
|
||||
<label className="block text-xs text-gray-500 mb-1">Puntos</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>
|
||||
<label className="block text-xs text-gray-500 mb-1">Estado (Determina Puntuación)</label>
|
||||
<select
|
||||
value={choice.status || 'info'}
|
||||
value={choice.status || 'ok'}
|
||||
onChange={(e) => updateChoice(idx, 'status', e.target.value)}
|
||||
className="w-full px-2 py-1 border border-gray-300 rounded text-sm"
|
||||
>
|
||||
{STATUS_OPTIONS.map(s => (
|
||||
<option key={s.value} value={s.value}>{s.label}</option>
|
||||
))}
|
||||
<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>
|
||||
</div>
|
||||
@@ -295,14 +282,16 @@ export function QuestionTypeEditor({ value, onChange, maxPoints = 1 }) {
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="number"
|
||||
value={choice.points}
|
||||
onChange={(e) => updateChoice(idx, 'points', parseInt(e.target.value) || 0)}
|
||||
<select
|
||||
value={choice.status || 'ok'}
|
||||
onChange={(e) => updateChoice(idx, 'status', e.target.value)}
|
||||
className="w-full px-2 py-1 border border-gray-300 rounded text-sm"
|
||||
placeholder="Puntos"
|
||||
min="0"
|
||||
/>
|
||||
title="Define la puntuación: OK=1pt, Advertencia=0.5pt, Crítico=0pt"
|
||||
>
|
||||
<option value="ok">✓ OK (1pt)</option>
|
||||
<option value="warning">⚠ Advertencia (0.5pt)</option>
|
||||
<option value="critical">✗ Crítico (0pt)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
|
||||
@@ -6,7 +6,7 @@ export default function Sidebar({ user, activeTab, setActiveTab, sidebarOpen, se
|
||||
{sidebarOpen && (
|
||||
<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">
|
||||
<span className="text-white font-bold text-lg">S</span>
|
||||
<span className="text-white font-bold text-lg">A</span>
|
||||
</div>
|
||||
<h2 className="text-xl font-bold bg-gradient-to-r from-indigo-400 to-purple-400 bg-clip-text text-transparent">Ayutec</h2>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user