@if($question->question_type == 'radio')
@foreach(explode(',', $question->options) as $key => $option)
@php
$checked = '';
$option_id = explode(',', $question->option_ids)[$key];
@endphp
@if(in_array($question->id, array_column($response, 'question_id')))
@php
$index = array_search($question->id, array_column($response,
'question_id'));
@endphp
@if($response[$index]['response'] == $option_id)
@php $checked = 'checked'; @endphp
@endif
@if($previousResponse)
@if($previousResponse[$index]['response'] == $option_id)
@php $previousValue = $option; @endphp
@endif
@endif
@endif
@endforeach
@if($isChanged)
(Previous Response : {{$previousValue}})
@endif
@endif
@if($question->question_type == 'checkbox')
@foreach(explode(',', $question->options) as $key => $option)
@php
$checked = '';
$option_id = explode(',', $question->option_ids)[$key];
@endphp
@if(in_array($question->id, array_column($response, 'question_id')))
@php
$index = array_search($question->id, array_column($response,
'question_id'));
@endphp
@if(in_array($option_id, explode(',', $response[$index]['response'])))
@php $checked = 'checked'; @endphp
@endif
@endif
@endforeach
@endif
@if($question->question_type == 'select')
@endif
{{--
@if(in_array($question->id, array_column($response, 'question_id')))
@php
$index = array_search($question->id, array_column($response,
'question_id'));
@endphp
@if($response[$index]['option_colour'] == 'green')
@elseif($response[$index]['option_colour'] == 'red')
@elseif($response[$index]['option_colour'] == 'yellow')
@elseif($response[$index]['option_colour'] == 'black')
@endif
@endif
--}}