
<section class="pcoded-main-container">
    <div class="pcoded-content">
        <div class="page-header">
            <div class="page-block">
                <div class="row align-items-center">
                    <div class="col-md-12">
                        <div class="page-header-title">
                            <h5 class="m-b-10"><?= __('Edit Question') ?></h5>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?= $this->Form->create($question,['id'=>'q_form']) ?>
        <div class="row">
            <div class="col-sm-12">
               <div class="card">
                <div class="card-body">
                 <div class="col-md-4">
                    
                    <p><strong>Paper: </strong><?=$question->paper->subject; ?></p>                        
                </div>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
             
                <div class="col-md-12" id="options">
                   <div class="form-group">
                    <p><strong>Q.</strong>  <?=$question->question; ?></p>
                </div>
            </div>
            <div class="col-md-12" id="options">
               <div class="form-group">
                <label>Answer Options: </label>
            </div>
            <?php
            $newOptions = explode('--*--',$question['options']);
            $correct_ans = trim($question['correct_ans']);

            if(!empty($newOptions)){ 
                foreach ($newOptions as $option) {
                    $checked = '';
                    $option_id = md5($option);
                    if($correct_ans === trim($option)){
                        $checked = "checked='true'";
                    }
                    ?>
                    <div class="form-group d-inline">
                        <div class="radio radio-success d-inline">
                            <input type="radio" onclick="prevnt(event)" name="correct_ans" id="<?=$option_id; ?>" <?=$checked;?> value="<?=$option; ?>">
                            <label for="<?=$option_id; ?>" class="cr"><?=$option; ?></label>
                        </div>
                        
                    </div>
                <?php } } ?>
                
            </div>
            <?php if(@$userright_arr[0]->edit):?>
            <div class="float-right d-flex mt-1">
                <span>                                 
                   <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"fas fa-edit text-muted m-r-10 f-16")), array('controller' => 'Questions', 'action' => 'edit', $question->id),array('escape'=>false)) 
                   ?>
               </span>               
           </div>
           <?php endif;?>
       </div>
       
   </div>
</div>
</div>
</section>

<script type="text/javascript">
    function prevnt(e){

       e.preventDefault();
   }
</script>
<?php /*
<section class="pcoded-main-container">
<div class="pcoded-content">
    <div class="page-header">
        <div class="page-block">
            <div class="row align-items-center">
                <div class="col-md-12">
                    <div class="page-header-title">
                        <h5 class="m-b-10">Question Details<?php echo $this->Html->link('<i class="feather icon-list" ></i> Question List',array('controller'=>'Questions','action'=>'index'), array('class' => 'btn btn-primary pull-right','escape'=>false),array());?>
                        </h5>
                    </div>                   
                </div>
            </div>
        </div>
    </div>
    <div class="row">
         <div class="col-xl-12 col-md-12">
            <div class="card">
                <div class="card-body table-border-style">
                    <div class="table-responsive panel">
                        <div class="row">
                            <div class="col-xl-6 col-md-6">
                                <table class="vertical-table table table-striped">
                                    <tr>
                                        <th scope="row"><?= __('Paper') ?></th>
                                        <td><?=$question->Paper;
                                        $question->has('paper') ? $this->Html->link($question->paper->paper, ['controller' => 'Papers', 'action' => 'view', $question->paper->id]) : ''*?></td>
                                    </tr>
                                    <tr>
                                        <th scope="row"><?= __('Correct Ans') ?></th>
                                        <td><?= h($question->correct_ans) ?></td>
                                    </tr>
                                </table>
                            </div>
                            <div class="col-xl-6 col-md-6">
                                <table class="vertical-table table table-striped">

                                    <tr>
                                        <th scope="row"><?= __('Created') ?></th>
                                        <td><?= date('d,M,Y H:i',strtotime($question->created)) ?></td>
                                    </tr>
                                    <tr>
                                        <th scope="row"><?= __('Modified') ?></th>
                                        <td><?= date('d,M,Y H:i',strtotime($question->modified)) ?></td>
                                    </tr>
                                </table>
                            </div>
                            <div class="col-xl-12   ">
                                <h4><?= __('Question') ?></h4>
                                    <?= $this->Text->autoParagraph(h($question->question)); ?>
                            </div>
                            <div class="col-xl-12 ">
                                <h4><?= __('Answers') ?></h4>
                                  <ol type = 'A'>
                                 <?php $answars= explode(",",$question->answers);

                                 foreach($answars as $answer)  {?>
                                   
                                      <li><?= $answer?></li>
                                      
                                    <?php } ?>
                               </ol>
                            </div>
                        </div>
                        <div class="table-responsive dataTables_wrapper dt-bootstrap4">
                            <h5><?= __('Related Results') ?></h5>
                                <?php if (!empty($question->results)): ?>
                                <table cellpadding="0" cellspacing="0" class="table">
                                    <tr>
                                        <th scope="col">#</th>
                                        <th scope="col"><?= __('Question Id') ?></th>
                                        <th scope="col"><?= __('Freelancer Id') ?></th>
                                        <th scope="col"><?= __('Answer Status') ?></th>
                                        <th scope="col" class="actions"><?= __('Actions') ?></th>
                                    </tr>
                                    <?php $i = 1; foreach ($question->results as $results): ?>
                                    <tr>
                                        <td><?= $i++; ?></td>
                                        <td><?= h($results->question_id) ?></td>
                                        <td><?= h($results->freelancer_id) ?></td>
                                        <td><?php
                                            if($results->answer_status ==0){
                                                echo "Not answer";
                                            }else{
                                                echo "Answer";
                                            }
                                        ?></td>
                                        <td class="actions">
                                            <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"fas fa-eye btn btn-success",'traget' =>'_blank')), array('controller' => 'Results', 'action' => 'view', $results->id),array('escape'=>false,'target' =>'_blank')) ?>
                                        </td>
                                    </tr>
                                    <?php endforeach; ?>
                                </table>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
*/ ?>