Questionaire

@php $i=0; @endphp @if(!empty($risks)) @foreach($risks as $key=>$risk) @php $i++; @endphp @if($i%3==0)
@endif @endforeach @endif
@if(!empty($risks)) @foreach($risks as $key=>$risk)
0) style="display:none" @endif data-index="{{$key}}"> @csrf
@if(!empty($questionnaires[$risk->id])) @php $totalControl = count($riskControls[$risk->id]) @endphp
Responses
@foreach($riskControls[$risk->id] as $rc) @endforeach @php $agg_resp = [0,0,0,0]; $agg_controls=[]; $divisor = 0; $resp_best_control = array(); //$temp_design = $temp_performance = 0; @endphp @foreach($questionnaires[$risk->id] as $r_key => $qr) @php $controlAnswerCount = 0; @endphp @php $agg_resp[0] += intval($qr->inherent_risk_likelyhood); $agg_resp[1] += intval($qr->inherent_risk_impact); $designs = explode(',',$qr->control_designs); $performance = explode(',',$qr->control_performance); $internal_best_control = 0; $best_control = 5; @endphp @foreach($designs as $key=>$d) @php $controlAnswerCount++; //$internal_best_control = $matrix_controls[$d][$performance[$key]]; $internal_best_control = $matrix_controls[$performance[$key]][$d]; //echo $d.'__'.$performance[$key].'==>'.$internal_best_control.' = '.$best_control; if($internal_best_control <= $best_control) { //echo 'Yes'; $best_control = $internal_best_control; $resp_best_control[$r_key]['design'] = $matrix['control_design'][$d]; $resp_best_control[$r_key]['performance'] = $matrix['control_performance'][$performance[$key]]; $resp_best_control[$r_key]['intersect'] = $best_control; $resp_best_control[$r_key]['design_value'] = $d; $resp_best_control[$r_key]['peformace_value'] = $performance[$key]; } //echo "
"; @endphp @php if(!isset($agg_controls[$key][0])) $agg_controls[$key][0] = 0; if(!isset($agg_controls[$key][1])) $agg_controls[$key][1] = 0; $agg_controls[$key][0] += intval($d); $agg_controls[$key][1] += intval($performance[$key]); @endphp @endforeach @php $remainControl = $totalControl-$controlAnswerCount; if($remainControl > 0) { for($c=0;$c<$remainControl; $c++) { echo ''; } } @endphp @php $agg_resp[2] += intval($qr->calculated_residual_risk_impact); $agg_resp[3] += intval($qr->perceived_residual_risk_impact); $divisor++; @endphp @endforeach
Respondent Name Risk Likelihood Risk Impact{{$rc->control_reference_no}}Calculated Residual Risk Perceived Residual Risk
{{$users[$qr->respondent_id]}} {{ucwords($matrix['likelihood'][$qr->inherent_risk_likelyhood])}} {{ucwords($matrix['impact'][$qr->inherent_risk_impact])}}

{{ucwords($matrix['control_design'][$d])}}

{{ucwords($matrix['control_performance'][$performance[$key]])}}

{{ucwords($matrix['residual_risk'][$qr->calculated_residual_risk_impact])}}

