mercredi 28 décembre 2022

Cannot use object of type stdClass as array (View: .../para-answers.blade.php)

<?php 
    $options = json_decode($question->answers); 
    $correct_answers = json_decode($question->correct_answers);
    
     $outer_index=0;

?>
<div class="row">
    <div class="col-md-12">
        <ul class="questions-container fullwidth">
          <?php 
          foreach($options as $option) { 
            // dd($user_answers);
            $cAnswer = $correct_answers[$outer_index]->answer;
            $uAnswer = $user_answers[$outer_index];
            // dd($uAnswer);
            // print_r($option->options[0]);
              $sub_options = (array)$option->options;
              $optionsl2  = null;
              // if(isset($option->optionsl2))
              // $optionsl2 = (array) $option->optionsl2; 


            foreach($sub_options as $key => $value)
             $sub_options = $value;
            ?>  
            <li>
                <div class="question">
                    <h3> <span class="language_l1">{!!$option->question !!}</span>
                     
                    </h3> </div>
               
                <div class="select-answer">
                    <ul class="row">
                    <?php $index=0; 
                     
                     foreach($sub_options as $key1 => $value1) { 
                        $correct_answer_class = '';
                        if($cAnswer==$index+1)
                        {
                              $correct_answer_class = 'correct-answer';
                        }
                        
                        $submitted_value = '';
                        if($user_answers) 
                        {
                           if($uAnswer == $index+1) 
                           {
                                $submitted_value = 'checked';
                                
                            }
                        }
                      
                        ?>
                        <li class="col-md-6  answer_radio" >
                            <input type="radio" name="option" id="1radio1"   disabled="">
                           
                        </li>
                        <?php $index++; } ?>
                    </ul>
                </div>
            </li>
            <hr>
            <?php } ?>

        </ul>
    </div>
</div>

Here we got an issue (Cannot use object of type stdClass as array). Please help me to solve this problem. In this we want to show result of students paragraph questions... This project build on laravel 5.2 please check the following errors solve this... I get this error while we take a paragraph exam.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/LJCkE7p
via IFTTT

Aucun commentaire:

Enregistrer un commentaire