@extends('layouts.master') @section('css') @stop @section('content') @if(Session::has('message_error'))
{!! Session::get('message_error') !!}
@endif @if(Session::has('message_success'))
{!! Session::get('message_success') !!}
@endif
{!! Form::open(['url' => 'ze/guardarevaluation', 'method' => 'POST']) !!} @csrf
{!! Form::hidden('form_id', $form_id , $attributes = array('id'=>'form_id'))!!} {!! Form::hidden('id_estudiante', $id_estudiante , $attributes = array('id'=>'id_estudiante'))!!} {!! Form::hidden('id_docente', $id_docente , $attributes = array('id'=>'id_docente'))!!} {!! Form::hidden('cod_mat', $cod_mat , $attributes = array('id'=>'cod_mat'))!!} {!! Form::hidden('idseccion', $id_seccion , $attributes = array('id'=>'idseccion'))!!} {!! Form::text('Teacher', $docente , $attributes = array('class' => 'form-control data mayuscula','id'=>'Teacher', 'readOnly' => 'readOnly'))!!}
{!! Form::text('Course', $materia , $attributes = array('class' => 'form-control data mayuscula','id'=>'Course', 'readOnly' => 'readOnly'))!!}


@php // Filter questions to separate radio questions from others $radioQuestions = $form->questions->where('question_type', 'radio'); $otherQuestions = $form->questions->whereIn('question_type', ['text', 'textarea', 'checkbox', 'select']); @endphp {{-- Render non-radio questions individually --}} @forelse ($otherQuestions as $question)
@if ($question->question_type == 'text') @elseif ($question->question_type == 'textarea') @elseif ($question->question_type == 'checkbox')
@php $options = is_array($question->options) ? $question->options : json_decode($question->options ?? '[]', true); $options = is_array($options) ? $options : []; $oldValues = old('question_' . $question->id, []); @endphp @foreach ($options as $option)
@endforeach @error('question_' . $question->id)
{{ $message }}
@enderror
@elseif ($question->question_type == 'select') @endif @error('question_' . $question->id)
{{ $message }}
@enderror
@empty {{-- This block will only execute if there are no non-radio questions --}} @endforelse {{-- Render radio questions in a table --}} @if ($radioQuestions->isNotEmpty())

Preguntas de Opción Múltiple

@php // Get options from the first radio question to use as table headers $firstRadioQuestionOptions = $radioQuestions->first() ? (is_array($radioQuestions->first()->options) ? $radioQuestions->first()->options : json_decode($radioQuestions->first()->options ?? '[]', true)) : []; $firstRadioQuestionOptions = is_array($firstRadioQuestionOptions) ? $firstRadioQuestionOptions : []; @endphp @foreach ($firstRadioQuestionOptions as $option) @endforeach @php $radioCounter = 1; @endphp @foreach($radioQuestions as $question) @php $options = is_array($question->options) ? $question->options : json_decode($question->options ?? '[]', true); $options = is_array($options) ? $options : []; @endphp @foreach ($options as $optionValue) @endforeach @endforeach
Preguntas{{ $option }}
{{ $radioCounter++ }} {{ $question->question_text }} id) == $optionValue ? 'checked' : '' }} required>
@foreach ($radioQuestions as $question) @error('question_' . $question->id)
{{ $message }}
@enderror @endforeach @endif @if ($form->questions->isEmpty())
Este formulario no tiene preguntas configuradas aún.
@endif
Volver @if (!$form->questions->isEmpty()) @endif
{!!Form::close()!!}
@stop @section('postscript') @stop