{{ucwords($matrix['residual_risk'][$qr->perceived_residual_risk_impact])}}
Aggregated Response @php //$final_likelihood = round($agg_resp[0]/$divisor); //$final_impact = round($agg_resp[1]/$divisor); $final_likelihood = number_format($agg_resp[0]/$divisor, 2, '.', ''); $final_impact = number_format($agg_resp[1]/$divisor, 2, '.', ''); if($final_likelihood <= $thresold[1]) { $final_likelihood = 1; } else if($final_likelihood > $thresold[1] && $final_likelihood <= $thresold[2]) { $final_likelihood = 2; } else if($final_likelihood > $thresold[2] && $final_likelihood <= $thresold[3]) { $final_likelihood = 3; } else if($final_likelihood > $thresold[3] && $final_likelihood <= $thresold[4]) { $final_likelihood = 4; } else if($final_likelihood > $thresold[4]) { $final_likelihood = 5; } if($final_impact <= $thresold[1]) { $final_impact = 1; } else if($final_impact > $thresold[1] && $final_impact <= $thresold[2]) { $final_impact = 2; } else if($final_impact > $thresold[2] && $final_impact <= $thresold[3]) { $final_impact = 3; } else if($final_impact > $thresold[3] && $final_impact <= $thresold[4]) { $final_impact = 4; } else if($final_impact > $thresold[4]) { $final_impact = 5; } //$intersect_residual = $matrix_risk[$final_likelihood][$final_impact]; $intersect_residual = $matrix_risk[$final_impact][$final_likelihood]; @endphp

{{@ucwords($matrix['likelihood'][$final_likelihood])}}

{{@ucwords($matrix['impact'][$final_impact])}}

@php $average_design = array_sum(array_column($resp_best_control, 'design_value')); $average_performance = array_sum(array_column($resp_best_control, 'peformace_value')); //echo "
"; print_r($resp_best_control); 
                                                            
                                                            //$final_design = round($average_design/$divisor);
                                                            //$final_performance = round($average_performance/$divisor);

                                                            $final_design = number_format($average_design/$divisor, 2, '.', '');
                                                            $final_performance = number_format($average_performance/$divisor, 2, '.', '');
                                                            
                                                            if($final_design <= $thresold[1]) {
                                                            $final_design = 1;
                                                            } else if($final_design > $thresold[1] && $final_design <= $thresold[2]) {
                                                                $final_design = 2;
                                                            } else if($final_design > $thresold[2] && $final_design <= $thresold[3]) {
                                                                $final_design = 3;
                                                            } else if($final_design > $thresold[3] && $final_design <= $thresold[4]) {
                                                                $final_design = 4;
                                                            } else if($final_design > $thresold[4]) {
                                                                $final_design = 5;
                                                            }

                                                            if($final_performance <= $thresold[1]) {
                                                            $final_performance = 1;
                                                            } else if($final_performance > $thresold[1] && $final_performance <= $thresold[2]) {
                                                                $final_performance = 2;
                                                            } else if($final_performance > $thresold[2] && $final_performance <= $thresold[3]) {
                                                                $final_performance = 3;
                                                            } else if($final_performance > $thresold[3] && $final_performance <= $thresold[4]) {
                                                                $final_performance = 4;
                                                            } else if($final_performance > $thresold[4]) {
                                                                $final_performance = 5;
                                                            }
                                                        
                                                            
                                                            //$intersect_control = $matrix_controls[$final_design][$final_performance];
                                                            $intersect_control = $matrix_controls[$final_performance][$final_design];
                                                        @endphp 
                                                         
                                                         
                                                         
                                                        

{{@ucwords($matrix['control_design'][$final_design])}}

{{@ucwords($matrix['control_performance'][$final_performance])}}

{{-- @foreach($agg_controls as $row)

{{@ucwords($matrix['control_design'][round($row[0]/$divisor)])}}

{{@ucwords($matrix['control_performance'][round($row[1]/$divisor)])}} @endforeach --}}

@php $intersect_calculated_risk = $matrix_calc[$intersect_residual][$intersect_control]; //echo $intersect_residual; //$intersect_calculated_risk = round($agg_resp[2]/$divisor); @endphp

{{@ucwords($matrix['residual_risk'][$intersect_calculated_risk])}}

{{@ucwords($matrix['residual_risk'][round($agg_resp[3]/$divisor)])}}
@endif
@endforeach

Comments
@can('approve_questionnaire.edit') @if(isset($model->is_approved) && $model->is_approved == 'yes') @else Back @endif @endcan
@else

Please select risk for this RCSA planner

@endif